ad34555f470c3144c00279791b853640a76f3c44
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 implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

75)     SIGNAL s_reg_wr_hi_lo_no:   std_logic_vector( 4 DOWNTO 0);
76)     SIGNAL s_reg_wr_hi_lo_data: std_logic_vector(31 DOWNTO 0);
77)     SIGNAL s_reg_wr_hi_lo_en:   std_logic;
78) 
Stefan Schuermans implemented ... and link ->...

Stefan Schuermans authored 12 years ago

79)     SIGNAL s_reg_wr_link_no:   std_logic_vector( 4 DOWNTO 0);
80)     SIGNAL s_reg_wr_link_data: std_logic_vector(31 DOWNTO 0);
81)     SIGNAL s_reg_wr_link_en:   std_logic;
82) 
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

83)     SIGNAL s_reg_wr_no:   std_logic_vector( 4 DOWNTO 0);
84)     SIGNAL s_reg_wr_data: std_logic_vector(31 DOWNTO 0);
85)     SIGNAL s_reg_wr_en:   std_logic;
86) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

87)     SIGNAL s_data_addr: std_logic_vector(31 DOWNTO 0);
88) 
89)     TYPE t_data_rd IS (data_rd_idle, data_rd_read);
90)     SIGNAL n_data_rd: t_data_rd;
Stefan Schuermans implemented multiplier

Stefan Schuermans authored 12 years ago

91)     SIGNAL r_data_rd: t_data_rd;
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

92) 
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

93)     SIGNAL n_reg_lo: std_logic_vector(31 DOWNTO 0);
94)     SIGNAL n_reg_hi: std_logic_vector(31 DOWNTO 0);
95)     SIGNAL r_reg_lo: std_logic_vector(31 DOWNTO 0);
96)     SIGNAL r_reg_hi: std_logic_vector(31 DOWNTO 0);
97) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

98)     SIGNAL s_mul_signed: std_logic;
99)     SIGNAL s_mul_start:  std_logic;
100)     SIGNAL s_mul_busy:   std_logic;
101)     SIGNAL s_mul_res:    std_logic_vector(63 DOWNTO 0);
Stefan Schuermans implemented multiplier

Stefan Schuermans authored 12 years ago

102) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

103)     SIGNAL s_div_signed: std_logic;
104)     SIGNAL s_div_start:  std_logic;
105)     SIGNAL s_div_busy:   std_logic;
106)     SIGNAL s_div_res:    std_logic_vector(31 DOWNTO 0);
107)     SIGNAL s_div_rem:    std_logic_vector(31 DOWNTO 0);
108) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

112)             o_reg_s:  OUT std_logic_vector( 4 DOWNTO 0);
113)             o_reg_t:  OUT std_logic_vector( 4 DOWNTO 0);
114)             o_reg_d:  OUT std_logic_vector( 4 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

115)             o_imm_a:  OUT std_logic_vector( 4 DOWNTO 0);
116)             o_imm_16: OUT std_logic_vector(15 DOWNTO 0);
117)             o_imm_26: OUT std_logic_vector(25 DOWNTO 0);
118)             o_op:     OUT t_op;
119)             o_link:   OUT t_link;
120)             o_cmp:    OUT t_cmp;
121)             o_alu:    OUT t_alu;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

124)         );
125)     END COMPONENT e_mips_decoder;
126) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

127)     COMPONENT e_mips_regs IS
128)         PORT (
129)             rst:         IN  std_logic;
130)             clk:         IN  std_logic;
131)             i_rd_a_no:   IN  std_logic_vector( 4 DOWNTO 0);
132)             o_rd_a_data: OUT std_logic_vector(31 DOWNTO 0);
133)             i_rd_b_no:   IN  std_logic_vector( 4 DOWNTO 0);
134)             o_rd_b_data: OUT std_logic_vector(31 DOWNTO 0);
135)             i_wr_no:     IN  std_logic_vector( 4 DOWNTO 0);
136)             i_wr_data:   IN  std_logic_vector(31 DOWNTO 0);
137)             i_wr_en:     IN  std_logic
138)         );
139)     END COMPONENT e_mips_regs;
140) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

141)     COMPONENT e_mips_alu IS
142)         PORT (
143)             i_alu: IN  t_alu;
144)             i_op1: IN  std_logic_vector(31 DOWNTO 0);
145)             i_op2: IN  std_logic_vector(31 DOWNTO 0);
146)             o_res: OUT std_logic_vector(31 DOWNTO 0)
147)         );
148)     END COMPONENT e_mips_alu;
149) 
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

150)     COMPONENT e_mips_cmp IS
151)         PORT (
152)             i_cmp: IN  t_cmp;
153)             i_op1: IN  std_logic_vector(31 DOWNTO 0);
154)             i_op2: IN  std_logic_vector(31 DOWNTO 0);
155)             o_res: OUT std_logic
156)         );
157)     END COMPONENT e_mips_cmp;
158) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

159)     COMPONENT e_mips_mul IS
160)         PORT (
161)             rst:      IN  std_logic;
162)             clk:      IN  std_logic;
163)             i_a:      IN  std_logic_vector(31 DOWNTO 0);
164)             i_b:      IN  std_logic_vector(31 DOWNTO 0);
165)             i_signed: IN  std_logic;
166)             i_start:  IN  std_logic;
167)             o_busy:   OUT std_logic;
168)             o_res:    OUT std_logic_vector(63 DOWNTO 0)
169)         );
170)     END COMPONENT e_mips_mul;
171) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

172)     COMPONENT e_mips_div IS
173)         PORT (
174)             rst:      IN  std_logic;
175)             clk:      IN  std_logic;
176)             i_num:    IN  std_logic_vector(31 DOWNTO 0);
177)             i_denom:  IN  std_logic_vector(31 DOWNTO 0);
178)             i_signed: IN  std_logic;
179)             i_start:  IN  std_logic;
180)             o_busy:   OUT std_logic;
181)             o_res:    OUT std_logic_vector(31 DOWNTO 0);
182)             o_rem:    OUT std_logic_vector(31 DOWNTO 0)
183)         );
184)     END COMPONENT e_mips_div;
185) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

186) BEGIN
187) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

188)     s_stall <= i_stall OR s_stall_data_rd OR s_mul_busy OR s_div_busy;
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

190)     decoder: e_mips_decoder
191)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

192)             i_instr  => s_instr,
193)             o_reg_s  => n_reg_s,
194)             o_reg_t  => n_reg_t,
195)             o_reg_d  => n_reg_d,
196)             o_imm_a  => n_imm_a,
197)             o_imm_16 => n_imm_16,
198)             o_imm_26 => n_imm_26,
199)             o_op     => n_op,
200)             o_link   => n_link,
201)             o_cmp    => n_cmp,
202)             o_alu    => n_alu,
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

205)         );
206) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

207)     regs: e_mips_regs
208)         PORT MAP (
209)             rst         => rst,
210)             clk         => clk,
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

214)             o_rd_b_data => s_val_t,
215)             i_wr_no     => s_reg_wr_no,
216)             i_wr_data   => s_reg_wr_data,
217)             i_wr_en     => s_reg_wr_en
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

219) 
220)     alu: e_mips_alu
221)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

223)             i_op1 => s_alu_op1,
224)             i_op2 => s_alu_op2,
225)             o_res => s_alu_res
226)         );
227) 
228)     cmp: e_mips_cmp
229)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

231)             i_op1 => s_cmp_op1,
232)             i_op2 => s_cmp_op2,
233)             o_res => s_cmp_res
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

234)         );
235) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

236)     mul: e_mips_mul
237)         PORT MAP (
238)             rst      => rst,
239)             clk      => clk,
240)             i_a      => s_val_s,
241)             i_b      => s_val_t,
242)             i_signed => s_mul_signed,
243)             i_start  => s_mul_start,
244)             o_busy   => s_mul_busy,
245)             o_res    => s_mul_res
246)         );
247) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

248)     div: e_mips_div
249)         PORT MAP (
250)             rst      => rst,
251)             clk      => clk,
252)             i_num    => s_val_s,
253)             i_denom  => s_val_t,
254)             i_signed => s_div_signed,
255)             i_start  => s_div_start,
256)             o_busy   => s_div_busy,
257)             o_res    => s_div_res,
258)             o_rem    => s_div_rem
259)         );
260) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

261)     p_sync_pc: PROCESS(rst, clk)
262)     BEGIN
263)         IF rst = '1' THEN
Stefan Schuermans start with PC 0

Stefan Schuermans authored 12 years ago

264)             r_pc <= X"FFFFFFFC";
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

266)             IF s_stall = '0' THEN
267)                 r_pc <= n_pc;
268)             END IF;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

269)         END IF;
270)     END PROCESS p_sync_pc;
271) 
272)     p_fetch: PROCESS(n_pc, i_instr_data)
273)     BEGIN
274)         o_instr_addr <= n_pc;
275)         s_instr      <= i_instr_data;
276)     END PROCESS p_fetch;
277) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

281)             r_reg_s  <= (OTHERS => '0');
282)             r_reg_t  <= (OTHERS => '0');
283)             r_reg_d  <= (OTHERS => '0');
284)             r_imm_a  <= (OTHERS => '0');
285)             r_imm_16 <= (OTHERS => '0');
286)             r_imm_26 <= (OTHERS => '0');
287)             r_op     <= op_none;
288)             r_link   <= link_none;
289)             r_cmp    <= cmp_none;
290)             r_alu    <= alu_none;
291)             r_imm    <= imm_none;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

294)             IF s_stall = '0' THEN
295)                 r_reg_s  <= n_reg_s;
296)                 r_reg_t  <= n_reg_t;
297)                 r_reg_d  <= n_reg_d;
298)                 r_imm_a  <= n_imm_a;
299)                 r_imm_16 <= n_imm_16;
300)                 r_imm_26 <= n_imm_26;
301)                 r_op     <= n_op;
302)                 r_link   <= n_link;
303)                 r_cmp    <= n_cmp;
304)                 r_alu    <= n_alu;
305)                 r_imm    <= n_imm;
306)                 r_ldst   <= n_ldst;
307)             END IF;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

311)     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

312)     BEGIN
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

315)         IF r_op = op_alu THEN
316)             CASE r_imm IS
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

318)                     s_alu_op1 <= s_val_s;
319)                     s_alu_op2 <= s_val_t;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

330)                 WHEN OTHERS => NULL;
331)             END CASE;
332)         END IF;
333)     END PROCESS p_alu_in;
334) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

335)     p_alu_out: PROCESS(r_op, r_imm, r_reg_t, r_reg_d, s_alu_res)
336)     BEGIN
337)         s_reg_wr_alu_no   <= (OTHERS => '0');
338)         s_reg_wr_alu_data <= (OTHERS => '0');
339)         s_reg_wr_alu_en   <= '0';
340)         IF r_op = op_alu THEN
341)             CASE r_imm IS
342)                 WHEN imm_none | imm_a =>
343)                     s_reg_wr_alu_no   <= r_reg_d;
344)                     s_reg_wr_alu_data <= s_alu_res;
345)                     s_reg_wr_alu_en   <= '1';
346)                 WHEN imm_16se | imm_16ze =>
347)                     s_reg_wr_alu_no   <= r_reg_t;
348)                     s_reg_wr_alu_data <= s_alu_res;
349)                     s_reg_wr_alu_en   <= '1';
350)                 WHEN OTHERS => NULL;
351)             END CASE;
352)         END IF;
353)     END PROCESS p_alu_out;
354) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

355)     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

356)     BEGIN
357)         s_cmp_op1 <= (OTHERS => '0');
358)         s_cmp_op2 <= (OTHERS => '0');
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

360)             s_cmp_op1 <= s_val_s;
361)             s_cmp_op2 <= s_val_t;
362)         END IF;
363)     END PROCESS p_cmp_in;
364) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

365)     p_reg_wr: PROCESS(s_stall,
366)                       s_reg_wr_alu_no, s_reg_wr_alu_data, s_reg_wr_alu_en,
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

367)                       s_reg_wr_data_no, s_reg_wr_data_data, s_reg_wr_data_en,
Stefan Schuermans implemented ... and link ->...

Stefan Schuermans authored 12 years ago

368)                       s_reg_wr_hi_lo_no, s_reg_wr_hi_lo_data, s_reg_wr_hi_lo_en,
369)                       s_reg_wr_link_no, s_reg_wr_link_data, s_reg_wr_link_en)
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

370)     BEGIN
371)         s_reg_wr_no   <= (OTHERS => '0');
372)         s_reg_wr_data <= (OTHERS => '0');
373)         s_reg_wr_en   <= '0';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

374)         IF s_stall = '0' THEN
375)             IF s_reg_wr_alu_en = '1' THEN
376)                 s_reg_wr_no   <= s_reg_wr_alu_no;
377)                 s_reg_wr_data <= s_reg_wr_alu_data;
378)                 s_reg_wr_en   <= '1';
379)             ELSIF s_reg_wr_data_en = '1' THEN
380)                 s_reg_wr_no   <= s_reg_wr_data_no;
381)                 s_reg_wr_data <= s_reg_wr_data_data;
382)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

383)             ELSIF s_reg_wr_hi_lo_en = '1' THEN
384)                 s_reg_wr_no   <= s_reg_wr_hi_lo_no;
385)                 s_reg_wr_data <= s_reg_wr_hi_lo_data;
386)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented ... and link ->...

Stefan Schuermans authored 12 years ago

387)             ELSIF s_reg_wr_link_en = '1' THEN
388)                 s_reg_wr_no   <= s_reg_wr_link_no;
389)                 s_reg_wr_data <= s_reg_wr_link_data;
390)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

391)             END IF;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

392)         END IF;
393)     END PROCESS p_reg_wr;
394) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

395)     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

396)         VARIABLE v_pc:  signed(31 DOWNTO 0);
397)         VARIABLE v_rel: signed(17 DOWNTO 0);
398)     BEGIN
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

399)         IF r_op = op_j AND s_cmp_res = '1' THEN
400)             IF r_imm = imm_26 THEN
401)                 n_pc <= r_pc(31 DOWNTO 28) & r_imm_26 & "00";
402)             ELSE
403)                 n_pc <= std_logic_vector(signed(r_pc) +
404)                                          signed(r_imm_16 & "00"));
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

406)         ELSE
407)             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

408)         END IF;
409)     END PROCESS p_next_pc;
410) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

411)     p_data_addr: PROCESS(r_op, s_val_s, r_imm_16)
412)         VARIABLE v_ofs: signed(31 DOWNTO 0);
413)         VARIABLE v_addr: signed(31 DOWNTO 0);
414)     BEGIN
415)         s_data_addr <= (OTHERS => '0');
416)         IF r_op = op_l OR r_op = op_s THEN
417)             v_ofs(15 DOWNTO 0)  := signed(r_imm_16);
418)             v_ofs(31 DOWNTO 16) := (OTHERS => r_imm_16(15));
419)             v_addr              := signed(s_val_s) + v_ofs;
420)             s_data_addr         <= std_logic_vector(v_addr);
421)         END IF;
422)     END PROCESS p_data_addr;
423) 
424)     o_data_addr <= s_data_addr(31 DOWNTO 2) & "00";
425) 
Stefan Schuermans implementation of LWL, LWR

Stefan Schuermans authored 12 years ago

426)     p_data_rd: PROCESS(r_data_rd, r_op, r_ldst, s_data_addr, r_reg_t, i_data_rd_data, s_val_t)
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

427)         VARIABLE v_b: std_logic_vector( 7 DOWNTO 0);
428)         VARIABLE v_h: std_logic_vector(15 DOWNTO 0);
Stefan Schuermans implementation of LWL, LWR

Stefan Schuermans authored 12 years ago

429)         VARIABLE v_w: std_logic_vector(31 DOWNTO 0);
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

430)     BEGIN
431)         s_stall_data_rd    <= '0';
432)         n_data_rd          <= data_rd_idle;
433)         s_reg_wr_data_no   <= (OTHERS => '0');
434)         s_reg_wr_data_data <= (OTHERS => '0');
435)         s_reg_wr_data_en   <= '0';
436)         CASE r_data_rd IS
437)             WHEN data_rd_idle =>
438)                 IF r_op = op_l THEN
439)                     s_stall_data_rd <= '1';
440)                     n_data_rd <= data_rd_read;
441)                 END IF;
442)             WHEN data_rd_read =>
443)                 CASE r_ldst IS
444)                     WHEN ldst_b | ldst_bu =>
445)                         CASE s_data_addr(1 DOWNTO 0) IS
446)                             WHEN "00" => v_b := i_data_rd_data( 7 DOWNTO  0);
447)                             WHEN "01" => v_b := i_data_rd_data(15 DOWNTO  8);
448)                             WHEN "10" => v_b := i_data_rd_data(23 DOWNTO 16);
449)                             WHEN "11" => v_b := i_data_rd_data(31 DOWNTO 24);
450)                             WHEN OTHERS => NULL;
451)                         END CASE;
452)                         s_reg_wr_data_data(7 DOWNTO 0) <= v_b;
453)                         IF r_ldst = ldst_b THEN
454)                             s_reg_wr_data_data(31 DOWNTO 8) <= (OTHERS => v_b(7));
455)                         END IF;
456)                     WHEN ldst_h | ldst_hu =>
457)                         CASE s_data_addr(1 DOWNTO 1) IS
458)                             WHEN "0" => v_h := i_data_rd_data(15 DOWNTO  0);
459)                             WHEN "1" => v_h := i_data_rd_data(31 DOWNTO 16);
460)                             WHEN OTHERS => NULL;
461)                         END CASE;
462)                         s_reg_wr_data_data(15 DOWNTO 0) <= v_h;
463)                         IF r_ldst = ldst_h THEN
464)                             s_reg_wr_data_data(31 DOWNTO 16) <= (OTHERS => v_h(15));
465)                         END IF;
466)                     WHEN ldst_w =>
467)                         s_reg_wr_data_data <= i_data_rd_data;
Stefan Schuermans implementation of LWL, LWR

Stefan Schuermans authored 12 years ago

468)                     WHEN ldst_wl =>
469)                         v_w := s_val_t;
470)                         CASE s_data_addr(1 DOWNTO 0) IS
471)                             WHEN "00" => v_w(31 DOWNTO 24) := i_data_rd_data( 7 DOWNTO 0);
472)                             WHEN "01" => v_w(31 DOWNTO 16) := i_data_rd_data(15 DOWNTO 0);
473)                             WHEN "10" => v_w(31 DOWNTO  8) := i_data_rd_data(23 DOWNTO 0);
474)                             WHEN "11" => v_w(31 DOWNTO  0) := i_data_rd_data(31 DOWNTO 0);
475)                             WHEN OTHERS => NULL;
476)                         END CASE;
477)                         s_reg_wr_data_data <= v_w;
478)                     WHEN ldst_wr =>
479)                         v_w := s_val_t;
480)                         CASE s_data_addr(1 DOWNTO 0) IS
481)                             WHEN "00" => v_w(31 DOWNTO  0) := i_data_rd_data(31 DOWNTO  0);
482)                             WHEN "01" => v_w(23 DOWNTO  0) := i_data_rd_data(31 DOWNTO  8);
483)                             WHEN "10" => v_w(15 DOWNTO  0) := i_data_rd_data(31 DOWNTO 16);
484)                             WHEN "11" => v_w( 7 DOWNTO  0) := i_data_rd_data(31 DOWNTO 24);
485)                             WHEN OTHERS => NULL;
486)                         END CASE;
487)                         s_reg_wr_data_data <= v_w;
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

488)                     WHEN OTHERS => NULL;
489)                 END CASE;
490)                 s_reg_wr_data_no <= r_reg_t;
491)                 s_reg_wr_data_en <= '1';
492)             WHEN OTHERS => NULL;
493)         END CASE;
494)     END PROCESS p_data_rd;
495) 
496)     p_sync_data_rd: PROCESS(rst, clk)
497)     BEGIN
498)         IF rst = '1' THEN
499)             r_data_rd <= data_rd_idle;
500)         ELSIF rising_edge(clk) THEN
501)             IF i_stall = '0' THEN
502)                 r_data_rd <= n_data_rd;
503)             END IF;
504)         END IF;
505)     END PROCESS p_sync_data_rd;
506) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

507)     p_data_wr: PROCESS(r_op, r_ldst, s_data_addr, s_val_t)
508)     BEGIN
509)         o_data_wr_data <= (OTHERS => '0');
510)         o_data_wr_en   <= "0000";
511)         IF r_op = op_s THEN
512)             CASE r_ldst IS
513)                 WHEN ldst_b =>
514)                     CASE s_data_addr(1 DOWNTO 0) IS
515)                         WHEN "00" =>
516)                             o_data_wr_data( 7 DOWNTO  0) <= s_val_t(7 DOWNTO 0);
517)                             o_data_wr_en                 <= "0001";
518)                         WHEN "01" =>
519)                             o_data_wr_data(15 DOWNTO  8) <= s_val_t(7 DOWNTO 0);
520)                             o_data_wr_en                 <= "0010";
521)                         WHEN "10" =>
522)                             o_data_wr_data(23 DOWNTO 16) <= s_val_t(7 DOWNTO 0);
523)                             o_data_wr_en                 <= "0100";
524)                         WHEN "11" =>
525)                             o_data_wr_data(31 DOWNTO 24) <= s_val_t(7 DOWNTO 0);
526)                             o_data_wr_en                 <= "1000";
527)                         WHEN OTHERS => NULL;
528)                     END CASE;
529)                 WHEN ldst_h =>
530)                     CASE s_data_addr(1 DOWNTO 1) IS
531)                         WHEN "0" =>
532)                             o_data_wr_data(15 DOWNTO  0) <= s_val_t(15 DOWNTO 0);
533)                             o_data_wr_en                 <= "0011";
534)                         WHEN "1" =>
535)                             o_data_wr_data(31 DOWNTO 16) <= s_val_t(15 DOWNTO 0);
536)                             o_data_wr_en                 <= "1100";
537)                         WHEN OTHERS => NULL;
538)                     END CASE;
539)                 WHEN ldst_w =>
540)                     o_data_wr_data <= s_val_t;
541)                     o_data_wr_en   <= "1111";
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

542)                 WHEN ldst_wl =>
543)                     CASE s_data_addr(1 DOWNTO 0) IS
544)                         WHEN "00" =>
545)                             o_data_wr_data( 7 DOWNTO 0) <= s_val_t(31 DOWNTO 24);
546)                             o_data_wr_en                <= "0001";
547)                         WHEN "01" =>
548)                             o_data_wr_data(15 DOWNTO 0) <= s_val_t(31 DOWNTO 16);
549)                             o_data_wr_en                <= "0011";
550)                         WHEN "10" =>
551)                             o_data_wr_data(23 DOWNTO 0) <= s_val_t(31 DOWNTO  8);
552)                             o_data_wr_en                <= "0111";
553)                         WHEN "11" =>
554)                             o_data_wr_data(31 DOWNTO 0) <= s_val_t(31 DOWNTO  0);
555)                             o_data_wr_en                <= "1111";
556)                         WHEN OTHERS => NULL;
557)                     END CASE;
558)                 WHEN ldst_wr =>
559)                     CASE s_data_addr(1 DOWNTO 0) IS
560)                         WHEN "00" =>
561)                             o_data_wr_data(31 DOWNTO  0) <= s_val_t(31 DOWNTO 0);
562)                             o_data_wr_en                 <= "1111";
563)                         WHEN "01" =>
564)                             o_data_wr_data(31 DOWNTO  8) <= s_val_t(23 DOWNTO 0);
565)                             o_data_wr_en                 <= "1110";
566)                         WHEN "10" =>
567)                             o_data_wr_data(31 DOWNTO 16) <= s_val_t(15 DOWNTO 0);
568)                             o_data_wr_en                 <= "1100";
569)                         WHEN "11" =>
570)                             o_data_wr_data(31 DOWNTO 24) <= s_val_t( 7 DOWNTO 0);
571)                             o_data_wr_en                 <= "1000";
572)                         WHEN OTHERS => NULL;
573)                     END CASE;
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

574)                 WHEN OTHERS => NULL;
575)             END CASE;
576)         END IF;
577)     END PROCESS p_data_wr;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

578) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

579)     p_reg_hi_lo: PROCESS(r_reg_lo, r_reg_hi, r_op, r_reg_d, s_val_s,
580)                          s_mul_res, s_div_res, s_div_rem)
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

581)     BEGIN
582)         n_reg_lo            <= r_reg_lo;
583)         n_reg_hi            <= r_reg_hi;
584)         s_reg_wr_hi_lo_no   <= (OTHERS => '0');
585)         s_reg_wr_hi_lo_data <= (OTHERS => '0');
586)         s_reg_wr_hi_lo_en   <= '0';
587)         CASE r_op IS
588)             WHEN op_mfhi =>
589)                 s_reg_wr_hi_lo_no   <= r_reg_d;
590)                 s_reg_wr_hi_lo_data <= r_reg_hi;
591)                 s_reg_wr_hi_lo_en   <= '1';            
592)             WHEN op_mflo =>
593)                 s_reg_wr_hi_lo_no   <= r_reg_d;
594)                 s_reg_wr_hi_lo_data <= r_reg_lo;
595)                 s_reg_wr_hi_lo_en   <= '1';            
596)             WHEN op_mthi =>
597)                 n_reg_hi <= s_val_s;
598)             WHEN op_mtlo =>
599)                 n_reg_lo <= s_val_s;
Stefan Schuermans implemented multiplier

Stefan Schuermans authored 12 years ago

600)             WHEN op_mult | op_multu =>
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

601)                 n_reg_lo <= std_logic_vector(s_mul_res(31 DOWNTO  0));
602)                 n_reg_hi <= std_logic_vector(s_mul_res(63 DOWNTO 32));
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

603)             WHEN op_div | op_divu =>
604)                 n_reg_lo <= s_div_res;
605)                 n_reg_hi <= s_div_rem;
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

606)             WHEN OTHERS => NULL;
607)         END CASE;
608)     END PROCESS p_reg_hi_lo;
609) 
610)     p_sync_reg_hi_lo: PROCESS(clk, rst)
611)     BEGIN
612)         IF rst = '1' THEN
613)             r_reg_lo <= (OTHERS => '0');
614)             r_reg_hi <= (OTHERS => '0');
615)         ELSIF rising_edge(clk) THEN
616)             IF s_stall = '0' THEN
617)                 r_reg_lo <= n_reg_lo;
618)                 r_reg_hi <= n_reg_hi;
619)             END IF;
620)         END IF;
621)     END PROCESS p_sync_reg_hi_lo;
622) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

623)     s_mul_signed <= '1' WHEN r_op = op_mult ELSE '0';
624)     s_mul_start  <= '1' WHEN i_stall = '0' AND (r_op = op_mult OR r_op = op_multu) ELSE '0';
Stefan Schuermans implemented multiplier

Stefan Schuermans authored 12 years ago

625) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

626)     s_div_signed <= '1' WHEN r_op = op_div ELSE '0';
627)     s_div_start  <= '1' WHEN i_stall = '0' AND (r_op = op_div OR r_op = op_divu) ELSE '0';
628) 
Stefan Schuermans implemented ... and link ->...

Stefan Schuermans authored 12 years ago

629)     p_link: PROCESS(r_pc, r_link)
630)     BEGIN
631)         s_reg_wr_link_no   <= std_logic_vector(to_unsigned(31, 5));
632)         s_reg_wr_link_data <= std_logic_vector(signed(r_pc) + to_signed(4, 32));
633)         IF r_link = link_link THEN
634)             s_reg_wr_link_en <= '1';
635)         ELSE
636)             s_reg_wr_link_en <= '0';
637)         END IF;
638)     END PROCESS p_link;
639)