在FPGA设计过程中,一般都要用到FIFO和RAM,如何利用altera 给出的megafunction配置成自己想要的FIFO和RAM,就得从自己的设计的RAM功能来看。主要考虑:端口数目、宽度和深度、时钟、时钟使能、读端口使能、输出端口是否寄存、复位(port、Widths and depths、Clks 、readen、Regs 、clkens、 Aclrs)。
这里强调下:
Asychronous Clear,只复位输入/输出端口的寄存器,不复位RAM块里的数据。对altera 的不同芯片,有的只复位输出寄存器,有的复位输入和输出寄存器。
还要注意:Write and Read Operations Triggering, 即读/写操作的时序,比如用M4K 的Memory Blocks作为RAM的话,下降沿写入数据,上升沿读出数据。
详细可以看:http://www.altera.com/literature/ug/ug_ram.pdf
下面就介绍几种常用的storage megafunction。
1. altsyncram
Parameterized true dual-port synchronous RAM megafunction。
端口:可配置成:一端口读(或一端读、一端写;一端读、双端写;双端口读、双端口读写)的异步复位RAM。
时钟:可配置成单一时钟、读/写双时钟、端口A/B双时钟。
2. lpm_fifo _dc
--------------------------------------------------------------------------------
Parameterized dual-clock FIFO megafunction.
读数据端口:可配置成Legacy synchronour FIFO mode 和Show-ahead synchronous FIFO mode.
3. lpm_fifo
--------------------------------------------------------------------------------
Parameterized single-clock FIFO megafunction.
4. lpm_shiftreg
--------------------------------------------------------------------------------
Parameterized shift register megafunction. Altera recommends that you use the lpm_shiftreg function to replace all other types of shift register functions.
5. lpm_tff
--------------------------------------------------------------------------------
Parameterized T-type flipflop megafunction. Altera recommends that you use lpm_ff rather than lpm_tff
下列的RAM megafunction,Altera 推荐用altsyncram
1. Alt3pram :
Parameterized triple-port RAM megafunction.
2. Altdpram
Parameterized dual-port RAM megafunction. This megafunction is provided only for backward compatibility in Cyclone, Cyclone II, HardCopy Stratix, Stratix, and Stratix GX designs; instead, Altera recommends using the altsyncram megafunction.
3. csdpram Parameterized cycle-shared dual-port RAM megafunction. Altera recommends using lpm_ram_dp for dual-port RAM functions in ACEX 1K, APEX 20K, APEX II, FLEX 10KE, and Mercury projects.
4. lpm_ram_dp
Parameterized dual-port RAM megafunction. This megafunction is provided only for backward compatibility in Cyclone, Cyclone II, HardCopy Stratix, Stratix, and Stratix GX designs; instead, Altera recommends using the altsyncram megafunction.
5. lpm_ram_dq Parameterized RAM with separate input and output ports megafunction. Altera recommends using lpm_ram_dq to implement asynchronous memory or memory with synchronous inputs and/or outputs. This megafunction is provided only for backward compatibility in Cyclone, Cyclone II, HardCopy Stratix, Stratix, and Stratix GX designs; instead, Altera recommends using the altsyncram megafunction.
6. lpm_ram_io Parameterized RAM with a single I/O port megafunction. This megafunction is provided only for backward compatibility in Cyclone, Cyclone II, HardCopy Stratix, Stratix, and Stratix GX design; instead, Altera recommends using the altsyncram megafunction.
7. pm_rom Megafunction
Parameterized ROM megafunction. Altera recommends that you use the lpm_rom function to implement all ROM functions. This megafunction is provided only for backward compatibility for Cyclone, Cyclone II, HardCopy Stratix, Stratix, and Stratix GX devices; instead, Altera recommends using the altsyncram megafunction.
下列的FIFO megafunction,Altera 推荐用lpm_fifo_dc
1. csfifo Megafunction
Parameterized cycle-shared FIFO megafunction. Altera recommends that you use lpm_fifo instead of csfifo for single-clock FIFO functions, and that you use lpm_fifo_dc instead of csfifo for dual-clock FIFO functions.
2. dcfifo Megafunction
Parameterized dual-clock FIFO megafunction
3. scfifo Megafunction
Parameterized single-clock FIFO megafunction