cbae278d8c7be98f5a4183dab6e718f7cf875581
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);
28)     SIGNAL s_enc_type: t_enc_type;
29)     SIGNAL s_func:     std_logic_vector(5 DOWNTO 0);
30) 
31) BEGIN
32) 
33)     s_opcode <= i_instr(31 DOWNTO 26);
34) 
35)     p_enc_type: PROCESS(s_opcode)
36)     BEGIN
37)         CASE s_opcode IS
38)             WHEN "000000" => s_enc_type <= enc_reg;
39)             WHEN "000010" => s_enc_type <= enc_jmp;
40)             WHEN "011010" => s_enc_type <= enc_jmp;
41)             WHEN OTHERS   => s_enc_type <= enc_imm;
42)         END CASE;
43)     END PROCESS p_enc_type;
44) 
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

46)     BEGIN
47)         CASE s_enc_type IS
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

55)     BEGIN
56)         CASE s_enc_type IS
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

64)     BEGIN
65)         CASE s_enc_type IS
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

70) 
71)     p_imm_a: PROCESS(i_instr, s_enc_type)
72)     BEGIN
73)         CASE s_enc_type IS
74)             WHEN enc_reg => o_imm_a <= i_instr(10 DOWNTO 6);
75)             WHEN OTHERS  => o_imm_a <= "00000";
76)         END CASE;
77)     END PROCESS p_imm_a;
78) 
79)     p_func: PROCESS(i_instr, s_enc_type)
80)     BEGIN
81)         CASE s_enc_type IS
82)             WHEN enc_reg => s_func <= i_instr(5 DOWNTO 0);
83)             WHEN OTHERS  => s_func <= "000000";
84)         END CASE;
85)     END PROCESS p_func;
86) 
87)     p_imm_16: PROCESS(i_instr, s_enc_type)
88)     BEGIN
89)         CASE s_enc_type IS
90)             WHEN enc_reg => o_imm_16 <= i_instr(15 DOWNTO 0);
91)             WHEN OTHERS  => o_imm_16 <= X"0000";
92)         END CASE;
93)     END PROCESS p_imm_16;
94) 
95)     p_imm_26: PROCESS(i_instr, s_enc_type)
96)     BEGIN
97)         CASE s_enc_type IS
98)             WHEN enc_reg => o_imm_26 <= i_instr(25 DOWNTO 0);
99)             WHEN OTHERS  => o_imm_26 <= X"000000" & "00";
100)         END CASE;
101)     END PROCESS p_imm_26;
102) 
103)     p_op: PROCESS(s_opcode, s_func)
104)     BEGIN
105)         o_op   <= op_none;
106)         o_link <= link_none;
107)         o_cmp  <= cmp_none;
108)         o_alu  <= alu_none;
109)         o_imm  <= imm_none;
110)         CASE s_opcode IS
111)             WHEN "000000" =>
112)                 CASE s_func IS
113)                     WHEN "000000" => o_op <= op_alu; o_alu <= alu_sll; o_imm <= imm_a;
114)                     WHEN "000010" => o_op <= op_alu; o_alu <= alu_srl; o_imm <= imm_a;
115)                     WHEN "000011" => o_op <= op_alu; o_alu <= alu_sra; o_imm <= imm_a;
116)                     WHEN "000100" => o_op <= op_alu; o_alu <= alu_sll;
117)                     WHEN "000110" => o_op <= op_alu; o_alu <= alu_srl;
118)                     WHEN "000111" => o_op <= op_alu; o_alu <= alu_sra;
119)                     WHEN "001000" => o_op <= op_j;
120)                     WHEN "001001" => o_op <= op_j; o_link <= link_link;
121)                     -- TODO: 010xxx, 011xxx missing
122)                     WHEN "100000" => o_op <= op_alu; o_alu <= alu_add;
123)                     WHEN "100001" => o_op <= op_alu; o_alu <= alu_add;
124)                     WHEN "100010" => o_op <= op_alu; o_alu <= alu_sub;
125)                     WHEN "100011" => o_op <= op_alu; o_alu <= alu_sub;
126)                     WHEN "100100" => o_op <= op_alu; o_alu <= alu_and;
127)                     WHEN "100101" => o_op <= op_alu; o_alu <= alu_or;
128)                     WHEN "100110" => o_op <= op_alu; o_alu <= alu_xor;
129)                     WHEN "100111" => o_op <= op_alu; o_alu <= alu_nor;
130)                     WHEN "101010" => o_op <= op_alu; o_alu <= alu_slt;
Stefan Schuermans separated shifter from ALU

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

132)                     WHEN OTHERS => NULL;
133)                 END CASE;
134)             WHEN "000010" => o_op <= op_j;
135)             WHEN "000011" => o_op <= op_j; o_link <= link_link; o_imm <= imm_26;
136)             WHEN "000100" => o_op <= op_b; o_cmp <= cmp_eq;
137)             WHEN "000101" => o_op <= op_b; o_cmp <= cmp_ne;
138)             WHEN "000110" => o_op <= op_b; o_cmp <= cmp_lez;
139)             WHEN "000111" => o_op <= op_b; o_cmp <= cmp_gtz;
140)             WHEN "001000" => o_op <= op_alu; o_alu <= alu_add; o_imm <= imm_16se;
141)             WHEN "001001" => o_op <= op_alu; o_alu <= alu_add; o_imm <= imm_16se;
142)             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

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