3e7dd45a140fbd055e030e0afdba0d189fc818c4
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 r_data_rd: t_data_rd;
87)     SIGNAL n_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 start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

97)             o_reg_s:  OUT std_logic_vector( 4 DOWNTO 0);
98)             o_reg_t:  OUT std_logic_vector( 4 DOWNTO 0);
99)             o_reg_d:  OUT std_logic_vector( 4 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

100)             o_imm_a:  OUT std_logic_vector( 4 DOWNTO 0);
101)             o_imm_16: OUT std_logic_vector(15 DOWNTO 0);
102)             o_imm_26: OUT std_logic_vector(25 DOWNTO 0);
103)             o_op:     OUT t_op;
104)             o_link:   OUT t_link;
105)             o_cmp:    OUT t_cmp;
106)             o_alu:    OUT t_alu;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

109)         );
110)     END COMPONENT e_mips_decoder;
111) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

112)     COMPONENT e_mips_regs IS
113)         PORT (
114)             rst:         IN  std_logic;
115)             clk:         IN  std_logic;
116)             i_rd_a_no:   IN  std_logic_vector( 4 DOWNTO 0);
117)             o_rd_a_data: OUT std_logic_vector(31 DOWNTO 0);
118)             i_rd_b_no:   IN  std_logic_vector( 4 DOWNTO 0);
119)             o_rd_b_data: OUT std_logic_vector(31 DOWNTO 0);
120)             i_wr_no:     IN  std_logic_vector( 4 DOWNTO 0);
121)             i_wr_data:   IN  std_logic_vector(31 DOWNTO 0);
122)             i_wr_en:     IN  std_logic
123)         );
124)     END COMPONENT e_mips_regs;
125) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

126)     COMPONENT e_mips_alu IS
127)         PORT (
128)             i_alu: IN  t_alu;
129)             i_op1: IN  std_logic_vector(31 DOWNTO 0);
130)             i_op2: IN  std_logic_vector(31 DOWNTO 0);
131)             o_res: OUT std_logic_vector(31 DOWNTO 0)
132)         );
133)     END COMPONENT e_mips_alu;
134) 
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

135)     COMPONENT e_mips_cmp IS
136)         PORT (
137)             i_cmp: IN  t_cmp;
138)             i_op1: IN  std_logic_vector(31 DOWNTO 0);
139)             i_op2: IN  std_logic_vector(31 DOWNTO 0);
140)             o_res: OUT std_logic
141)         );
142)     END COMPONENT e_mips_cmp;
143) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

144) BEGIN
145) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

148)     decoder: e_mips_decoder
149)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

150)             i_instr  => s_instr,
151)             o_reg_s  => n_reg_s,
152)             o_reg_t  => n_reg_t,
153)             o_reg_d  => n_reg_d,
154)             o_imm_a  => n_imm_a,
155)             o_imm_16 => n_imm_16,
156)             o_imm_26 => n_imm_26,
157)             o_op     => n_op,
158)             o_link   => n_link,
159)             o_cmp    => n_cmp,
160)             o_alu    => n_alu,
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

163)         );
164) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

165)     regs: e_mips_regs
166)         PORT MAP (
167)             rst         => rst,
168)             clk         => clk,
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

172)             o_rd_b_data => s_val_t,
173)             i_wr_no     => s_reg_wr_no,
174)             i_wr_data   => s_reg_wr_data,
175)             i_wr_en     => s_reg_wr_en
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

177) 
178)     alu: e_mips_alu
179)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

181)             i_op1 => s_alu_op1,
182)             i_op2 => s_alu_op2,
183)             o_res => s_alu_res
184)         );
185) 
186)     cmp: e_mips_cmp
187)         PORT MAP (
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

189)             i_op1 => s_cmp_op1,
190)             i_op2 => s_cmp_op2,
191)             o_res => s_cmp_res
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

192)         );
193) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

194)     p_sync_pc: PROCESS(rst, clk)
195)     BEGIN
196)         IF rst = '1' THEN
197)             r_pc <= (OTHERS => '0');
198)         ELSIF rising_edge(clk) THEN
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

199)             IF s_stall = '0' THEN
200)                 r_pc <= n_pc;
201)             END IF;
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

202)         END IF;
203)     END PROCESS p_sync_pc;
204) 
205)     p_fetch: PROCESS(n_pc, i_instr_data)
206)     BEGIN
207)         o_instr_addr <= n_pc;
208)         s_instr      <= i_instr_data;
209)     END PROCESS p_fetch;
210) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

214)             r_reg_s  <= (OTHERS => '0');
215)             r_reg_t  <= (OTHERS => '0');
216)             r_reg_d  <= (OTHERS => '0');
217)             r_imm_a  <= (OTHERS => '0');
218)             r_imm_16 <= (OTHERS => '0');
219)             r_imm_26 <= (OTHERS => '0');
220)             r_op     <= op_none;
221)             r_link   <= link_none;
222)             r_cmp    <= cmp_none;
223)             r_alu    <= alu_none;
224)             r_imm    <= imm_none;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

227)             IF s_stall = '0' THEN
228)                 r_reg_s  <= n_reg_s;
229)                 r_reg_t  <= n_reg_t;
230)                 r_reg_d  <= n_reg_d;
231)                 r_imm_a  <= n_imm_a;
232)                 r_imm_16 <= n_imm_16;
233)                 r_imm_26 <= n_imm_26;
234)                 r_op     <= n_op;
235)                 r_link   <= n_link;
236)                 r_cmp    <= n_cmp;
237)                 r_alu    <= n_alu;
238)                 r_imm    <= n_imm;
239)                 r_ldst   <= n_ldst;
240)             END IF;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

245)     BEGIN
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

248)         IF r_op = op_alu THEN
249)             CASE r_imm IS
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

251)                     s_alu_op1 <= s_val_s;
252)                     s_alu_op2 <= s_val_t;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

263)                 WHEN OTHERS => NULL;
264)             END CASE;
265)         END IF;
266)     END PROCESS p_alu_in;
267) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

268)     p_alu_out: PROCESS(r_op, r_imm, r_reg_t, r_reg_d, s_alu_res)
269)     BEGIN
270)         s_reg_wr_alu_no   <= (OTHERS => '0');
271)         s_reg_wr_alu_data <= (OTHERS => '0');
272)         s_reg_wr_alu_en   <= '0';
273)         IF r_op = op_alu THEN
274)             CASE r_imm IS
275)                 WHEN imm_none | imm_a =>
276)                     s_reg_wr_alu_no   <= r_reg_d;
277)                     s_reg_wr_alu_data <= s_alu_res;
278)                     s_reg_wr_alu_en   <= '1';
279)                 WHEN imm_16se | imm_16ze =>
280)                     s_reg_wr_alu_no   <= r_reg_t;
281)                     s_reg_wr_alu_data <= s_alu_res;
282)                     s_reg_wr_alu_en   <= '1';
283)                 WHEN OTHERS => NULL;
284)             END CASE;
285)         END IF;
286)     END PROCESS p_alu_out;
287) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

289)     BEGIN
290)         s_cmp_op1 <= (OTHERS => '0');
291)         s_cmp_op2 <= (OTHERS => '0');
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

293)             s_cmp_op1 <= s_val_s;
294)             s_cmp_op2 <= s_val_t;
295)         END IF;
296)     END PROCESS p_cmp_in;
297) 
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

298)     p_reg_wr: PROCESS(s_stall,
299)                       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

300)                       s_reg_wr_data_no, s_reg_wr_data_data, s_reg_wr_data_en,
301)                       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

302)     BEGIN
303)         s_reg_wr_no   <= (OTHERS => '0');
304)         s_reg_wr_data <= (OTHERS => '0');
305)         s_reg_wr_en   <= '0';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

306)         IF s_stall = '0' THEN
307)             IF s_reg_wr_alu_en = '1' THEN
308)                 s_reg_wr_no   <= s_reg_wr_alu_no;
309)                 s_reg_wr_data <= s_reg_wr_alu_data;
310)                 s_reg_wr_en   <= '1';
311)             ELSIF s_reg_wr_data_en = '1' THEN
312)                 s_reg_wr_no   <= s_reg_wr_data_no;
313)                 s_reg_wr_data <= s_reg_wr_data_data;
314)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

315)             ELSIF s_reg_wr_hi_lo_en = '1' THEN
316)                 s_reg_wr_no   <= s_reg_wr_hi_lo_no;
317)                 s_reg_wr_data <= s_reg_wr_hi_lo_data;
318)                 s_reg_wr_en   <= '1';
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

320)         END IF;
321)     END PROCESS p_reg_wr;
322) 
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

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

324)         VARIABLE v_pc:  signed(31 DOWNTO 0);
325)         VARIABLE v_rel: signed(17 DOWNTO 0);
326)     BEGIN
Stefan Schuermans implement jump logic, imple...

Stefan Schuermans authored 12 years ago

327)         IF r_op = op_j AND s_cmp_res = '1' THEN
328)             IF r_imm = imm_26 THEN
329)                 n_pc <= r_pc(31 DOWNTO 28) & r_imm_26 & "00";
330)             ELSE
331)                 n_pc <= std_logic_vector(signed(r_pc) +
332)                                          signed(r_imm_16 & "00"));
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

334)         ELSE
335)             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

336)         END IF;
337)     END PROCESS p_next_pc;
338) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

339)     p_data_addr: PROCESS(r_op, s_val_s, r_imm_16)
340)         VARIABLE v_ofs: signed(31 DOWNTO 0);
341)         VARIABLE v_addr: signed(31 DOWNTO 0);
342)     BEGIN
343)         s_data_addr <= (OTHERS => '0');
344)         IF r_op = op_l OR r_op = op_s THEN
345)             v_ofs(15 DOWNTO 0)  := signed(r_imm_16);
346)             v_ofs(31 DOWNTO 16) := (OTHERS => r_imm_16(15));
347)             v_addr              := signed(s_val_s) + v_ofs;
348)             s_data_addr         <= std_logic_vector(v_addr);
349)         END IF;
350)     END PROCESS p_data_addr;
351) 
352)     o_data_addr <= s_data_addr(31 DOWNTO 2) & "00";
353) 
Stefan Schuermans implementation of LWL, LWR

Stefan Schuermans authored 12 years ago

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

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

358)     BEGIN
359)         s_stall_data_rd    <= '0';
360)         n_data_rd          <= data_rd_idle;
361)         s_reg_wr_data_no   <= (OTHERS => '0');
362)         s_reg_wr_data_data <= (OTHERS => '0');
363)         s_reg_wr_data_en   <= '0';
364)         CASE r_data_rd IS
365)             WHEN data_rd_idle =>
366)                 IF r_op = op_l THEN
367)                     s_stall_data_rd <= '1';
368)                     n_data_rd <= data_rd_read;
369)                 END IF;
370)             WHEN data_rd_read =>
371)                 CASE r_ldst IS
372)                     WHEN ldst_b | ldst_bu =>
373)                         CASE s_data_addr(1 DOWNTO 0) IS
374)                             WHEN "00" => v_b := i_data_rd_data( 7 DOWNTO  0);
375)                             WHEN "01" => v_b := i_data_rd_data(15 DOWNTO  8);
376)                             WHEN "10" => v_b := i_data_rd_data(23 DOWNTO 16);
377)                             WHEN "11" => v_b := i_data_rd_data(31 DOWNTO 24);
378)                             WHEN OTHERS => NULL;
379)                         END CASE;
380)                         s_reg_wr_data_data(7 DOWNTO 0) <= v_b;
381)                         IF r_ldst = ldst_b THEN
382)                             s_reg_wr_data_data(31 DOWNTO 8) <= (OTHERS => v_b(7));
383)                         END IF;
384)                     WHEN ldst_h | ldst_hu =>
385)                         CASE s_data_addr(1 DOWNTO 1) IS
386)                             WHEN "0" => v_h := i_data_rd_data(15 DOWNTO  0);
387)                             WHEN "1" => v_h := i_data_rd_data(31 DOWNTO 16);
388)                             WHEN OTHERS => NULL;
389)                         END CASE;
390)                         s_reg_wr_data_data(15 DOWNTO 0) <= v_h;
391)                         IF r_ldst = ldst_h THEN
392)                             s_reg_wr_data_data(31 DOWNTO 16) <= (OTHERS => v_h(15));
393)                         END IF;
394)                     WHEN ldst_w =>
395)                         s_reg_wr_data_data <= i_data_rd_data;
Stefan Schuermans implementation of LWL, LWR

Stefan Schuermans authored 12 years ago

396)                     WHEN ldst_wl =>
397)                         v_w := s_val_t;
398)                         CASE s_data_addr(1 DOWNTO 0) IS
399)                             WHEN "00" => v_w(31 DOWNTO 24) := i_data_rd_data( 7 DOWNTO 0);
400)                             WHEN "01" => v_w(31 DOWNTO 16) := i_data_rd_data(15 DOWNTO 0);
401)                             WHEN "10" => v_w(31 DOWNTO  8) := i_data_rd_data(23 DOWNTO 0);
402)                             WHEN "11" => v_w(31 DOWNTO  0) := i_data_rd_data(31 DOWNTO 0);
403)                             WHEN OTHERS => NULL;
404)                         END CASE;
405)                         s_reg_wr_data_data <= v_w;
406)                     WHEN ldst_wr =>
407)                         v_w := s_val_t;
408)                         CASE s_data_addr(1 DOWNTO 0) IS
409)                             WHEN "00" => v_w(31 DOWNTO  0) := i_data_rd_data(31 DOWNTO  0);
410)                             WHEN "01" => v_w(23 DOWNTO  0) := i_data_rd_data(31 DOWNTO  8);
411)                             WHEN "10" => v_w(15 DOWNTO  0) := i_data_rd_data(31 DOWNTO 16);
412)                             WHEN "11" => v_w( 7 DOWNTO  0) := i_data_rd_data(31 DOWNTO 24);
413)                             WHEN OTHERS => NULL;
414)                         END CASE;
415)                         s_reg_wr_data_data <= v_w;
Stefan Schuermans implemented simple load ins...

Stefan Schuermans authored 12 years ago

416)                     WHEN OTHERS => NULL;
417)                 END CASE;
418)                 s_reg_wr_data_no <= r_reg_t;
419)                 s_reg_wr_data_en <= '1';
420)             WHEN OTHERS => NULL;
421)         END CASE;
422)     END PROCESS p_data_rd;
423) 
424)     p_sync_data_rd: PROCESS(rst, clk)
425)     BEGIN
426)         IF rst = '1' THEN
427)             r_data_rd <= data_rd_idle;
428)         ELSIF rising_edge(clk) THEN
429)             IF i_stall = '0' THEN
430)                 r_data_rd <= n_data_rd;
431)             END IF;
432)         END IF;
433)     END PROCESS p_sync_data_rd;
434) 
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

435)     p_data_wr: PROCESS(r_op, r_ldst, s_data_addr, s_val_t)
436)     BEGIN
437)         o_data_wr_data <= (OTHERS => '0');
438)         o_data_wr_en   <= "0000";
439)         IF r_op = op_s THEN
440)             CASE r_ldst IS
441)                 WHEN ldst_b =>
442)                     CASE s_data_addr(1 DOWNTO 0) IS
443)                         WHEN "00" =>
444)                             o_data_wr_data( 7 DOWNTO  0) <= s_val_t(7 DOWNTO 0);
445)                             o_data_wr_en                 <= "0001";
446)                         WHEN "01" =>
447)                             o_data_wr_data(15 DOWNTO  8) <= s_val_t(7 DOWNTO 0);
448)                             o_data_wr_en                 <= "0010";
449)                         WHEN "10" =>
450)                             o_data_wr_data(23 DOWNTO 16) <= s_val_t(7 DOWNTO 0);
451)                             o_data_wr_en                 <= "0100";
452)                         WHEN "11" =>
453)                             o_data_wr_data(31 DOWNTO 24) <= s_val_t(7 DOWNTO 0);
454)                             o_data_wr_en                 <= "1000";
455)                         WHEN OTHERS => NULL;
456)                     END CASE;
457)                 WHEN ldst_h =>
458)                     CASE s_data_addr(1 DOWNTO 1) IS
459)                         WHEN "0" =>
460)                             o_data_wr_data(15 DOWNTO  0) <= s_val_t(15 DOWNTO 0);
461)                             o_data_wr_en                 <= "0011";
462)                         WHEN "1" =>
463)                             o_data_wr_data(31 DOWNTO 16) <= s_val_t(15 DOWNTO 0);
464)                             o_data_wr_en                 <= "1100";
465)                         WHEN OTHERS => NULL;
466)                     END CASE;
467)                 WHEN ldst_w =>
468)                     o_data_wr_data <= s_val_t;
469)                     o_data_wr_en   <= "1111";
Stefan Schuermans implemented M T/F HI/LO

Stefan Schuermans authored 12 years ago

470)                 WHEN ldst_wl =>
471)                     CASE s_data_addr(1 DOWNTO 0) IS
472)                         WHEN "00" =>
473)                             o_data_wr_data( 7 DOWNTO 0) <= s_val_t(31 DOWNTO 24);
474)                             o_data_wr_en                <= "0001";
475)                         WHEN "01" =>
476)                             o_data_wr_data(15 DOWNTO 0) <= s_val_t(31 DOWNTO 16);
477)                             o_data_wr_en                <= "0011";
478)                         WHEN "10" =>
479)                             o_data_wr_data(23 DOWNTO 0) <= s_val_t(31 DOWNTO  8);
480)                             o_data_wr_en                <= "0111";
481)                         WHEN "11" =>
482)                             o_data_wr_data(31 DOWNTO 0) <= s_val_t(31 DOWNTO  0);
483)                             o_data_wr_en                <= "1111";
484)                         WHEN OTHERS => NULL;
485)                     END CASE;
486)                 WHEN ldst_wr =>
487)                     CASE s_data_addr(1 DOWNTO 0) IS
488)                         WHEN "00" =>
489)                             o_data_wr_data(31 DOWNTO  0) <= s_val_t(31 DOWNTO 0);
490)                             o_data_wr_en                 <= "1111";
491)                         WHEN "01" =>
492)                             o_data_wr_data(31 DOWNTO  8) <= s_val_t(23 DOWNTO 0);
493)                             o_data_wr_en                 <= "1110";
494)                         WHEN "10" =>
495)                             o_data_wr_data(31 DOWNTO 16) <= s_val_t(15 DOWNTO 0);
496)                             o_data_wr_en                 <= "1100";
497)                         WHEN "11" =>
498)                             o_data_wr_data(31 DOWNTO 24) <= s_val_t( 7 DOWNTO 0);
499)                             o_data_wr_en                 <= "1000";
500)                         WHEN OTHERS => NULL;
501)                     END CASE;
Stefan Schuermans implemented simple store in...

Stefan Schuermans authored 12 years ago

502)                 WHEN OTHERS => NULL;
503)             END CASE;
504)         END IF;
505)     END PROCESS p_data_wr;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

507)     p_reg_hi_lo: PROCESS(r_reg_lo, r_reg_hi, r_op, r_reg_d, s_val_s)
508)     BEGIN
509)         n_reg_lo            <= r_reg_lo;
510)         n_reg_hi            <= r_reg_hi;
511)         s_reg_wr_hi_lo_no   <= (OTHERS => '0');
512)         s_reg_wr_hi_lo_data <= (OTHERS => '0');
513)         s_reg_wr_hi_lo_en   <= '0';
514)         CASE r_op IS
515)             WHEN op_mfhi =>
516)                 s_reg_wr_hi_lo_no   <= r_reg_d;
517)                 s_reg_wr_hi_lo_data <= r_reg_hi;
518)                 s_reg_wr_hi_lo_en   <= '1';            
519)             WHEN op_mflo =>
520)                 s_reg_wr_hi_lo_no   <= r_reg_d;
521)                 s_reg_wr_hi_lo_data <= r_reg_lo;
522)                 s_reg_wr_hi_lo_en   <= '1';            
523)             WHEN op_mthi =>
524)                 n_reg_hi <= s_val_s;
525)             WHEN op_mtlo =>
526)                 n_reg_lo <= s_val_s;
527)             WHEN OTHERS => NULL;
528)         END CASE;
529)     END PROCESS p_reg_hi_lo;
530) 
531)     p_sync_reg_hi_lo: PROCESS(clk, rst)
532)     BEGIN
533)         IF rst = '1' THEN
534)             r_reg_lo <= (OTHERS => '0');
535)             r_reg_hi <= (OTHERS => '0');
536)         ELSIF rising_edge(clk) THEN
537)             IF s_stall = '0' THEN
538)                 r_reg_lo <= n_reg_lo;
539)                 r_reg_hi <= n_reg_hi;
540)             END IF;
541)         END IF;
542)     END PROCESS p_sync_reg_hi_lo;
543)