20735fb90be09b504dfda8f0274d6011d6342085
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_decoder IS
7)     PORT (
8)         i_instr:  IN  std_logic_vector(31 DOWNTO 0);
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

9)         o_reg_s:  OUT std_logic_vector( 4 DOWNTO 0);
10)         o_reg_t:  OUT std_logic_vector( 4 DOWNTO 0);
11)         o_reg_d:  OUT std_logic_vector( 4 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

12)         o_imm_a:  OUT std_logic_vector( 4 DOWNTO 0);
13)         o_imm_16: OUT std_logic_vector(15 DOWNTO 0);
14)         o_imm_26: OUT std_logic_vector(25 DOWNTO 0);
15)         o_op:     OUT t_op;
16)         o_link:   OUT t_link;
17)         o_cmp:    OUT t_cmp;
18)         o_alu:    OUT t_alu;
19)         o_imm:    OUT t_imm
20)     );
21) END ENTITY e_mips_decoder;
22) 
23) ARCHITECTURE a_mips_decoder OF e_mips_decoder IS
24) 
25)     TYPE t_enc_type IS (enc_reg, enc_imm, enc_jmp);
26) 
27)     SIGNAL s_opcode:   std_logic_vector(5 DOWNTO 0);
Stefan Schuermans add missing branch instruct...

Stefan Schuermans authored 12 years ago

28)     SIGNAL s_ext_op:   std_logic_vector(4 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

29)     SIGNAL s_func:     std_logic_vector(5 DOWNTO 0);
Stefan Schuermans add missing branch instruct...

Stefan Schuermans authored 12 years ago

30)     SIGNAL s_enc_type: t_enc_type;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

31) 
32) BEGIN
33) 
34)     s_opcode <= i_instr(31 DOWNTO 26);
Stefan Schuermans add missing branch instruct...

Stefan Schuermans authored 12 years ago

35)     s_ext_op <= i_instr(20 DOWNTO 16);
36)     s_func   <= i_instr( 5 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

37) 
38)     p_enc_type: PROCESS(s_opcode)
39)     BEGIN
40)         CASE s_opcode IS
41)             WHEN "000000" => s_enc_type <= enc_reg;
42)             WHEN "000010" => s_enc_type <= enc_jmp;
43)             WHEN "011010" => s_enc_type <= enc_jmp;
44)             WHEN OTHERS   => s_enc_type <= enc_imm;
45)         END CASE;
46)     END PROCESS p_enc_type;
47) 
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

48)     p_reg_s: PROCESS(i_instr, s_enc_type)
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

49)     BEGIN
50)         CASE s_enc_type IS
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

51)             WHEN enc_reg => o_reg_s <= i_instr(25 DOWNTO 21);
52)             WHEN enc_imm => o_reg_s <= i_instr(25 DOWNTO 21);
53)             WHEN OTHERS  => o_reg_s <= "00000";
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

54)         END CASE;
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

55)     END PROCESS p_reg_s;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

56) 
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

57)     p_reg_t: PROCESS(i_instr, s_enc_type)
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

58)     BEGIN
59)         CASE s_enc_type IS
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

60)             WHEN enc_reg => o_reg_t <= i_instr(20 DOWNTO 16);
61)             WHEN enc_imm => o_reg_t <= i_instr(20 DOWNTO 16);
62)             WHEN OTHERS  => o_reg_t <= "00000";
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

63)         END CASE;
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

64)     END PROCESS p_reg_t;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

65) 
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

66)     p_reg_d: PROCESS(i_instr, s_enc_type)
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

67)     BEGIN
68)         CASE s_enc_type IS
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

69)             WHEN enc_reg => o_reg_d <= i_instr(15 DOWNTO 11);
70)             WHEN OTHERS  => o_reg_d <= "00000";
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

71)         END CASE;
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

72)     END PROCESS p_reg_d;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

73) 
74)     p_imm_a: PROCESS(i_instr, s_enc_type)
75)     BEGIN
76)         CASE s_enc_type IS
77)             WHEN enc_reg => o_imm_a <= i_instr(10 DOWNTO 6);
78)             WHEN OTHERS  => o_imm_a <= "00000";
79)         END CASE;
80)     END PROCESS p_imm_a;
81) 
82)     p_imm_16: PROCESS(i_instr, s_enc_type)
83)     BEGIN
84)         CASE s_enc_type IS
85)             WHEN enc_reg => o_imm_16 <= i_instr(15 DOWNTO 0);
86)             WHEN OTHERS  => o_imm_16 <= X"0000";
87)         END CASE;
88)     END PROCESS p_imm_16;
89) 
90)     p_imm_26: PROCESS(i_instr, s_enc_type)
91)     BEGIN
92)         CASE s_enc_type IS
93)             WHEN enc_reg => o_imm_26 <= i_instr(25 DOWNTO 0);
94)             WHEN OTHERS  => o_imm_26 <= X"000000" & "00";
95)         END CASE;
96)     END PROCESS p_imm_26;
97) 
Stefan Schuermans add missing branch instruct...

Stefan Schuermans authored 12 years ago

98)     p_op: PROCESS(s_opcode, s_ext_op, s_func)
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

99)     BEGIN
100)         o_op   <= op_none;
101)         o_link <= link_none;
102)         o_cmp  <= cmp_none;
103)         o_alu  <= alu_none;
104)         o_imm  <= imm_none;
105)         CASE s_opcode IS
106)             WHEN "000000" =>
107)                 CASE s_func IS
108)                     WHEN "000000" => o_op <= op_alu; o_alu <= alu_sll; o_imm <= imm_a;
109)                     WHEN "000010" => o_op <= op_alu; o_alu <= alu_srl; o_imm <= imm_a;
110)                     WHEN "000011" => o_op <= op_alu; o_alu <= alu_sra; o_imm <= imm_a;
111)                     WHEN "000100" => o_op <= op_alu; o_alu <= alu_sll;
112)                     WHEN "000110" => o_op <= op_alu; o_alu <= alu_srl;
113)                     WHEN "000111" => o_op <= op_alu; o_alu <= alu_sra;
114)                     WHEN "001000" => o_op <= op_j;
115)                     WHEN "001001" => o_op <= op_j; o_link <= link_link;
116)                     -- TODO: 010xxx, 011xxx missing
117)                     WHEN "100000" => o_op <= op_alu; o_alu <= alu_add;
118)                     WHEN "100001" => o_op <= op_alu; o_alu <= alu_add;
119)                     WHEN "100010" => o_op <= op_alu; o_alu <= alu_sub;
120)                     WHEN "100011" => o_op <= op_alu; o_alu <= alu_sub;
121)                     WHEN "100100" => o_op <= op_alu; o_alu <= alu_and;
122)                     WHEN "100101" => o_op <= op_alu; o_alu <= alu_or;
123)                     WHEN "100110" => o_op <= op_alu; o_alu <= alu_xor;
124)                     WHEN "100111" => o_op <= op_alu; o_alu <= alu_nor;
125)                     WHEN "101010" => o_op <= op_alu; o_alu <= alu_slt;
Stefan Schuermans separated shifter from ALU

Stefan Schuermans authored 12 years ago

126)                     WHEN "101011" => o_op <= op_alu; o_alu <= alu_sltu;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

127)                     WHEN OTHERS => NULL;
128)                 END CASE;
Stefan Schuermans add missing branch instruct...

Stefan Schuermans authored 12 years ago

129)             WHEN "000001" => o_op <= op_b; o_imm <= imm_16se;
130)                              IF s_ext_op(0) = '1' THEN o_cmp <= cmp_gez;
131)                                                   ELSE o_cmp <= cmp_ltz;
132)                                                   END IF;
133)                              IF s_ext_op(4) = '1' THEN o_link <= link_link;
134)                                                   ELSE o_link <= link_none;
135)                                                   END IF;
Stefan Schuermans fix decoding of J

Stefan Schuermans authored 12 years ago

136)             WHEN "000010" => o_op <= op_j; o_imm <= imm_26;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

137)             WHEN "000011" => o_op <= op_j; o_link <= link_link; o_imm <= imm_26;
Stefan Schuermans add missing branch instruct...

Stefan Schuermans authored 12 years ago

138)             WHEN "000100" => o_op <= op_b; o_cmp <= cmp_eq; o_imm <= imm_16se;
139)             WHEN "000101" => o_op <= op_b; o_cmp <= cmp_ne; o_imm <= imm_16se;
140)             WHEN "000110" => o_op <= op_b; o_cmp <= cmp_lez; o_imm <= imm_16se;
141)             WHEN "000111" => o_op <= op_b; o_cmp <= cmp_gtz; o_imm <= imm_16se;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

142)             WHEN "001000" => o_op <= op_alu; o_alu <= alu_add; o_imm <= imm_16se;
143)             WHEN "001001" => o_op <= op_alu; o_alu <= alu_add; o_imm <= imm_16se;
144)             WHEN "001010" => o_op <= op_alu; o_alu <= alu_slt; o_imm <= imm_16se;
Stefan Schuermans separated shifter from ALU

Stefan Schuermans authored 12 years ago

145)             WHEN "001011" => o_op <= op_alu; o_alu <= alu_sltu; o_imm <= imm_16se;