805ce7d0c3ac4b79e0f2ad723ee438d106c84acd
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

1) LIBRARY ieee;
2) USE ieee.std_logic_1164.all;
3) USE ieee.numeric_std.all;
4) USE work.mips_types.all;
5) 
6) ENTITY e_mips_core IS
7)     PORT (
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

8)         rst:            IN  std_logic;
9)         clk:            IN  std_logic;
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

10)         i_stall:        IN  std_logic;
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

11)         o_instr_addr:   OUT std_logic_vector(31 DOWNTO 0);
12)         i_instr_data:   IN  std_logic_vector(31 DOWNTO 0);
13)         o_data_addr:    OUT std_logic_vector(31 DOWNTO 0);
14)         i_data_rd_data: IN  std_logic_vector(31 DOWNTO 0);
15)         o_data_wr_data: OUT std_logic_vector(31 DOWNTO 0);
16)         o_data_wr_en:   OUT std_logic_vector( 3 DOWNTO 0)
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

17)     );
18) END ENTITY e_mips_core;
19) 
20) ARCHITECTURE a_mips_core OF e_mips_core IS
21) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

22)     SIGNAL s_stall:         std_logic;
23)     SIGNAL s_stall_data_rd: std_logic;
24) 
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

25)     SIGNAL r_pc: std_logic_vector(31 DOWNTO 0);
26)     SIGNAL n_pc: std_logic_vector(31 DOWNTO 0);
27) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

28)     SIGNAL s_instr: std_logic_vector(31 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

29) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

30)     SIGNAL n_reg_s:  std_logic_vector( 4 DOWNTO 0);
31)     SIGNAL n_reg_t:  std_logic_vector( 4 DOWNTO 0);
32)     SIGNAL n_reg_d:  std_logic_vector( 4 DOWNTO 0);
33)     SIGNAL n_imm_a:  std_logic_vector( 4 DOWNTO 0);
34)     SIGNAL n_imm_16: std_logic_vector(15 DOWNTO 0);
35)     SIGNAL n_imm_26: std_logic_vector(25 DOWNTO 0);
36)     SIGNAL n_op:     t_op;
37)     SIGNAL n_link:   t_link;
38)     SIGNAL n_cmp:    t_cmp;
39)     SIGNAL n_alu:    t_alu;
40)     SIGNAL n_imm:    t_imm;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

41)     SIGNAL n_ldst:   t_ldst;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

42) 
43)     SIGNAL r_reg_s:  std_logic_vector( 4 DOWNTO 0);
44)     SIGNAL r_reg_t:  std_logic_vector( 4 DOWNTO 0);
45)     SIGNAL r_reg_d:  std_logic_vector( 4 DOWNTO 0);
46)     SIGNAL r_imm_a:  std_logic_vector( 4 DOWNTO 0);
47)     SIGNAL r_imm_16: std_logic_vector(15 DOWNTO 0);
48)     SIGNAL r_imm_26: std_logic_vector(25 DOWNTO 0);
49)     SIGNAL r_op:     t_op;
50)     SIGNAL r_link:   t_link;
51)     SIGNAL r_cmp:    t_cmp;
52)     SIGNAL r_alu:    t_alu;
53)     SIGNAL r_imm:    t_imm;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

54)     SIGNAL r_ldst:   t_ldst;
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

55) 
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

56)     SIGNAL s_val_s: std_logic_vector(31 DOWNTO 0);
57)     SIGNAL s_val_t: std_logic_vector(31 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

58) 
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

59)     SIGNAL s_alu_op1: std_logic_vector(31 DOWNTO 0);
60)     SIGNAL s_alu_op2: std_logic_vector(31 DOWNTO 0);
61)     SIGNAL s_alu_res: std_logic_vector(31 DOWNTO 0);
62) 
63)     SIGNAL s_cmp_op1: std_logic_vector(31 DOWNTO 0);
64)     SIGNAL s_cmp_op2: std_logic_vector(31 DOWNTO 0);
65)     SIGNAL s_cmp_res: std_logic;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

66) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

67)     SIGNAL s_reg_wr_alu_no:   std_logic_vector( 4 DOWNTO 0);
68)     SIGNAL s_reg_wr_alu_data: std_logic_vector(31 DOWNTO 0);
69)     SIGNAL s_reg_wr_alu_en:   std_logic;
70) 
71)     SIGNAL s_reg_wr_data_no:   std_logic_vector( 4 DOWNTO 0);
72)     SIGNAL s_reg_wr_data_data: std_logic_vector(31 DOWNTO 0);
73)     SIGNAL s_reg_wr_data_en:   std_logic;
74) 
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

75)     SIGNAL s_reg_wr_no:   std_logic_vector( 4 DOWNTO 0);
76)     SIGNAL s_reg_wr_data: std_logic_vector(31 DOWNTO 0);
77)     SIGNAL s_reg_wr_en:   std_logic;
78) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

79)     SIGNAL s_data_addr: std_logic_vector(31 DOWNTO 0);
80) 
81)     TYPE t_data_rd IS (data_rd_idle, data_rd_read);
82)     SIGNAL r_data_rd: t_data_rd;
83)     SIGNAL n_data_rd: t_data_rd;
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

84) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

85)     COMPONENT e_mips_decoder IS
86)         PORT (
87)             i_instr:  IN  std_logic_vector(31 DOWNTO 0);
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

88)             o_reg_s:  OUT std_logic_vector( 4 DOWNTO 0);
89)             o_reg_t:  OUT std_logic_vector( 4 DOWNTO 0);
90)             o_reg_d:  OUT std_logic_vector( 4 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

91)             o_imm_a:  OUT std_logic_vector( 4 DOWNTO 0);
92)             o_imm_16: OUT std_logic_vector(15 DOWNTO 0);
93)             o_imm_26: OUT std_logic_vector(25 DOWNTO 0);
94)             o_op:     OUT t_op;
95)             o_link:   OUT t_link;
96)             o_cmp:    OUT t_cmp;
97)             o_alu:    OUT t_alu;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

98)             o_imm:    OUT t_imm;
99)             o_ldst:   OUT t_ldst
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

100)         );
101)     END COMPONENT e_mips_decoder;
102) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

103)     COMPONENT e_mips_regs IS
104)         PORT (
105)             rst:         IN  std_logic;
106)             clk:         IN  std_logic;
107)             i_rd_a_no:   IN  std_logic_vector( 4 DOWNTO 0);
108)             o_rd_a_data: OUT std_logic_vector(31 DOWNTO 0);
109)             i_rd_b_no:   IN  std_logic_vector( 4 DOWNTO 0);
110)             o_rd_b_data: OUT std_logic_vector(31 DOWNTO 0);
111)             i_wr_no:     IN  std_logic_vector( 4 DOWNTO 0);
112)             i_wr_data:   IN  std_logic_vector(31 DOWNTO 0);
113)             i_wr_en:     IN  std_logic
114)         );
115)     END COMPONENT e_mips_regs;
116) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

117)     COMPONENT e_mips_alu IS
118)         PORT (
119)             i_alu: IN  t_alu;
120)             i_op1: IN  std_logic_vector(31 DOWNTO 0);
121)             i_op2: IN  std_logic_vector(31 DOWNTO 0);
122)             o_res: OUT std_logic_vector(31 DOWNTO 0)
123)         );
124)     END COMPONENT e_mips_alu;
125) 
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

126)     COMPONENT e_mips_cmp IS
127)         PORT (
128)             i_cmp: IN  t_cmp;
129)             i_op1: IN  std_logic_vector(31 DOWNTO 0);
130)             i_op2: IN  std_logic_vector(31 DOWNTO 0);
131)             o_res: OUT std_logic
132)         );
133)     END COMPONENT e_mips_cmp;
134) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

135) BEGIN
136) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

137)     s_stall <= i_stall OR s_stall_data_rd;
138) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

139)     decoder: e_mips_decoder
140)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

141)             i_instr  => s_instr,
142)             o_reg_s  => n_reg_s,
143)             o_reg_t  => n_reg_t,
144)             o_reg_d  => n_reg_d,
145)             o_imm_a  => n_imm_a,
146)             o_imm_16 => n_imm_16,
147)             o_imm_26 => n_imm_26,
148)             o_op     => n_op,
149)             o_link   => n_link,
150)             o_cmp    => n_cmp,
151)             o_alu    => n_alu,
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

152)             o_imm    => n_imm,
153)             o_ldst   => n_ldst
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

154)         );
155) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

156)     regs: e_mips_regs
157)         PORT MAP (
158)             rst         => rst,
159)             clk         => clk,
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

160)             i_rd_a_no   => r_reg_s,
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

161)             o_rd_a_data => s_val_s,
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

162)             i_rd_b_no   => r_reg_t,
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

163)             o_rd_b_data => s_val_t,
164)             i_wr_no     => s_reg_wr_no,
165)             i_wr_data   => s_reg_wr_data,
166)             i_wr_en     => s_reg_wr_en
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

167)         );
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

168) 
169)     alu: e_mips_alu
170)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

171)             i_alu => r_alu,
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

172)             i_op1 => s_alu_op1,
173)             i_op2 => s_alu_op2,
174)             o_res => s_alu_res
175)         );
176) 
177)     cmp: e_mips_cmp
178)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

179)             i_cmp => r_cmp,
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

180)             i_op1 => s_cmp_op1,
181)             i_op2 => s_cmp_op2,
182)             o_res => s_cmp_res
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

183)         );
184) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

185)     p_sync_pc: PROCESS(rst, clk)
186)     BEGIN
187)         IF rst = '1' THEN
188)             r_pc <= (OTHERS => '0');
189)         ELSIF rising_edge(clk) THEN
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

190)             IF s_stall = '0' THEN
191)                 r_pc <= n_pc;
192)             END IF;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

193)         END IF;
194)     END PROCESS p_sync_pc;
195) 
196)     p_fetch: PROCESS(n_pc, i_instr_data)
197)     BEGIN
198)         o_instr_addr <= n_pc;
199)         s_instr      <= i_instr_data;
200)     END PROCESS p_fetch;
201) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

202)     p_sync_dec2ex: PROCESS(rst, clk)
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

203)     BEGIN
204)         IF rst = '1' THEN
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

205)             r_reg_s  <= (OTHERS => '0');
206)             r_reg_t  <= (OTHERS => '0');
207)             r_reg_d  <= (OTHERS => '0');
208)             r_imm_a  <= (OTHERS => '0');
209)             r_imm_16 <= (OTHERS => '0');
210)             r_imm_26 <= (OTHERS => '0');
211)             r_op     <= op_none;
212)             r_link   <= link_none;
213)             r_cmp    <= cmp_none;
214)             r_alu    <= alu_none;
215)             r_imm    <= imm_none;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

216)             r_ldst   <= ldst_none;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

217)         ELSIF rising_edge(clk) THEN
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

218)             IF s_stall = '0' THEN
219)                 r_reg_s  <= n_reg_s;
220)                 r_reg_t  <= n_reg_t;
221)                 r_reg_d  <= n_reg_d;
222)                 r_imm_a  <= n_imm_a;
223)                 r_imm_16 <= n_imm_16;
224)                 r_imm_26 <= n_imm_26;
225)                 r_op     <= n_op;
226)                 r_link   <= n_link;
227)                 r_cmp    <= n_cmp;
228)                 r_alu    <= n_alu;
229)                 r_imm    <= n_imm;
230)                 r_ldst   <= n_ldst;
231)             END IF;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

232)         END IF;
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

233)     END PROCESS p_sync_dec2ex;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

234) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

235)     p_alu_in: PROCESS(r_op, r_imm, s_val_s, s_val_t, r_imm_a, r_imm_16)
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

236)     BEGIN
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

237)         s_alu_op1 <= (OTHERS => '0');
238)         s_alu_op2 <= (OTHERS => '0');
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

239)         IF r_op = op_alu THEN
240)             CASE r_imm IS
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

241)                 WHEN imm_none =>
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

242)                     s_alu_op1 <= s_val_s;
243)                     s_alu_op2 <= s_val_t;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

244)                 WHEN imm_a =>
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

245)                     s_alu_op1(4 DOWNTO 0) <= r_imm_a;
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

246)                     s_alu_op2 <= s_val_t;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

247)                 WHEN imm_16se =>
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

248)                     s_alu_op1 <= s_val_s;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

249)                     s_alu_op2(15 DOWNTO 0) <= r_imm_16;
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

250)                     s_alu_op2(31 DOWNTO 16) <= (OTHERS => r_imm_16(15));
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

251)                 WHEN imm_16ze =>
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

252)                     s_alu_op1 <= s_val_s;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

253)                     s_alu_op2(15 DOWNTO 0) <= r_imm_16;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

254)                 WHEN OTHERS => NULL;
255)             END CASE;
256)         END IF;
257)     END PROCESS p_alu_in;
258) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

259)     p_alu_out: PROCESS(r_op, r_imm, r_reg_t, r_reg_d, s_alu_res)
260)     BEGIN
261)         s_reg_wr_alu_no   <= (OTHERS => '0');
262)         s_reg_wr_alu_data <= (OTHERS => '0');
263)         s_reg_wr_alu_en   <= '0';
264)         IF r_op = op_alu THEN
265)             CASE r_imm IS
266)                 WHEN imm_none | imm_a =>
267)                     s_reg_wr_alu_no   <= r_reg_d;
268)                     s_reg_wr_alu_data <= s_alu_res;
269)                     s_reg_wr_alu_en   <= '1';
270)                 WHEN imm_16se | imm_16ze =>
271)                     s_reg_wr_alu_no   <= r_reg_t;
272)                     s_reg_wr_alu_data <= s_alu_res;
273)                     s_reg_wr_alu_en   <= '1';
274)                 WHEN OTHERS => NULL;
275)             END CASE;
276)         END IF;
277)     END PROCESS p_alu_out;
278) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

279)     p_cmp_in: PROCESS(r_op, s_val_s, s_val_t)
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

280)     BEGIN
281)         s_cmp_op1 <= (OTHERS => '0');
282)         s_cmp_op2 <= (OTHERS => '0');
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

283)         IF r_op = op_j THEN
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

284)             s_cmp_op1 <= s_val_s;
285)             s_cmp_op2 <= s_val_t;
286)         END IF;
287)     END PROCESS p_cmp_in;
288) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

289)     p_reg_wr: PROCESS(s_stall,
290)                       s_reg_wr_alu_no, s_reg_wr_alu_data, s_reg_wr_alu_en,
291)                       s_reg_wr_data_no, s_reg_wr_data_data, s_reg_wr_data_en)
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

292)     BEGIN
293)         s_reg_wr_no   <= (OTHERS => '0');
294)         s_reg_wr_data <= (OTHERS => '0');
295)         s_reg_wr_en   <= '0';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

296)         IF s_stall = '0' THEN
297)             IF s_reg_wr_alu_en = '1' THEN
298)                 s_reg_wr_no   <= s_reg_wr_alu_no;
299)                 s_reg_wr_data <= s_reg_wr_alu_data;
300)                 s_reg_wr_en   <= '1';
301)             ELSIF s_reg_wr_data_en = '1' THEN
302)                 s_reg_wr_no   <= s_reg_wr_data_no;
303)                 s_reg_wr_data <= s_reg_wr_data_data;
304)                 s_reg_wr_en   <= '1';
305)             END IF;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

306)         END IF;
307)     END PROCESS p_reg_wr;
308) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

309)     p_next_pc: PROCESS(r_pc, r_op, r_imm, s_cmp_res, r_imm_16, r_imm_26)
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

310)         VARIABLE v_pc:  signed(31 DOWNTO 0);
311)         VARIABLE v_rel: signed(17 DOWNTO 0);
312)     BEGIN
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

313)         IF r_op = op_j AND s_cmp_res = '1' THEN
314)             IF r_imm = imm_26 THEN
315)                 n_pc <= r_pc(31 DOWNTO 28) & r_imm_26 & "00";
316)             ELSE
317)                 n_pc <= std_logic_vector(signed(r_pc) +
318)                                          signed(r_imm_16 & "00"));
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

319)             END IF;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

320)         ELSE
321)             n_pc <= std_logic_vector(signed(r_pc) + to_signed(4, 32));
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

322)         END IF;
323)     END PROCESS p_next_pc;
324) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

325)     p_data_addr: PROCESS(r_op, s_val_s, r_imm_16)
326)         VARIABLE v_ofs: signed(31 DOWNTO 0);
327)         VARIABLE v_addr: signed(31 DOWNTO 0);
328)     BEGIN
329)         s_data_addr <= (OTHERS => '0');
330)         IF r_op = op_l OR r_op = op_s THEN
331)             v_ofs(15 DOWNTO 0)  := signed(r_imm_16);
332)             v_ofs(31 DOWNTO 16) := (OTHERS => r_imm_16(15));
333)             v_addr              := signed(s_val_s) + v_ofs;
334)             s_data_addr         <= std_logic_vector(v_addr);
335)         END IF;
336)     END PROCESS p_data_addr;
337) 
338)     o_data_addr <= s_data_addr(31 DOWNTO 2) & "00";
339) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

340)     p_data_rd: PROCESS(r_data_rd, r_op, r_ldst, s_data_addr, r_reg_t, i_data_rd_data)
341)         VARIABLE v_b: std_logic_vector( 7 DOWNTO 0);
342)         VARIABLE v_h: std_logic_vector(15 DOWNTO 0);
343)     BEGIN
344)         s_stall_data_rd    <= '0';
345)         n_data_rd          <= data_rd_idle;
346)         s_reg_wr_data_no   <= (OTHERS => '0');
347)         s_reg_wr_data_data <= (OTHERS => '0');
348)         s_reg_wr_data_en   <= '0';
349)         CASE r_data_rd IS
350)             WHEN data_rd_idle =>
351)                 IF r_op = op_l THEN
352)                     s_stall_data_rd <= '1';
353)                     n_data_rd <= data_rd_read;
354)                 END IF;
355)             WHEN data_rd_read =>
356)                 CASE r_ldst IS
357)                     WHEN ldst_b | ldst_bu =>
358)                         CASE s_data_addr(1 DOWNTO 0) IS
359)                             WHEN "00" => v_b := i_data_rd_data( 7 DOWNTO  0);
360)                             WHEN "01" => v_b := i_data_rd_data(15 DOWNTO  8);
361)                             WHEN "10" => v_b := i_data_rd_data(23 DOWNTO 16);
362)                             WHEN "11" => v_b := i_data_rd_data(31 DOWNTO 24);
363)                             WHEN OTHERS => NULL;
364)                         END CASE;
365)                         s_reg_wr_data_data(7 DOWNTO 0) <= v_b;
366)                         IF r_ldst = ldst_b THEN
367)                             s_reg_wr_data_data(31 DOWNTO 8) <= (OTHERS => v_b(7));
368)                         END IF;
369)                     WHEN ldst_h | ldst_hu =>
370)                         CASE s_data_addr(1 DOWNTO 1) IS
371)                             WHEN "0" => v_h := i_data_rd_data(15 DOWNTO  0);
372)                             WHEN "1" => v_h := i_data_rd_data(31 DOWNTO 16);
373)                             WHEN OTHERS => NULL;
374)                         END CASE;
375)                         s_reg_wr_data_data(15 DOWNTO 0) <= v_h;
376)                         IF r_ldst = ldst_h THEN
377)                             s_reg_wr_data_data(31 DOWNTO 16) <= (OTHERS => v_h(15));
378)                         END IF;
379)                     WHEN ldst_w =>
380)                         s_reg_wr_data_data <= i_data_rd_data;
381)                     WHEN OTHERS => NULL;
382)                 END CASE;
383)                 s_reg_wr_data_no <= r_reg_t;
384)                 s_reg_wr_data_en <= '1';
385)             WHEN OTHERS => NULL;
386)         END CASE;
387)     END PROCESS p_data_rd;
388) 
389)     p_sync_data_rd: PROCESS(rst, clk)
390)     BEGIN
391)         IF rst = '1' THEN
392)             r_data_rd <= data_rd_idle;
393)         ELSIF rising_edge(clk) THEN
394)             IF i_stall = '0' THEN
395)                 r_data_rd <= n_data_rd;
396)             END IF;
397)         END IF;
398)     END PROCESS p_sync_data_rd;
399) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

400)     p_data_wr: PROCESS(r_op, r_ldst, s_data_addr, s_val_t)
401)     BEGIN
402)         o_data_wr_data <= (OTHERS => '0');
403)         o_data_wr_en   <= "0000";
404)         IF r_op = op_s THEN
405)             CASE r_ldst IS
406)                 WHEN ldst_b =>
407)                     CASE s_data_addr(1 DOWNTO 0) IS
408)                         WHEN "00" =>
409)                             o_data_wr_data( 7 DOWNTO  0) <= s_val_t(7 DOWNTO 0);
410)                             o_data_wr_en                 <= "0001";
411)                         WHEN "01" =>
412)                             o_data_wr_data(15 DOWNTO  8) <= s_val_t(7 DOWNTO 0);
413)                             o_data_wr_en                 <= "0010";
414)                         WHEN "10" =>
415)                             o_data_wr_data(23 DOWNTO 16) <= s_val_t(7 DOWNTO 0);
416)                             o_data_wr_en                 <= "0100";
417)                         WHEN "11" =>
418)                             o_data_wr_data(31 DOWNTO 24) <= s_val_t(7 DOWNTO 0);
419)                             o_data_wr_en                 <= "1000";
420)                         WHEN OTHERS => NULL;
421)                     END CASE;
422)                 WHEN ldst_h =>
423)                     CASE s_data_addr(1 DOWNTO 1) IS
424)                         WHEN "0" =>
425)                             o_data_wr_data(15 DOWNTO  0) <= s_val_t(15 DOWNTO 0);
426)                             o_data_wr_en                 <= "0011";
427)                         WHEN "1" =>
428)                             o_data_wr_data(31 DOWNTO 16) <= s_val_t(15 DOWNTO 0);
429)                             o_data_wr_en                 <= "1100";
430)                         WHEN OTHERS => NULL;
431)                     END CASE;
432)                 WHEN ldst_w =>
433)                     o_data_wr_data <= s_val_t;
434)                     o_data_wr_en   <= "1111";
435)                 WHEN OTHERS => NULL;
436)             END CASE;
437)         END IF;
438)     END PROCESS p_data_wr;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

439)