6de2817c80725b20f67d16405a5bc9929438d30a
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 implement correctly writing...

Stefan Schuermans authored 12 years ago

79)     SIGNAL s_reg_wr_no:   std_logic_vector( 4 DOWNTO 0);
80)     SIGNAL s_reg_wr_data: std_logic_vector(31 DOWNTO 0);
81)     SIGNAL s_reg_wr_en:   std_logic;
82) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

83)     SIGNAL s_data_addr: std_logic_vector(31 DOWNTO 0);
84) 
85)     TYPE t_data_rd IS (data_rd_idle, data_rd_read);
86)     SIGNAL n_data_rd: t_data_rd;
Stefan Schuermans implemented multiplier

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

89)     SIGNAL n_reg_lo: std_logic_vector(31 DOWNTO 0);
90)     SIGNAL n_reg_hi: std_logic_vector(31 DOWNTO 0);
91)     SIGNAL r_reg_lo: std_logic_vector(31 DOWNTO 0);
92)     SIGNAL r_reg_hi: std_logic_vector(31 DOWNTO 0);
93) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

94)     SIGNAL s_mul_signed: std_logic;
95)     SIGNAL s_mul_start:  std_logic;
96)     SIGNAL s_mul_busy:   std_logic;
97)     SIGNAL s_mul_res:    std_logic_vector(63 DOWNTO 0);
Stefan Schuermans implemented multiplier

Stefan Schuermans authored 12 years ago

98) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

99)     SIGNAL s_div_signed: std_logic;
100)     SIGNAL s_div_start:  std_logic;
101)     SIGNAL s_div_busy:   std_logic;
102)     SIGNAL s_div_res:    std_logic_vector(31 DOWNTO 0);
103)     SIGNAL s_div_rem:    std_logic_vector(31 DOWNTO 0);
104) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

108)             o_reg_s:  OUT std_logic_vector( 4 DOWNTO 0);
109)             o_reg_t:  OUT std_logic_vector( 4 DOWNTO 0);
110)             o_reg_d:  OUT std_logic_vector( 4 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

120)         );
121)     END COMPONENT e_mips_decoder;
122) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

182) BEGIN
183) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

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

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

Stefan Schuermans authored 12 years ago

186)     decoder: e_mips_decoder
187)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

201)         );
202) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

203)     regs: e_mips_regs
204)         PORT MAP (
205)             rst         => rst,
206)             clk         => clk,
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

210)             o_rd_b_data => s_val_t,
211)             i_wr_no     => s_reg_wr_no,
212)             i_wr_data   => s_reg_wr_data,
213)             i_wr_en     => s_reg_wr_en
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

215) 
216)     alu: e_mips_alu
217)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

219)             i_op1 => s_alu_op1,
220)             i_op2 => s_alu_op2,
221)             o_res => s_alu_res
222)         );
223) 
224)     cmp: e_mips_cmp
225)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

227)             i_op1 => s_cmp_op1,
228)             i_op2 => s_cmp_op2,
229)             o_res => s_cmp_res
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

230)         );
231) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

257)     p_sync_pc: PROCESS(rst, clk)
258)     BEGIN
259)         IF rst = '1' THEN
260)             r_pc <= (OTHERS => '0');
261)         ELSIF rising_edge(clk) THEN
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

262)             IF s_stall = '0' THEN
263)                 r_pc <= n_pc;
264)             END IF;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

265)         END IF;
266)     END PROCESS p_sync_pc;
267) 
268)     p_fetch: PROCESS(n_pc, i_instr_data)
269)     BEGIN
270)         o_instr_addr <= n_pc;
271)         s_instr      <= i_instr_data;
272)     END PROCESS p_fetch;
273) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

308)     BEGIN
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

311)         IF r_op = op_alu THEN
312)             CASE r_imm IS
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

314)                     s_alu_op1 <= s_val_s;
315)                     s_alu_op2 <= s_val_t;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

323)                 WHEN imm_16ze =>
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 implement correctly writing...

Stefan Schuermans authored 12 years ago

326)                 WHEN OTHERS => NULL;
327)             END CASE;
328)         END IF;
329)     END PROCESS p_alu_in;
330) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

352)     BEGIN
353)         s_cmp_op1 <= (OTHERS => '0');
354)         s_cmp_op2 <= (OTHERS => '0');
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

356)             s_cmp_op1 <= s_val_s;
357)             s_cmp_op2 <= s_val_t;
358)         END IF;
359)     END PROCESS p_cmp_in;
360) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

361)     p_reg_wr: PROCESS(s_stall,
362)                       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

363)                       s_reg_wr_data_no, s_reg_wr_data_data, s_reg_wr_data_en,
364)                       s_reg_wr_hi_lo_no, s_reg_wr_hi_lo_data, s_reg_wr_hi_lo_en)
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

365)     BEGIN
366)         s_reg_wr_no   <= (OTHERS => '0');
367)         s_reg_wr_data <= (OTHERS => '0');
368)         s_reg_wr_en   <= '0';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

369)         IF s_stall = '0' THEN
370)             IF s_reg_wr_alu_en = '1' THEN
371)                 s_reg_wr_no   <= s_reg_wr_alu_no;
372)                 s_reg_wr_data <= s_reg_wr_alu_data;
373)                 s_reg_wr_en   <= '1';
374)             ELSIF s_reg_wr_data_en = '1' THEN
375)                 s_reg_wr_no   <= s_reg_wr_data_no;
376)                 s_reg_wr_data <= s_reg_wr_data_data;
377)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

378)             ELSIF s_reg_wr_hi_lo_en = '1' THEN
379)                 s_reg_wr_no   <= s_reg_wr_hi_lo_no;
380)                 s_reg_wr_data <= s_reg_wr_hi_lo_data;
381)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

383)         END IF;
384)     END PROCESS p_reg_wr;
385) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

387)         VARIABLE v_pc:  signed(31 DOWNTO 0);
388)         VARIABLE v_rel: signed(17 DOWNTO 0);
389)     BEGIN
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

390)         IF r_op = op_j AND s_cmp_res = '1' THEN
391)             IF r_imm = imm_26 THEN
392)                 n_pc <= r_pc(31 DOWNTO 28) & r_imm_26 & "00";
393)             ELSE
394)                 n_pc <= std_logic_vector(signed(r_pc) +
395)                                          signed(r_imm_16 & "00"));
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

397)         ELSE
398)             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

399)         END IF;
400)     END PROCESS p_next_pc;
401) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

402)     p_data_addr: PROCESS(r_op, s_val_s, r_imm_16)
403)         VARIABLE v_ofs: signed(31 DOWNTO 0);
404)         VARIABLE v_addr: signed(31 DOWNTO 0);
405)     BEGIN
406)         s_data_addr <= (OTHERS => '0');
407)         IF r_op = op_l OR r_op = op_s THEN
408)             v_ofs(15 DOWNTO 0)  := signed(r_imm_16);
409)             v_ofs(31 DOWNTO 16) := (OTHERS => r_imm_16(15));
410)             v_addr              := signed(s_val_s) + v_ofs;
411)             s_data_addr         <= std_logic_vector(v_addr);
412)         END IF;
413)     END PROCESS p_data_addr;
414) 
415)     o_data_addr <= s_data_addr(31 DOWNTO 2) & "00";
416) 
Stefan Schuermans implementation of LWL, LWR

Stefan Schuermans authored 12 years ago

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

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

459)                     WHEN ldst_wl =>
460)                         v_w := s_val_t;
461)                         CASE s_data_addr(1 DOWNTO 0) IS
462)                             WHEN "00" => v_w(31 DOWNTO 24) := i_data_rd_data( 7 DOWNTO 0);
463)                             WHEN "01" => v_w(31 DOWNTO 16) := i_data_rd_data(15 DOWNTO 0);
464)                             WHEN "10" => v_w(31 DOWNTO  8) := i_data_rd_data(23 DOWNTO 0);
465)                             WHEN "11" => v_w(31 DOWNTO  0) := i_data_rd_data(31 DOWNTO 0);
466)                             WHEN OTHERS => NULL;
467)                         END CASE;
468)                         s_reg_wr_data_data <= v_w;
469)                     WHEN ldst_wr =>
470)                         v_w := s_val_t;
471)                         CASE s_data_addr(1 DOWNTO 0) IS
472)                             WHEN "00" => v_w(31 DOWNTO  0) := i_data_rd_data(31 DOWNTO  0);
473)                             WHEN "01" => v_w(23 DOWNTO  0) := i_data_rd_data(31 DOWNTO  8);
474)                             WHEN "10" => v_w(15 DOWNTO  0) := i_data_rd_data(31 DOWNTO 16);
475)                             WHEN "11" => v_w( 7 DOWNTO  0) := i_data_rd_data(31 DOWNTO 24);
476)                             WHEN OTHERS => NULL;
477)                         END CASE;
478)                         s_reg_wr_data_data <= v_w;
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

479)                     WHEN OTHERS => NULL;
480)                 END CASE;
481)                 s_reg_wr_data_no <= r_reg_t;
482)                 s_reg_wr_data_en <= '1';
483)             WHEN OTHERS => NULL;
484)         END CASE;
485)     END PROCESS p_data_rd;
486) 
487)     p_sync_data_rd: PROCESS(rst, clk)
488)     BEGIN
489)         IF rst = '1' THEN
490)             r_data_rd <= data_rd_idle;
491)         ELSIF rising_edge(clk) THEN
492)             IF i_stall = '0' THEN
493)                 r_data_rd <= n_data_rd;
494)             END IF;
495)         END IF;
496)     END PROCESS p_sync_data_rd;
497) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

533)                 WHEN ldst_wl =>
534)                     CASE s_data_addr(1 DOWNTO 0) IS
535)                         WHEN "00" =>
536)                             o_data_wr_data( 7 DOWNTO 0) <= s_val_t(31 DOWNTO 24);
537)                             o_data_wr_en                <= "0001";
538)                         WHEN "01" =>
539)                             o_data_wr_data(15 DOWNTO 0) <= s_val_t(31 DOWNTO 16);
540)                             o_data_wr_en                <= "0011";
541)                         WHEN "10" =>
542)                             o_data_wr_data(23 DOWNTO 0) <= s_val_t(31 DOWNTO  8);
543)                             o_data_wr_en                <= "0111";
544)                         WHEN "11" =>
545)                             o_data_wr_data(31 DOWNTO 0) <= s_val_t(31 DOWNTO  0);
546)                             o_data_wr_en                <= "1111";
547)                         WHEN OTHERS => NULL;
548)                     END CASE;
549)                 WHEN ldst_wr =>
550)                     CASE s_data_addr(1 DOWNTO 0) IS
551)                         WHEN "00" =>
552)                             o_data_wr_data(31 DOWNTO  0) <= s_val_t(31 DOWNTO 0);
553)                             o_data_wr_en                 <= "1111";
554)                         WHEN "01" =>
555)                             o_data_wr_data(31 DOWNTO  8) <= s_val_t(23 DOWNTO 0);
556)                             o_data_wr_en                 <= "1110";
557)                         WHEN "10" =>
558)                             o_data_wr_data(31 DOWNTO 16) <= s_val_t(15 DOWNTO 0);
559)                             o_data_wr_en                 <= "1100";
560)                         WHEN "11" =>
561)                             o_data_wr_data(31 DOWNTO 24) <= s_val_t( 7 DOWNTO 0);
562)                             o_data_wr_en                 <= "1000";
563)                         WHEN OTHERS => NULL;
564)                     END CASE;
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

565)                 WHEN OTHERS => NULL;
566)             END CASE;
567)         END IF;
568)     END PROCESS p_data_wr;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

569) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

572)     BEGIN
573)         n_reg_lo            <= r_reg_lo;
574)         n_reg_hi            <= r_reg_hi;
575)         s_reg_wr_hi_lo_no   <= (OTHERS => '0');
576)         s_reg_wr_hi_lo_data <= (OTHERS => '0');
577)         s_reg_wr_hi_lo_en   <= '0';
578)         CASE r_op IS
579)             WHEN op_mfhi =>
580)                 s_reg_wr_hi_lo_no   <= r_reg_d;
581)                 s_reg_wr_hi_lo_data <= r_reg_hi;
582)                 s_reg_wr_hi_lo_en   <= '1';            
583)             WHEN op_mflo =>
584)                 s_reg_wr_hi_lo_no   <= r_reg_d;
585)                 s_reg_wr_hi_lo_data <= r_reg_lo;
586)                 s_reg_wr_hi_lo_en   <= '1';            
587)             WHEN op_mthi =>
588)                 n_reg_hi <= s_val_s;
589)             WHEN op_mtlo =>
590)                 n_reg_lo <= s_val_s;
Stefan Schuermans implemented multiplier

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

594)             WHEN op_div | op_divu =>
595)                 n_reg_lo <= s_div_res;
596)                 n_reg_hi <= s_div_rem;
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

597)             WHEN OTHERS => NULL;
598)         END CASE;
599)     END PROCESS p_reg_hi_lo;
600) 
601)     p_sync_reg_hi_lo: PROCESS(clk, rst)
602)     BEGIN
603)         IF rst = '1' THEN
604)             r_reg_lo <= (OTHERS => '0');
605)             r_reg_hi <= (OTHERS => '0');
606)         ELSIF rising_edge(clk) THEN
607)             IF s_stall = '0' THEN
608)                 r_reg_lo <= n_reg_lo;
609)                 r_reg_hi <= n_reg_hi;
610)             END IF;
611)         END IF;
612)     END PROCESS p_sync_reg_hi_lo;
613) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

614)     s_mul_signed <= '1' WHEN r_op = op_mult ELSE '0';
615)     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

616) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

617)     s_div_signed <= '1' WHEN r_op = op_div ELSE '0';
618)     s_div_start  <= '1' WHEN i_stall = '0' AND (r_op = op_div OR r_op = op_divu) ELSE '0';
619)