仅对英特尔可见 — GUID: mwh1409959588216
Ixiasoft
1.4.1.1. 使用同步的存储器模块
1.4.1.2. 避免不受支持的复位和控制条件
1.4.1.3. 检查Read-During-Write行为
1.4.1.4. 控制RAM推断和实现
1.4.1.5. 具有旧数据Read-During-Write行为的单时钟同步RAM
1.4.1.6. 具有新数据Read-During-Write行为的单时钟同步RAM
1.4.1.7. 简单双端口,双时钟同步RAM
1.4.1.8. 真双端口同步RAM
1.4.1.9. 混合宽度双端口RAM
读取宽度小于写入宽度的SystemVerilog混合宽度RAM
读取宽度大于写入宽度的SystemVerilog混合宽度RAM
读取宽度小于写入宽度的VHDL混合宽度RAM
读取宽度大于写入宽度的VHDL混合宽度RAM
1.4.1.10. 带Byte-Enable信号的RAM
1.4.1.11. 上电时指定初始存储器内容
仅对英特尔可见 — GUID: mwh1409959588216
Ixiasoft
1.4.1.9. 混合宽度双端口RAM
本节中的RAM代码示例显示SystemVerilog和VHDL代码,这些代码通过不同宽度的数据端口推断RAM。
Verilog-1995不支持混合宽度RAM,因为此标准缺少用于对不同的读取宽度和/或写入宽度进行建模的多维数组。Verilog-2001不支持混合宽度RAM,因为这种类型的逻辑需要多个封装尺寸。不同的综合工具对这些存储器的支持可能有所不同。本节描述 Intel® Quartus® Prime Pro Edition综合的推断规则。
多维封装阵列的第一维表示宽端口与窄端口的比率。第二维表示较窄的端口宽度。读取和写入端口的宽度必须指定目标器件中存储器模块支持的读取或写入比率。否则,综合工具不会推断RAM。
请参考 Intel® Quartus® Prime HDL模板来了解支持读写宽度组合的参数化示例。您还可以找到具有两个混合宽度读取端口和两个混合宽度写入端口的真双端口RAM的示例。
读取宽度小于写入宽度的SystemVerilog混合宽度RAM
module mixed_width_ram // 256x32 write and 1024x8 read
(
input [7:0] waddr,
input [31:0] wdata,
input we, clk,
input [9:0] raddr,
output logic [7:0] q
);
logic [3:0][7:0] ram[0:255];
always_ff@(posedge clk)
begin
if(we) ram[waddr] <= wdata;
q <= ram[raddr / 4][raddr % 4];
end
endmodule : mixed_width_ram
读取宽度大于写入宽度的SystemVerilog混合宽度RAM
module mixed_width_ram // 1024x8 write and 256x32 read
(
input [9:0] waddr,
input [31:0] wdata,
input we, clk,
input [7:0] raddr,
output logic [9:0] q
);
logic [3:0][7:0] ram[0:255];
always_ff@(posedge clk)
begin
if(we) ram[waddr / 4][waddr % 4] <= wdata;
q <= ram[raddr];
end
endmodule : mixed_width_ram
读取宽度小于写入宽度的VHDL混合宽度RAM
library ieee;
use ieee.std_logic_1164.all;
package ram_types is
type word_t is array (0 to 3) of std_logic_vector(7 downto 0);
type ram_t is array (0 to 255) of word_t;
end ram_types;
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.ram_types.all;
entity mixed_width_ram is
port (
we, clk : in std_logic;
waddr : in integer range 0 to 255;
wdata : in word_t;
raddr : in integer range 0 to 1023;
q : out std_logic_vector(7 downto 0));
end mixed_width_ram;
architecture rtl of mixed_width_ram is
signal ram : ram_t;
begin -- rtl
process(clk, we)
begin
if(rising_edge(clk)) then
if(we = '1') then
ram(waddr) <= wdata;
end if;
q <= ram(raddr / 4 )(raddr mod 4);
end if;
end process;
end rtl;
读取宽度大于写入宽度的VHDL混合宽度RAM
library ieee;
use ieee.std_logic_1164.all;
package ram_types is
type word_t is array (0 to 3) of std_logic_vector(7 downto 0);
type ram_t is array (0 to 255) of word_t;
end ram_types;
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.ram_types.all;
entity mixed_width_ram is
port (
we, clk : in std_logic;
waddr : in integer range 0 to 1023;
wdata : in std_logic_vector(7 downto 0);
raddr : in integer range 0 to 255;
q : out word_t);
end mixed_width_ram;
architecture rtl of mixed_width_ram is
signal ram : ram_t;
begin -- rtl
process(clk, we)
begin
if(rising_edge(clk)) then
if(we = '1') then
ram(waddr / 4)(waddr mod 4) <= wdata;
end if;
q <= ram(raddr);
end if;
end process;
end rtl;