Tips on using the lpm_ram_dq module

 

When using the lpm_ram_dq to access the memory on board, I found that it was most easily accomplished by synchronizing the input and output to the clock. By synchronizing the output to the clock, you can be sure of when the value presented on the output of the lpm_ram_dq is a valid and stable result. The drawback to synchronizing both the input and output to the clock is that every access to the RAM will take two clock cycles. This is because the output from the module will not be correct until one full clock cycle after the address was read in. The following waveform depicts how the lpm_ram_dq behaves:

 


Here is some sample code on how I generic and port mapped the lpm_ram_dq module when I created an instance of it:

 

memMod : lpm_ram_dq

generic map(lpm_width => DATA_WIDTH,

lpm_type => "L_RAM_DQ",
lpm_widthad => ADDR_WIDTH,
lpm_numwords => "unused",
lpm_file => "unused",
lpm_indata => "registered",
lpm_outdata => "registered",
lpm_hint => "unused",
lpm_address_control => "registered"
)
port map (data => indata,
address => address,
we => enab,
inclock => clock,
outclock => clock,
q => output
);

 

The explanations of each of these signals and generics can be found in the Altera's Max+plus2 help manual or at this other student application notes . However, it did not explain that when inputting an address to the lpm, the address is automatically adjusted by the width of the data for you. For example, if the current address was 01 (binary), then to read the next element after you can simply increment the address by 1 to give you an address of 10 (binary) regardless of the width of the data. As well, when you wish to write to memory, the write enable signal must be high at the same edge where the address is read in.

 


 

Author:

Patrick Chan (pcchan@gpu.srv.ualberta.ca)

364305

 

Co-Authors:

Neil Fraser 252885

Srilata Kammila 253698

Edmund Quan 244667

 

If there are any concerns about the content of this document, or if there are any errors, please e-mail me at pcchan@gpu.srv.ualberta.ca.