Код
entity ramdata is
generic
(
DATA_WIDTH : natural;
ADDR_WIDTH : natural
);
port
(
rclk : in std_logic;
wclk : in std_logic;
raddr : in std_logic_vector (0 to ADDR_WIDTH - 1);
waddr : in std_logic_vector (0 to ADDR_WIDTH - 1);
data : in std_logic_vector((DATA_WIDTH-1) downto 0);
we : in std_logic;
q : out std_logic_vector((DATA_WIDTH -1) downto 0)
);
end ramdata;
architecture behavioural of ramdata is
subtype byte is std_logic_vector((DATA_WIDTH-1) downto 0);
type memory is array(2**ADDR_WIDTH-1 downto 0) of byte;
signal ram : memory;
attribute ramstyle : string;
-- attribute ramstyle of ram : signal is "M512, no_rw_check";
attribute ramstyle of ram : signal is "M9K, no_rw_check";
-- attribute ramstyle of ram : signal is "M-RAM";
-- attribute ramstyle of ram : signal is "MLAB, no_rw_check";
begin
process(wclk)
begin
if(rising_edge(wclk)) then
if(we = '0') then
ram(conv_integer(waddr)) <= data;
end if;
end if;
end process;
process(rclk)
begin
if(rising_edge(rclk)) then
if(we = '0') then
q <= ram(conv_integer(raddr));
else
q <= (others => 'Z');
end if;
end if;
end process;
end behavioural;
generic
(
DATA_WIDTH : natural;
ADDR_WIDTH : natural
);
port
(
rclk : in std_logic;
wclk : in std_logic;
raddr : in std_logic_vector (0 to ADDR_WIDTH - 1);
waddr : in std_logic_vector (0 to ADDR_WIDTH - 1);
data : in std_logic_vector((DATA_WIDTH-1) downto 0);
we : in std_logic;
q : out std_logic_vector((DATA_WIDTH -1) downto 0)
);
end ramdata;
architecture behavioural of ramdata is
subtype byte is std_logic_vector((DATA_WIDTH-1) downto 0);
type memory is array(2**ADDR_WIDTH-1 downto 0) of byte;
signal ram : memory;
attribute ramstyle : string;
-- attribute ramstyle of ram : signal is "M512, no_rw_check";
attribute ramstyle of ram : signal is "M9K, no_rw_check";
-- attribute ramstyle of ram : signal is "M-RAM";
-- attribute ramstyle of ram : signal is "MLAB, no_rw_check";
begin
process(wclk)
begin
if(rising_edge(wclk)) then
if(we = '0') then
ram(conv_integer(waddr)) <= data;
end if;
end if;
end process;
process(rclk)
begin
if(rising_edge(rclk)) then
if(we = '0') then
q <= ram(conv_integer(raddr));
else
q <= (others => 'Z');
end if;
end if;
end process;
end behavioural;
Предполагается использовать ее для записи 128 бит информации одним импульсом записи, а считывать четырьмя импульсами чтения по 32 бита.
Похоже на глупость, но все-же...
Скажите пожалуйста возможно-ли в принципе организовать такой режим записи-чтения? Если да то как это примерно будет выглядеть на VHDL?