Repository navigation
Expand file tree
/
Copy pathIRAM_wrapper.vhd
More file actions
137 lines (113 loc) · 2.83 KB
/
Copy pathIRAM_wrapper.vhd
File metadata and controls
137 lines (113 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use std.textio.all;
use ieee.std_logic_textio.all;
use WORK.constants.all;
use WORK.functions.all;
-- Memory filled by a process which reads from a file
entity IRAM_wrapper is
port (
Clk : in std_logic;
Rst : in std_logic;
Addr : in std_logic_vector(9 downto 0);
Dout : out std_logic_vector(31 downto 0)
);
end IRAM_wrapper ;
architecture IRam_Bhe of IRAM_wrapper is
component sram_32_1024_freepdk45 is
port (
clk0 : in std_logic; -- clock
csb0 : in std_logic; -- chip select (negative triggered)
web0 : in std_logic; -- Read not Write
din0 : in std_logic_vector(31 downto 0); -- input data
addr0 : in std_logic_vector(9 downto 0); -- address
dout0 : out std_logic_vector(31 downto 0)); -- read data
end component;
subtype RAMaddrs is natural range 0 to N_INSTR; -- range of addresses. The 4 is needed because the mem is byte addressable and we convert the mem_size from #words to #bytes
type RAM_ARRAY is array(RAMaddrs) of std_logic_vector(31 downto 0); -- size of data per address
constant IRAM_mem : RAM_ARRAY := (x"47db4e29",
x"581acfad",
x"461acfa9",
x"3864bf2d",
x"e38d41c2",
x"1ccd44e2",
x"1c4c403e",
x"1ccc40be",
x"2251d1ef",
x"cd51d5cb",
x"3220d14b",
x"32f0d1eb",
x"38c3df0b",
x"3912f9c7",
x"3813d9ab",
x"28d3fe9f",
x"24db9572",
x"247c3e42",
x"257d3a42",
x"247cbb36",
x"128d097f",
x"1298286f",
x"137e78ef",
x"124fe94f",
x"08d48bfb",
x"4a95d5ab",
x"4807185b",
x"48678adb",
x"6e18cf83",
x"6eaaed33",
x"6eeacda3",
x"2f5a1c23",
x"726a40b2",
x"324b00b2",
x"725b5362",
x"726c8132",
x"e36e1313",
x"1d8d04e3",
x"1d8b8197"
);
signal s_data_in: std_logic_vector(31 downto 0);
signal IRAM_addr, s_IRAM_addr, ss_IRAM_addr: std_logic_vector(9 downto 0);
signal s_RnW: std_logic;
signal idx, idx_next: std_logic_vector(9 downto 0);
begin
instr_mem: sram_32_1024_freepdk45
port map (
clk0 => CLK,
web0 => s_RnW, -- Read not Write
din0 => s_data_in,
addr0 => IRAM_addr,
csb0 => '0',
dout0 => Dout
);
IRAM_addr <= s_IRAM_addr when (rst= '0') else
ss_IRAM_addr;
s_RnW <= '0' when (rst= '0') else
'1';
idx_proc: process(clk,rst) begin
if(rst = '1') then
idx<= (others=>'0');
else
if( rising_edge(clk)) then
idx <= idx_next;
end if;
end if;
end process idx_proc;
rst_proc: process(idx,rst)
begin
if(rst = '1') then
idx_next<=(others=>'0');
else
if(to_integer(unsigned(idx)) <= N_INSTR) then
s_data_in <= IRAM_mem(to_integer(unsigned(idx)));
s_IRAM_addr <= idx;
idx_next <= std_logic_vector(unsigned(idx) +1);
end if;
end if;
end process rst_proc;
read_proc: process(addr) begin
if(rst = '1') then
ss_IRAM_addr <= "00"&addr(9 downto 2);
end if;
end process read_proc;
end IRam_Bhe;