Skip to content

Commit 419c9a6

Browse files
authored
Merge pull request #206 from Jbalkind/icachecleanup
Icache constants cleanup
2 parents 57604c1 + d9bda52 commit 419c9a6

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

icache.vhdl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ entity icache is
3232
SIM : boolean := false;
3333
-- Line size in bytes
3434
LINE_SIZE : positive := 64;
35+
-- BRAM organisation: We never access more than wishbone_data_bits at
36+
-- a time so to save resources we make the array only that wide, and
37+
-- use consecutive indices for to make a cache "line"
38+
--
39+
-- ROW_SIZE is the width in bytes of the BRAM (based on WB, so 64-bits)
40+
ROW_SIZE : positive := wishbone_data_bits / 8;
3541
-- Number of lines in a set
3642
NUM_LINES : positive := 32;
3743
-- Number of ways
@@ -65,19 +71,14 @@ entity icache is
6571
end entity icache;
6672

6773
architecture rtl of icache is
68-
-- BRAM organisation: We never access more than wishbone_data_bits at
69-
-- a time so to save resources we make the array only that wide, and
70-
-- use consecutive indices for to make a cache "line"
71-
--
72-
-- ROW_SIZE is the width in bytes of the BRAM (based on WB, so 64-bits)
73-
constant ROW_SIZE : natural := wishbone_data_bits / 8;
74+
constant ROW_SIZE_BITS : natural := ROW_SIZE*8;
7475
-- ROW_PER_LINE is the number of row (wishbone transactions) in a line
7576
constant ROW_PER_LINE : natural := LINE_SIZE / ROW_SIZE;
7677
-- BRAM_ROWS is the number of rows in BRAM needed to represent the full
7778
-- icache
7879
constant BRAM_ROWS : natural := NUM_LINES * ROW_PER_LINE;
7980
-- INSN_PER_ROW is the number of 32bit instructions per BRAM row
80-
constant INSN_PER_ROW : natural := wishbone_data_bits / 32;
81+
constant INSN_PER_ROW : natural := ROW_SIZE_BITS / 32;
8182
-- Bit fields counts in the address
8283

8384
-- INSN_BITS is the number of bits to select an instruction in a row
@@ -118,7 +119,7 @@ architecture rtl of icache is
118119
subtype row_in_line_t is unsigned(ROW_LINEBITS-1 downto 0);
119120

120121
-- The cache data BRAM organized as described above for each way
121-
subtype cache_row_t is std_ulogic_vector(wishbone_data_bits-1 downto 0);
122+
subtype cache_row_t is std_ulogic_vector(ROW_SIZE_BITS-1 downto 0);
122123

123124
-- The cache tags LUTRAM has a row per set. Vivado is a pain and will
124125
-- not handle a clean (commented) definition of the cache tags as a 3d
@@ -363,7 +364,7 @@ begin
363364
way: entity work.cache_ram
364365
generic map (
365366
ROW_BITS => ROW_BITS,
366-
WIDTH => wishbone_data_bits
367+
WIDTH => ROW_SIZE_BITS
367368
)
368369
port map (
369370
clk => clk,

0 commit comments

Comments
 (0)