ea1aa509f28467649b54a1116e0e639e9b77fe73
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 add initial values for regi...

Stefan Schuermans authored 12 years ago

25)     SIGNAL r_pc: std_logic_vector(31 DOWNTO 0) := X"FFFFFFFC";
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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) 
Stefan Schuermans add initial values for regi...

Stefan Schuermans authored 12 years ago

43)     SIGNAL r_reg_s:  std_logic_vector( 4 DOWNTO 0) := (OTHERS => '0');
44)     SIGNAL r_reg_t:  std_logic_vector( 4 DOWNTO 0) := (OTHERS => '0');
45)     SIGNAL r_reg_d:  std_logic_vector( 4 DOWNTO 0) := (OTHERS => '0');
46)     SIGNAL r_imm_a:  std_logic_vector( 4 DOWNTO 0) := (OTHERS => '0');
47)     SIGNAL r_imm_16: std_logic_vector(15 DOWNTO 0) := (OTHERS => '0');
48)     SIGNAL r_imm_26: std_logic_vector(25 DOWNTO 0) := (OTHERS => '0');
49)     SIGNAL r_op:     t_op                          := op_none;
50)     SIGNAL r_link:   t_link                        := link_none;
51)     SIGNAL r_cmp:    t_cmp                         := cmp_none;
52)     SIGNAL r_alu:    t_alu                         := alu_none;
53)     SIGNAL r_imm:    t_imm                         := imm_none;
54)     SIGNAL r_ldst:   t_ldst                        := ldst_none;
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 add initial values for regi...

Stefan Schuermans authored 12 years ago

91)     SIGNAL r_data_rd: t_data_rd := data_rd_idle;
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);
Stefan Schuermans add initial values for regi...

Stefan Schuermans authored 12 years ago

95)     SIGNAL r_reg_lo: std_logic_vector(31 DOWNTO 0) := (OTHERS => '0');
96)     SIGNAL r_reg_hi: std_logic_vector(31 DOWNTO 0) := (OTHERS => '0');
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

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)             clk:         IN  std_logic;
130)             i_rd_a_no:   IN  std_logic_vector( 4 DOWNTO 0);
131)             o_rd_a_data: OUT std_logic_vector(31 DOWNTO 0);
132)             i_rd_b_no:   IN  std_logic_vector( 4 DOWNTO 0);
133)             o_rd_b_data: OUT std_logic_vector(31 DOWNTO 0);
134)             i_wr_no:     IN  std_logic_vector( 4 DOWNTO 0);
135)             i_wr_data:   IN  std_logic_vector(31 DOWNTO 0);
136)             i_wr_en:     IN  std_logic
137)         );
138)     END COMPONENT e_mips_regs;
139) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

185) BEGIN
186) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

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

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

204)         );
205) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

232)         );
233) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

267)         END IF;
268)     END PROCESS p_sync_pc;
269) 
Stefan Schuermans fixed instruction fetch dur...

Stefan Schuermans authored 12 years ago

270)     p_fetch: PROCESS(s_stall, r_pc, n_pc, i_instr_data)
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

271)     BEGIN
Stefan Schuermans fixed instruction fetch dur...

Stefan Schuermans authored 12 years ago

272)         IF s_stall = '1' THEN
273)             o_instr_addr <= r_pc;
274)         ELSE
275)             o_instr_addr <= n_pc;
276)         END IF;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

277)         s_instr      <= i_instr_data;
278)     END PROCESS p_fetch;
279) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

314)     BEGIN
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

317)         IF r_op = op_alu THEN
318)             CASE r_imm IS
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

320)                     s_alu_op1 <= s_val_s;
321)                     s_alu_op2 <= s_val_t;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

367)     p_reg_wr: PROCESS(s_stall,
368)                       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

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

370)                       s_reg_wr_hi_lo_no, s_reg_wr_hi_lo_data, s_reg_wr_hi_lo_en,
371)                       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

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

394)         END IF;
395)     END PROCESS p_reg_wr;
396) 
Stefan Schuermans implemented jump register i...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

401)         IF r_op = op_j AND s_cmp_res = '1' THEN
402)             IF r_imm = imm_26 THEN
403)                 n_pc <= r_pc(31 DOWNTO 28) & r_imm_26 & "00";
Stefan Schuermans implemented jump register i...

Stefan Schuermans authored 12 years ago

404)             ELSIF r_imm = imm_16se THEN
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

405)                 n_pc <= std_logic_vector(signed(r_pc) +
406)                                          signed(r_imm_16 & "00"));
Stefan Schuermans implemented jump register i...

Stefan Schuermans authored 12 years ago

407)             ELSE
408)                 n_pc <= s_val_s;
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

410)         ELSE
411)             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

412)         END IF;
413)     END PROCESS p_next_pc;
414) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

578)                 WHEN OTHERS => NULL;
579)             END CASE;
580)         END IF;
581)     END PROCESS p_data_wr;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

582) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

607)             WHEN op_div | op_divu =>
608)                 n_reg_lo <= s_div_res;
609)                 n_reg_hi <= s_div_rem;
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

629) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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