55e2e5964690ce8638e2918f238672f4b7d25a38
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;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

21)     );
22) END ENTITY e_mips_decoder;
23) 
24) ARCHITECTURE a_mips_decoder OF e_mips_decoder IS
25) 
26)     TYPE t_enc_type IS (enc_reg, enc_imm, enc_jmp);
27) 
28)     SIGNAL s_opcode:   std_logic_vector(5 DOWNTO 0);
Stefan Schuermans add missing branch instruct...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

36)     s_ext_op <= i_instr(20 DOWNTO 16);
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

37)     s_func   <= i_instr( 5 DOWNTO  0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

100)     BEGIN
101)         o_op   <= op_none;
102)         o_link <= link_none;
103)         o_cmp  <= cmp_none;
104)         o_alu  <= alu_none;
105)         o_imm  <= imm_none;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

106)         o_ldst <= ldst_none;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

129)                     WHEN OTHERS => NULL;
130)                 END CASE;
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

131)             WHEN "000001" => o_op <= op_j; o_imm <= imm_16se;
Stefan Schuermans add missing branch instruct...

Stefan Schuermans authored 12 years ago

132)                              IF s_ext_op(0) = '1' THEN o_cmp <= cmp_gez;
133)                                                   ELSE o_cmp <= cmp_ltz;
134)                                                   END IF;
135)                              IF s_ext_op(4) = '1' THEN o_link <= link_link;
136)                                                   ELSE o_link <= link_none;
137)                                                   END IF;
Stefan Schuermans fix decoding of J

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

139)             WHEN "000011" => o_op <= op_j; o_link <= link_link; o_imm <= imm_26;
Stefan Schuermans compare unit, initial PC ideas

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

144)             WHEN "001000" => o_op <= op_alu; o_alu <= alu_add; o_imm <= imm_16se;
145)             WHEN "001001" => o_op <= op_alu; o_alu <= alu_add; o_imm <= imm_16se;
146)             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

147)             WHEN "001011" => o_op <= op_alu; o_alu <= alu_sltu; o_imm <= imm_16se;
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

148)             WHEN "001100" => o_op <= op_alu; o_alu <= alu_and; o_imm <= imm_16ze;
149)             WHEN "001101" => o_op <= op_alu; o_alu <= alu_or; o_imm <= imm_16ze;
150)             WHEN "001110" => o_op <= op_alu; o_alu <= alu_xor; o_imm <= imm_16ze;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

151)             WHEN "001111" => o_op <= op_alu; o_alu <= alu_up; o_imm <= imm_16ze;
152)             WHEN "100000" => o_op <= op_l; o_imm <= imm_16se; o_ldst <= ldst_b;
153)             WHEN "100001" => o_op <= op_l; o_imm <= imm_16se; o_ldst <= ldst_h;
Stefan Schuermans decoding of LWL, LWR, SWL, SWR

Stefan Schuermans authored 12 years ago

154)             WHEN "100010" => o_op <= op_l; o_imm <= imm_16se; o_ldst <= ldst_wl;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

155)             WHEN "100011" => o_op <= op_l; o_imm <= imm_16se; o_ldst <= ldst_w;
156)             WHEN "100100" => o_op <= op_l; o_imm <= imm_16se; o_ldst <= ldst_bu;
157)             WHEN "100101" => o_op <= op_l; o_imm <= imm_16se; o_ldst <= ldst_hu;
Stefan Schuermans decoding of LWL, LWR, SWL, SWR

Stefan Schuermans authored 12 years ago

158)             WHEN "100110" => o_op <= op_l; o_imm <= imm_16se; o_ldst <= ldst_wr;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

159)             WHEN "101000" => o_op <= op_s; o_imm <= imm_16se; o_ldst <= ldst_b;
160)             WHEN "101001" => o_op <= op_s; o_imm <= imm_16se; o_ldst <= ldst_h;
Stefan Schuermans decoding of LWL, LWR, SWL, SWR

Stefan Schuermans authored 12 years ago

161)             WHEN "101010" => o_op <= op_s; o_imm <= imm_16se; o_ldst <= ldst_wl;
Stefan Schuermans added decoding of simple lo...

Stefan Schuermans authored 12 years ago

162)             WHEN "101011" => o_op <= op_s; o_imm <= imm_16se; o_ldst <= ldst_w;
Stefan Schuermans decoding of LWL, LWR, SWL, SWR

Stefan Schuermans authored 12 years ago

163)             WHEN "101110" => o_op <= op_s; o_imm <= imm_16se; o_ldst <= ldst_wr;