Reformat cache_ram

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
pull/283/head
Anton Blanchard 4 years ago committed by Anton Blanchard
parent 6523acc743
commit 74254bf11a

@ -5,21 +5,21 @@ use ieee.math_real.all;


entity cache_ram is entity cache_ram is
generic( generic(
ROW_BITS : integer := 16; ROW_BITS : integer := 16;
WIDTH : integer := 64; WIDTH : integer := 64;
TRACE : boolean := false; TRACE : boolean := false;
ADD_BUF : boolean := false ADD_BUF : boolean := false
); );


port( port(
clk : in std_logic; clk : in std_logic;
rd_en : in std_logic; rd_en : in std_logic;
rd_addr : in std_logic_vector(ROW_BITS - 1 downto 0); rd_addr : in std_logic_vector(ROW_BITS - 1 downto 0);
rd_data : out std_logic_vector(WIDTH - 1 downto 0); rd_data : out std_logic_vector(WIDTH - 1 downto 0);
wr_sel : in std_logic_vector(WIDTH/8 - 1 downto 0); wr_sel : in std_logic_vector(WIDTH/8 - 1 downto 0);
wr_addr : in std_logic_vector(ROW_BITS - 1 downto 0); wr_addr : in std_logic_vector(ROW_BITS - 1 downto 0);
wr_data : in std_logic_vector(WIDTH - 1 downto 0) wr_data : in std_logic_vector(WIDTH - 1 downto 0)
); );


end cache_ram; end cache_ram;


@ -35,13 +35,13 @@ architecture rtl of cache_ram is


begin begin
process(clk) process(clk)
variable lbit : integer range 0 to WIDTH - 1; variable lbit : integer range 0 to WIDTH - 1;
variable mbit : integer range 0 to WIDTH - 1; variable mbit : integer range 0 to WIDTH - 1;
variable widx : integer range 0 to SIZE - 1; variable widx : integer range 0 to SIZE - 1;
constant sel0 : std_logic_vector(WIDTH/8 - 1 downto 0) constant sel0 : std_logic_vector(WIDTH/8 - 1 downto 0)
:= (others => '0'); := (others => '0');
begin begin
if rising_edge(clk) then if rising_edge(clk) then
if TRACE then if TRACE then
if wr_sel /= sel0 then if wr_sel /= sel0 then
report "write a:" & to_hstring(wr_addr) & report "write a:" & to_hstring(wr_addr) &
@ -57,29 +57,29 @@ begin
ram(widx)(mbit downto lbit) <= wr_data(mbit downto lbit); ram(widx)(mbit downto lbit) <= wr_data(mbit downto lbit);
end if; end if;
end loop; end loop;
if rd_en = '1' then if rd_en = '1' then
rd_data0 <= ram(to_integer(unsigned(rd_addr))); rd_data0 <= ram(to_integer(unsigned(rd_addr)));
if TRACE then if TRACE then
report "read a:" & to_hstring(rd_addr) & report "read a:" & to_hstring(rd_addr) &
" dat:" & to_hstring(ram(to_integer(unsigned(rd_addr)))); " dat:" & to_hstring(ram(to_integer(unsigned(rd_addr))));
end if; end if;
end if; end if;
end if; end if;
end process; end process;


buf: if ADD_BUF generate buf: if ADD_BUF generate
begin begin
process(clk) process(clk)
begin begin
if rising_edge(clk) then if rising_edge(clk) then
rd_data <= rd_data0; rd_data <= rd_data0;
end if; end if;
end process; end process;
end generate; end generate;


nobuf: if not ADD_BUF generate nobuf: if not ADD_BUF generate
begin begin
rd_data <= rd_data0; rd_data <= rd_data0;
end generate; end generate;


end; end;

Loading…
Cancel
Save