99b823b5a819c8fdf13eeed8f5ac8a01a185b7dc
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;
Stefan Schuermans fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

23)     SIGNAL r_stall_reset:   std_logic := '1';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

24)     SIGNAL s_stall_data_rd: std_logic;
25) 
Stefan Schuermans fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

26)     SIGNAL r_pc:         std_logic_vector(31 DOWNTO 0) := X"FFFFFFFC";
27)     SIGNAL n_pc:         std_logic_vector(31 DOWNTO 0);
28)     SIGNAL r_instr_data: std_logic_vector(31 DOWNTO 0) := X"00000000";
29)     SIGNAL s_instr:      std_logic_vector(31 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

43) 
Stefan Schuermans add initial values for regi...

Stefan Schuermans authored 12 years ago

44)     SIGNAL r_reg_s:  std_logic_vector( 4 DOWNTO 0) := (OTHERS => '0');
45)     SIGNAL r_reg_t:  std_logic_vector( 4 DOWNTO 0) := (OTHERS => '0');
46)     SIGNAL r_reg_d:  std_logic_vector( 4 DOWNTO 0) := (OTHERS => '0');
47)     SIGNAL r_imm_a:  std_logic_vector( 4 DOWNTO 0) := (OTHERS => '0');
48)     SIGNAL r_imm_16: std_logic_vector(15 DOWNTO 0) := (OTHERS => '0');
49)     SIGNAL r_imm_26: std_logic_vector(25 DOWNTO 0) := (OTHERS => '0');
50)     SIGNAL r_op:     t_op                          := op_none;
51)     SIGNAL r_link:   t_link                        := link_none;
52)     SIGNAL r_cmp:    t_cmp                         := cmp_none;
53)     SIGNAL r_alu:    t_alu                         := alu_none;
54)     SIGNAL r_imm:    t_imm                         := imm_none;
55)     SIGNAL r_ldst:   t_ldst                        := ldst_none;
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

56) 
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

59) 
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

67) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

68)     SIGNAL s_reg_wr_alu_no:   std_logic_vector( 4 DOWNTO 0);
69)     SIGNAL s_reg_wr_alu_data: std_logic_vector(31 DOWNTO 0);
70)     SIGNAL s_reg_wr_alu_en:   std_logic;
71) 
72)     SIGNAL s_reg_wr_data_no:   std_logic_vector( 4 DOWNTO 0);
73)     SIGNAL s_reg_wr_data_data: std_logic_vector(31 DOWNTO 0);
74)     SIGNAL s_reg_wr_data_en:   std_logic;
75) 
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

88)     SIGNAL s_data_addr: std_logic_vector(31 DOWNTO 0);
89) 
90)     TYPE t_data_rd IS (data_rd_idle, data_rd_read);
91)     SIGNAL n_data_rd: t_data_rd;
Stefan Schuermans add initial values for regi...

Stefan Schuermans authored 12 years ago

92)     SIGNAL r_data_rd: t_data_rd := data_rd_idle;
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

94)     SIGNAL n_reg_lo: std_logic_vector(31 DOWNTO 0);
95)     SIGNAL n_reg_hi: std_logic_vector(31 DOWNTO 0);
Stefan Schuermans add initial values for regi...

Stefan Schuermans authored 12 years ago

96)     SIGNAL r_reg_lo: std_logic_vector(31 DOWNTO 0) := (OTHERS => '0');
97)     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

98) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

103) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

128)     COMPONENT e_mips_regs IS
129)         PORT (
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 fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

188)     s_stall <= i_stall OR r_stall_reset 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)             clk         => clk,
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

260)     p_sync_pc: PROCESS(rst, clk)
261)     BEGIN
262)         IF rst = '1' THEN
Stefan Schuermans fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

263)             r_stall_reset <= '1';
264)             r_pc          <= X"FFFFFFFC";
265)             r_instr_data  <= X"00000000";
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

266)         ELSIF rising_edge(clk) THEN
Stefan Schuermans fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

267)             r_stall_reset <= '0';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

268)             IF s_stall = '0' THEN
Stefan Schuermans fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

269)                 r_pc         <= n_pc;
270)                 r_instr_data <= i_instr_data;
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

272)         END IF;
273)     END PROCESS p_sync_pc;
274) 
Stefan Schuermans fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

277)         IF s_stall = '1' THEN
278)             o_instr_addr <= r_pc;
Stefan Schuermans fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

279)             s_instr      <= r_instr_data;
Stefan Schuermans fixed instruction fetch dur...

Stefan Schuermans authored 12 years ago

280)         ELSE
281)             o_instr_addr <= n_pc;
Stefan Schuermans fixed instruction word inpu...

Stefan Schuermans authored 12 years ago

282)             s_instr      <= i_instr_data;
Stefan Schuermans fixed instruction fetch dur...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

284)     END PROCESS p_fetch;
285) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

289)             r_reg_s  <= (OTHERS => '0');
290)             r_reg_t  <= (OTHERS => '0');
291)             r_reg_d  <= (OTHERS => '0');
292)             r_imm_a  <= (OTHERS => '0');
293)             r_imm_16 <= (OTHERS => '0');
294)             r_imm_26 <= (OTHERS => '0');
295)             r_op     <= op_none;
296)             r_link   <= link_none;
297)             r_cmp    <= cmp_none;
298)             r_alu    <= alu_none;
299)             r_imm    <= imm_none;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

320)     BEGIN
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

323)         IF r_op = op_alu THEN
324)             CASE r_imm IS
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

326)                     s_alu_op1 <= s_val_s;
327)                     s_alu_op2 <= s_val_t;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

338)                 WHEN OTHERS => NULL;
339)             END CASE;
340)         END IF;
341)     END PROCESS p_alu_in;
342) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

364)     BEGIN
365)         s_cmp_op1 <= (OTHERS => '0');
366)         s_cmp_op2 <= (OTHERS => '0');
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

368)             s_cmp_op1 <= s_val_s;
369)             s_cmp_op2 <= s_val_t;
370)         END IF;
371)     END PROCESS p_cmp_in;
372) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

373)     p_reg_wr: PROCESS(s_stall,
374)                       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

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

376)                       s_reg_wr_hi_lo_no, s_reg_wr_hi_lo_data, s_reg_wr_hi_lo_en,
377)                       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

378)     BEGIN
379)         s_reg_wr_no   <= (OTHERS => '0');
380)         s_reg_wr_data <= (OTHERS => '0');
381)         s_reg_wr_en   <= '0';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

382)         IF s_stall = '0' THEN
383)             IF s_reg_wr_alu_en = '1' THEN
384)                 s_reg_wr_no   <= s_reg_wr_alu_no;
385)                 s_reg_wr_data <= s_reg_wr_alu_data;
386)                 s_reg_wr_en   <= '1';
387)             ELSIF s_reg_wr_data_en = '1' THEN
388)                 s_reg_wr_no   <= s_reg_wr_data_no;
389)                 s_reg_wr_data <= s_reg_wr_data_data;
390)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

391)             ELSIF s_reg_wr_hi_lo_en = '1' THEN
392)                 s_reg_wr_no   <= s_reg_wr_hi_lo_no;
393)                 s_reg_wr_data <= s_reg_wr_hi_lo_data;
394)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented ... and link ->...

Stefan Schuermans authored 12 years ago

395)             ELSIF s_reg_wr_link_en = '1' THEN
396)                 s_reg_wr_no   <= s_reg_wr_link_no;
397)                 s_reg_wr_data <= s_reg_wr_link_data;
398)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

400)         END IF;
401)     END PROCESS p_reg_wr;
402) 
Stefan Schuermans implemented jump register i...

Stefan Schuermans authored 12 years ago

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

404)         VARIABLE v_pc:  signed(31 DOWNTO 0);
405)         VARIABLE v_rel: signed(17 DOWNTO 0);
406)     BEGIN
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

413)             ELSE
414)                 n_pc <= s_val_s;
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

418)         END IF;
419)     END PROCESS p_next_pc;
420) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

584)                 WHEN OTHERS => NULL;
585)             END CASE;
586)         END IF;
587)     END PROCESS p_data_wr;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

588) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

591)     BEGIN
592)         n_reg_lo            <= r_reg_lo;
593)         n_reg_hi            <= r_reg_hi;
594)         s_reg_wr_hi_lo_no   <= (OTHERS => '0');
595)         s_reg_wr_hi_lo_data <= (OTHERS => '0');
596)         s_reg_wr_hi_lo_en   <= '0';
597)         CASE r_op IS
598)             WHEN op_mfhi =>
599)                 s_reg_wr_hi_lo_no   <= r_reg_d;
600)                 s_reg_wr_hi_lo_data <= r_reg_hi;
601)                 s_reg_wr_hi_lo_en   <= '1';            
602)             WHEN op_mflo =>
603)                 s_reg_wr_hi_lo_no   <= r_reg_d;
604)                 s_reg_wr_hi_lo_data <= r_reg_lo;
605)                 s_reg_wr_hi_lo_en   <= '1';            
606)             WHEN op_mthi =>
607)                 n_reg_hi <= s_val_s;
608)             WHEN op_mtlo =>
609)                 n_reg_lo <= s_val_s;
Stefan Schuermans implemented multiplier

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

613)             WHEN op_div | op_divu =>
614)                 n_reg_lo <= s_div_res;
615)                 n_reg_hi <= s_div_rem;
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

635) 
Stefan Schuermans implemented divider

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

639)     p_link: PROCESS(r_pc, r_link)
640)     BEGIN
641)         s_reg_wr_link_no   <= std_logic_vector(to_unsigned(31, 5));
642)         s_reg_wr_link_data <= std_logic_vector(signed(r_pc) + to_signed(4, 32));
643)         IF r_link = link_link THEN
644)             s_reg_wr_link_en <= '1';
645)         ELSE
646)             s_reg_wr_link_en <= '0';
647)         END IF;
648)     END PROCESS p_link;
649)