1 |
2 |
rhoads |
---------------------------------------------------------------------
|
2 |
|
|
-- TITLE: Controller / Opcode Decoder
|
3 |
|
|
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
|
4 |
|
|
-- DATE CREATED: 2/8/01
|
5 |
|
|
-- FILENAME: control.vhd
|
6 |
43 |
rhoads |
-- PROJECT: Plasma CPU core
|
7 |
2 |
rhoads |
-- COPYRIGHT: Software placed into the public domain by the author.
|
8 |
|
|
-- Software 'as is' without warranty. Author liable for nothing.
|
9 |
39 |
rhoads |
-- NOTE: MIPS(tm) is a registered trademark of MIPS Technologies.
|
10 |
|
|
-- MIPS Technologies does not endorse and is not associated with
|
11 |
|
|
-- this project.
|
12 |
2 |
rhoads |
-- DESCRIPTION:
|
13 |
|
|
-- Controls the CPU by decoding the opcode and generating control
|
14 |
|
|
-- signals to the rest of the CPU.
|
15 |
39 |
rhoads |
-- This entity decodes the MIPS(tm) opcode into a
|
16 |
|
|
-- Very-Long-Word-Instruction.
|
17 |
2 |
rhoads |
-- The 32-bit opcode is converted to a
|
18 |
|
|
-- 6+6+6+16+5+2+3+3+2+2+3+2+4 = 60 bit VLWI opcode.
|
19 |
|
|
-- Based on information found in:
|
20 |
|
|
-- "MIPS RISC Architecture" by Gerry Kane and Joe Heinrich
|
21 |
|
|
-- and "The Designer's Guide to VHDL" by Peter J. Ashenden
|
22 |
|
|
---------------------------------------------------------------------
|
23 |
|
|
library ieee;
|
24 |
|
|
use ieee.std_logic_1164.all;
|
25 |
39 |
rhoads |
use work.mlite_pack.all;
|
26 |
2 |
rhoads |
|
27 |
|
|
entity control is
|
28 |
|
|
port(opcode : in std_logic_vector(31 downto 0);
|
29 |
|
|
intr_signal : in std_logic;
|
30 |
|
|
rs_index : out std_logic_vector(5 downto 0);
|
31 |
|
|
rt_index : out std_logic_vector(5 downto 0);
|
32 |
|
|
rd_index : out std_logic_vector(5 downto 0);
|
33 |
|
|
imm_out : out std_logic_vector(15 downto 0);
|
34 |
|
|
alu_func : out alu_function_type;
|
35 |
|
|
shift_func : out shift_function_type;
|
36 |
|
|
mult_func : out mult_function_type;
|
37 |
|
|
branch_func : out branch_function_type;
|
38 |
|
|
a_source_out : out a_source_type;
|
39 |
|
|
b_source_out : out b_source_type;
|
40 |
|
|
c_source_out : out c_source_type;
|
41 |
|
|
pc_source_out: out pc_source_type;
|
42 |
|
|
mem_source_out:out mem_source_type);
|
43 |
|
|
end; --entity control
|
44 |
|
|
|
45 |
|
|
architecture logic of control is
|
46 |
|
|
-- type alu_function_type is (alu_nothing, alu_add, alu_subtract,
|
47 |
84 |
rhoads |
-- alu_less_than, alu_less_than_signed,
|
48 |
2 |
rhoads |
-- alu_or, alu_and, alu_xor, alu_nor);
|
49 |
|
|
-- type shift_function_type is (
|
50 |
|
|
-- shift_nothing, shift_left_unsigned,
|
51 |
|
|
-- shift_right_signed, shift_right_unsigned);
|
52 |
|
|
-- type mult_function_type is (
|
53 |
|
|
-- mult_nothing, mult_read_lo, mult_read_hi, mult_write_lo,
|
54 |
|
|
-- mult_write_hi, mult_mult, mult_divide, mult_signed_divide);
|
55 |
|
|
-- type a_source_type is (from_reg_source, from_imm10_6);
|
56 |
|
|
-- type b_source_type is (from_reg_target, from_imm, from_signed_imm);
|
57 |
|
|
-- type c_source_type is (from_null, from_alu, from_shift,
|
58 |
|
|
-- from_mult, from_memory, from_pc, from_imm_shift16,
|
59 |
|
|
-- from_reg_source_nez, from_reg_source_eqz);
|
60 |
|
|
-- type pc_source_type is (from_inc4, from_inc8, from_reg_source,
|
61 |
|
|
-- from_opcode25_0, from_branch, from_lbranch);
|
62 |
|
|
begin
|
63 |
|
|
|
64 |
71 |
rhoads |
control_proc: process(opcode, intr_signal)
|
65 |
2 |
rhoads |
variable op, func : std_logic_vector(5 downto 0);
|
66 |
|
|
variable rs, rt, rd : std_logic_vector(5 downto 0);
|
67 |
46 |
rhoads |
variable rtx : std_logic_vector(4 downto 0);
|
68 |
2 |
rhoads |
variable imm : std_logic_vector(15 downto 0);
|
69 |
|
|
variable alu_function : alu_function_type;
|
70 |
|
|
variable shift_function : shift_function_type;
|
71 |
|
|
variable mult_function : mult_function_type;
|
72 |
|
|
variable a_source : a_source_type;
|
73 |
|
|
variable b_source : b_source_type;
|
74 |
|
|
variable c_source : c_source_type;
|
75 |
|
|
variable pc_source : pc_source_type;
|
76 |
|
|
variable branch_function: branch_function_type;
|
77 |
|
|
variable mem_source : mem_source_type;
|
78 |
|
|
begin
|
79 |
|
|
alu_function := alu_nothing;
|
80 |
|
|
shift_function := shift_nothing;
|
81 |
|
|
mult_function := mult_nothing;
|
82 |
|
|
a_source := a_from_reg_source;
|
83 |
|
|
b_source := b_from_reg_target;
|
84 |
|
|
c_source := c_from_null;
|
85 |
|
|
pc_source := from_inc4;
|
86 |
|
|
branch_function := branch_eq;
|
87 |
61 |
rhoads |
mem_source := mem_fetch;
|
88 |
2 |
rhoads |
op := opcode(31 downto 26);
|
89 |
|
|
rs := '0' & opcode(25 downto 21);
|
90 |
|
|
rt := '0' & opcode(20 downto 16);
|
91 |
|
|
rtx := opcode(20 downto 16);
|
92 |
|
|
rd := '0' & opcode(15 downto 11);
|
93 |
|
|
func := opcode(5 downto 0);
|
94 |
|
|
imm := opcode(15 downto 0);
|
95 |
|
|
|
96 |
|
|
case op is
|
97 |
46 |
rhoads |
when "000000" => --SPECIAL
|
98 |
2 |
rhoads |
case func is
|
99 |
46 |
rhoads |
when "000000" => --SLL r[rd]=r[rt]<<re;
|
100 |
2 |
rhoads |
a_source := a_from_imm10_6;
|
101 |
|
|
c_source := c_from_shift;
|
102 |
|
|
shift_function := shift_left_unsigned;
|
103 |
46 |
rhoads |
when "000010" => --SRL r[rd]=u[rt]>>re;
|
104 |
2 |
rhoads |
a_source := a_from_imm10_6;
|
105 |
|
|
c_source := c_from_shift;
|
106 |
|
|
shift_function := shift_right_unsigned;
|
107 |
46 |
rhoads |
when "000011" => --SRA r[rd]=r[rt]>>re;
|
108 |
2 |
rhoads |
a_source := a_from_imm10_6;
|
109 |
|
|
c_source := c_from_shift;
|
110 |
|
|
shift_function := shift_right_signed;
|
111 |
46 |
rhoads |
when "000100" => --SLLV r[rd]=r[rt]<<r[rs];
|
112 |
2 |
rhoads |
c_source := c_from_shift;
|
113 |
|
|
shift_function := shift_left_unsigned;
|
114 |
46 |
rhoads |
when "000110" => --SRLV r[rd]=u[rt]>>r[rs];
|
115 |
2 |
rhoads |
c_source := c_from_shift;
|
116 |
|
|
shift_function := shift_right_unsigned;
|
117 |
46 |
rhoads |
when "000111" => --SRAV r[rd]=r[rt]>>r[rs];
|
118 |
2 |
rhoads |
c_source := c_from_shift;
|
119 |
|
|
shift_function := shift_right_signed;
|
120 |
46 |
rhoads |
when "001000" => --JR s->pc_next=r[rs];
|
121 |
2 |
rhoads |
pc_source := from_branch;
|
122 |
|
|
alu_function := alu_add;
|
123 |
|
|
branch_function := branch_yes;
|
124 |
46 |
rhoads |
when "001001" => --JALR r[rd]=s->pc_next; s->pc_next=r[rs];
|
125 |
6 |
rhoads |
c_source := c_from_pc_plus4;
|
126 |
2 |
rhoads |
pc_source := from_branch;
|
127 |
|
|
alu_function := alu_add;
|
128 |
|
|
branch_function := branch_yes;
|
129 |
46 |
rhoads |
when "001010" => --MOVZ if(!r[rt]) r[rd]=r[rs]; /*IV*/
|
130 |
2 |
rhoads |
-- c_source := c_from_reg_source_eqz;
|
131 |
46 |
rhoads |
when "001011" => --MOVN if(r[rt]) r[rd]=r[rs]; /*IV*/
|
132 |
2 |
rhoads |
-- c_source := from_reg_source_nez;
|
133 |
46 |
rhoads |
when "001100" => --SYSCALL
|
134 |
2 |
rhoads |
-- if(r[4]==0) printf("0x%8.8lx ",r[5]);
|
135 |
46 |
rhoads |
when "001101" => --BREAK s->wakeup=1;
|
136 |
|
|
when "001111" => --SYNC s->wakeup=1;
|
137 |
|
|
when "010000" => --MFHI r[rd]=s->hi;
|
138 |
2 |
rhoads |
c_source := c_from_mult;
|
139 |
|
|
mult_function := mult_read_hi;
|
140 |
46 |
rhoads |
when "010001" => --FTHI s->hi=r[rs];
|
141 |
2 |
rhoads |
mult_function := mult_write_hi;
|
142 |
46 |
rhoads |
when "010010" => --MFLO r[rd]=s->lo;
|
143 |
2 |
rhoads |
c_source := c_from_mult;
|
144 |
|
|
mult_function := mult_read_lo;
|
145 |
46 |
rhoads |
when "010011" => --MTLO s->lo=r[rs];
|
146 |
2 |
rhoads |
mult_function := mult_write_lo;
|
147 |
46 |
rhoads |
when "011000" => --MULT s->lo=r[rs]*r[rt]; s->hi=0;
|
148 |
44 |
rhoads |
mult_function := mult_signed_mult;
|
149 |
46 |
rhoads |
when "011001" => --MULTU s->lo=r[rs]*r[rt]; s->hi=0;
|
150 |
2 |
rhoads |
mult_function := mult_mult;
|
151 |
46 |
rhoads |
when "011010" => --DIV s->lo=r[rs]/r[rt]; s->hi=r[rs]%r[rt];
|
152 |
2 |
rhoads |
mult_function := mult_signed_divide;
|
153 |
46 |
rhoads |
when "011011" => --DIVU s->lo=r[rs]/r[rt]; s->hi=r[rs]%r[rt];
|
154 |
2 |
rhoads |
mult_function := mult_divide;
|
155 |
46 |
rhoads |
when "100000" => --ADD r[rd]=r[rs]+r[rt];
|
156 |
2 |
rhoads |
c_source := c_from_alu;
|
157 |
|
|
alu_function := alu_add;
|
158 |
46 |
rhoads |
when "100001" => --ADDU r[rd]=r[rs]+r[rt];
|
159 |
2 |
rhoads |
c_source := c_from_alu;
|
160 |
|
|
alu_function := alu_add;
|
161 |
46 |
rhoads |
when "100010" => --SUB r[rd]=r[rs]-r[rt];
|
162 |
2 |
rhoads |
c_source := c_from_alu;
|
163 |
|
|
alu_function := alu_subtract;
|
164 |
46 |
rhoads |
when "100011" => --SUBU r[rd]=r[rs]-r[rt];
|
165 |
2 |
rhoads |
c_source := c_from_alu;
|
166 |
|
|
alu_function := alu_subtract;
|
167 |
46 |
rhoads |
when "100100" => --AND r[rd]=r[rs]&r[rt];
|
168 |
2 |
rhoads |
c_source := c_from_alu;
|
169 |
|
|
alu_function := alu_and;
|
170 |
46 |
rhoads |
when "100101" => --OR r[rd]=r[rs]|r[rt];
|
171 |
2 |
rhoads |
c_source := c_from_alu;
|
172 |
|
|
alu_function := alu_or;
|
173 |
46 |
rhoads |
when "100110" => --XOR r[rd]=r[rs]^r[rt];
|
174 |
2 |
rhoads |
c_source := c_from_alu;
|
175 |
|
|
alu_function := alu_xor;
|
176 |
46 |
rhoads |
when "100111" => --NOR r[rd]=~(r[rs]|r[rt]);
|
177 |
2 |
rhoads |
c_source := c_from_alu;
|
178 |
|
|
alu_function := alu_nor;
|
179 |
46 |
rhoads |
when "101010" => --SLT r[rd]=r[rs]<r[rt];
|
180 |
2 |
rhoads |
c_source := c_from_alu;
|
181 |
|
|
alu_function := alu_less_than_signed;
|
182 |
46 |
rhoads |
when "101011" => --SLTU r[rd]=u[rs]<u[rt];
|
183 |
2 |
rhoads |
c_source := c_from_alu;
|
184 |
|
|
alu_function := alu_less_than;
|
185 |
46 |
rhoads |
when "101101" => --DADDU r[rd]=r[rs]+u[rt];
|
186 |
2 |
rhoads |
c_source := c_from_alu;
|
187 |
|
|
alu_function := alu_add;
|
188 |
46 |
rhoads |
when "110001" => --TGEU
|
189 |
|
|
when "110010" => --TLT
|
190 |
|
|
when "110011" => --TLTU
|
191 |
|
|
when "110100" => --TEQ
|
192 |
|
|
when "110110" => --TNE
|
193 |
2 |
rhoads |
when others =>
|
194 |
|
|
end case;
|
195 |
46 |
rhoads |
when "000001" => --REGIMM
|
196 |
2 |
rhoads |
rt := "000000";
|
197 |
|
|
rd := "011111";
|
198 |
|
|
a_source := a_from_pc;
|
199 |
|
|
b_source := b_from_immX4;
|
200 |
|
|
alu_function := alu_add;
|
201 |
|
|
pc_source := from_branch;
|
202 |
|
|
branch_function := branch_gtz;
|
203 |
|
|
--if(test) pc=pc+imm*4
|
204 |
|
|
case rtx is
|
205 |
46 |
rhoads |
when "10000" => --BLTZAL r[31]=s->pc_next; branch=r[rs]<0;
|
206 |
6 |
rhoads |
c_source := c_from_pc_plus4;
|
207 |
2 |
rhoads |
branch_function := branch_ltz;
|
208 |
46 |
rhoads |
when "00000" => --BLTZ branch=r[rs]<0;
|
209 |
2 |
rhoads |
branch_function := branch_ltz;
|
210 |
46 |
rhoads |
when "10001" => --BGEZAL r[31]=s->pc_next; branch=r[rs]>=0;
|
211 |
6 |
rhoads |
c_source := c_from_pc_plus4;
|
212 |
2 |
rhoads |
branch_function := branch_gez;
|
213 |
46 |
rhoads |
when "00001" => --BGEZ branch=r[rs]>=0;
|
214 |
2 |
rhoads |
branch_function := branch_gez;
|
215 |
46 |
rhoads |
when "10010" => --BLTZALL r[31]=s->pc_next; lbranch=r[rs]<0;
|
216 |
6 |
rhoads |
c_source := c_from_pc_plus4;
|
217 |
2 |
rhoads |
pc_source := from_lbranch;
|
218 |
|
|
branch_function := branch_ltz;
|
219 |
46 |
rhoads |
when "00010" => --BLTZL lbranch=r[rs]<0;
|
220 |
2 |
rhoads |
pc_source := from_lbranch;
|
221 |
|
|
branch_function := branch_ltz;
|
222 |
46 |
rhoads |
when "10011" => --BGEZALL r[31]=s->pc_next; lbranch=r[rs]>=0;
|
223 |
6 |
rhoads |
c_source := c_from_pc_plus4;
|
224 |
2 |
rhoads |
pc_source := from_lbranch;
|
225 |
|
|
branch_function := branch_gez;
|
226 |
46 |
rhoads |
when "00011" => --BGEZL lbranch=r[rs]>=0;
|
227 |
2 |
rhoads |
pc_source := from_lbranch;
|
228 |
|
|
branch_function := branch_gez;
|
229 |
|
|
when others =>
|
230 |
|
|
end case;
|
231 |
46 |
rhoads |
when "000011" => --JAL r[31]=s->pc_next; s->pc_next=(s->pc&0xf0000000)|target;
|
232 |
6 |
rhoads |
c_source := c_from_pc_plus4;
|
233 |
2 |
rhoads |
rd := "011111";
|
234 |
|
|
pc_source := from_opcode25_0;
|
235 |
46 |
rhoads |
when "000010" => --J s->pc_next=(s->pc&0xf0000000)|target;
|
236 |
2 |
rhoads |
pc_source := from_opcode25_0;
|
237 |
46 |
rhoads |
when "000100" => --BEQ branch=r[rs]==r[rt];
|
238 |
2 |
rhoads |
a_source := a_from_pc;
|
239 |
|
|
b_source := b_from_immX4;
|
240 |
|
|
alu_function := alu_add;
|
241 |
|
|
pc_source := from_branch;
|
242 |
|
|
branch_function := branch_eq;
|
243 |
46 |
rhoads |
when "000101" => --BNE branch=r[rs]!=r[rt];
|
244 |
2 |
rhoads |
a_source := a_from_pc;
|
245 |
|
|
b_source := b_from_immX4;
|
246 |
|
|
alu_function := alu_add;
|
247 |
|
|
pc_source := from_branch;
|
248 |
|
|
branch_function := branch_ne;
|
249 |
46 |
rhoads |
when "000110" => --BLEZ branch=r[rs]<=0;
|
250 |
2 |
rhoads |
a_source := a_from_pc;
|
251 |
|
|
b_source := b_from_immX4;
|
252 |
|
|
alu_function := alu_add;
|
253 |
|
|
pc_source := from_branch;
|
254 |
17 |
rhoads |
branch_function := branch_lez;
|
255 |
46 |
rhoads |
when "000111" => --BGTZ branch=r[rs]>0;
|
256 |
2 |
rhoads |
a_source := a_from_pc;
|
257 |
|
|
b_source := b_from_immX4;
|
258 |
|
|
alu_function := alu_add;
|
259 |
|
|
pc_source := from_branch;
|
260 |
|
|
branch_function := branch_gtz;
|
261 |
46 |
rhoads |
when "001000" => --ADDI r[rt]=r[rs]+(short)imm;
|
262 |
2 |
rhoads |
b_source := b_from_signed_imm;
|
263 |
|
|
c_source := c_from_alu;
|
264 |
|
|
rd := rt;
|
265 |
|
|
alu_function := alu_add;
|
266 |
46 |
rhoads |
when "001001" => --ADDIU u[rt]=u[rs]+(short)imm;
|
267 |
2 |
rhoads |
b_source := b_from_signed_imm;
|
268 |
|
|
c_source := c_from_alu;
|
269 |
|
|
rd := rt;
|
270 |
|
|
alu_function := alu_add;
|
271 |
46 |
rhoads |
when "001010" => --SLTI r[rt]=r[rs]<(short)imm;
|
272 |
2 |
rhoads |
b_source := b_from_signed_imm;
|
273 |
|
|
c_source := c_from_alu;
|
274 |
|
|
rd := rt;
|
275 |
113 |
rhoads |
alu_function := alu_less_than_signed;
|
276 |
46 |
rhoads |
when "001011" => --SLTIU u[rt]=u[rs]<(unsigned long)(short)imm;
|
277 |
2 |
rhoads |
b_source := b_from_imm;
|
278 |
|
|
c_source := c_from_alu;
|
279 |
|
|
rd := rt;
|
280 |
|
|
alu_function := alu_less_than;
|
281 |
46 |
rhoads |
when "001100" => --ANDI r[rt]=r[rs]&imm;
|
282 |
2 |
rhoads |
b_source := b_from_imm;
|
283 |
|
|
c_source := c_from_alu;
|
284 |
|
|
rd := rt;
|
285 |
|
|
alu_function := alu_and;
|
286 |
46 |
rhoads |
when "001101" => --ORI r[rt]=r[rs]|imm;
|
287 |
2 |
rhoads |
b_source := b_from_imm;
|
288 |
|
|
c_source := c_from_alu;
|
289 |
|
|
rd := rt;
|
290 |
|
|
alu_function := alu_or;
|
291 |
46 |
rhoads |
when "001110" => --XORI r[rt]=r[rs]^imm;
|
292 |
2 |
rhoads |
b_source := b_from_imm;
|
293 |
|
|
c_source := c_from_alu;
|
294 |
|
|
rd := rt;
|
295 |
|
|
alu_function := alu_xor;
|
296 |
46 |
rhoads |
when "001111" => --LUI r[rt]=(imm<<16);
|
297 |
2 |
rhoads |
c_source := c_from_imm_shift16;
|
298 |
|
|
rd := rt;
|
299 |
46 |
rhoads |
when "010000" => --COP0
|
300 |
2 |
rhoads |
alu_function := alu_or;
|
301 |
|
|
c_source := c_from_alu;
|
302 |
|
|
if opcode(23) = '0' then --move from CP0
|
303 |
|
|
rs := '1' & opcode(15 downto 11);
|
304 |
|
|
rt := "000000";
|
305 |
|
|
rd := '0' & opcode(20 downto 16);
|
306 |
|
|
else --move to CP0
|
307 |
|
|
rs := "000000";
|
308 |
|
|
rd(5) := '1';
|
309 |
|
|
end if;
|
310 |
46 |
rhoads |
when "010001" => --COP1
|
311 |
|
|
when "010010" => --COP2
|
312 |
|
|
when "010011" => --COP3
|
313 |
|
|
when "010100" => --BEQL lbranch=r[rs]==r[rt];
|
314 |
2 |
rhoads |
a_source := a_from_pc;
|
315 |
|
|
b_source := b_from_immX4;
|
316 |
|
|
alu_function := alu_add;
|
317 |
|
|
pc_source := from_lbranch;
|
318 |
|
|
branch_function := branch_eq;
|
319 |
46 |
rhoads |
when "010101" => --BNEL lbranch=r[rs]!=r[rt];
|
320 |
2 |
rhoads |
a_source := a_from_pc;
|
321 |
|
|
b_source := b_from_immX4;
|
322 |
|
|
alu_function := alu_add;
|
323 |
|
|
pc_source := from_lbranch;
|
324 |
|
|
branch_function := branch_ne;
|
325 |
46 |
rhoads |
when "010110" => --BLEZL lbranch=r[rs]<=0;
|
326 |
2 |
rhoads |
a_source := a_from_pc;
|
327 |
|
|
b_source := b_from_immX4;
|
328 |
|
|
alu_function := alu_add;
|
329 |
|
|
pc_source := from_lbranch;
|
330 |
|
|
branch_function := branch_lez;
|
331 |
46 |
rhoads |
when "010111" => --BGTZL lbranch=r[rs]>0;
|
332 |
2 |
rhoads |
a_source := a_from_pc;
|
333 |
|
|
b_source := b_from_immX4;
|
334 |
|
|
alu_function := alu_add;
|
335 |
|
|
pc_source := from_lbranch;
|
336 |
|
|
branch_function := branch_gtz;
|
337 |
46 |
rhoads |
when "100000" => --LB r[rt]=*(signed char*)ptr;
|
338 |
17 |
rhoads |
a_source := a_from_reg_source;
|
339 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
340 |
17 |
rhoads |
alu_function := alu_add;
|
341 |
|
|
rd := rt;
|
342 |
2 |
rhoads |
c_source := c_from_memory;
|
343 |
17 |
rhoads |
mem_source := mem_read8s; --address=(short)imm+r[rs];
|
344 |
46 |
rhoads |
when "100001" => --LH r[rt]=*(signed short*)ptr;
|
345 |
17 |
rhoads |
a_source := a_from_reg_source;
|
346 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
347 |
17 |
rhoads |
alu_function := alu_add;
|
348 |
|
|
rd := rt;
|
349 |
2 |
rhoads |
c_source := c_from_memory;
|
350 |
17 |
rhoads |
mem_source := mem_read16s; --address=(short)imm+r[rs];
|
351 |
46 |
rhoads |
when "100010" => --LWL //Not Implemented
|
352 |
17 |
rhoads |
a_source := a_from_reg_source;
|
353 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
354 |
17 |
rhoads |
alu_function := alu_add;
|
355 |
|
|
rd := rt;
|
356 |
|
|
c_source := c_from_memory;
|
357 |
|
|
mem_source := mem_read32;
|
358 |
46 |
rhoads |
when "100011" => --LW r[rt]=*(long*)ptr;
|
359 |
17 |
rhoads |
a_source := a_from_reg_source;
|
360 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
361 |
17 |
rhoads |
alu_function := alu_add;
|
362 |
|
|
rd := rt;
|
363 |
2 |
rhoads |
c_source := c_from_memory;
|
364 |
17 |
rhoads |
mem_source := mem_read32;
|
365 |
46 |
rhoads |
when "100100" => --LBU r[rt]=*(unsigned char*)ptr;
|
366 |
17 |
rhoads |
a_source := a_from_reg_source;
|
367 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
368 |
17 |
rhoads |
alu_function := alu_add;
|
369 |
|
|
rd := rt;
|
370 |
2 |
rhoads |
c_source := c_from_memory;
|
371 |
17 |
rhoads |
mem_source := mem_read8; --address=(short)imm+r[rs];
|
372 |
46 |
rhoads |
when "100101" => --LHU r[rt]=*(unsigned short*)ptr;
|
373 |
17 |
rhoads |
a_source := a_from_reg_source;
|
374 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
375 |
17 |
rhoads |
alu_function := alu_add;
|
376 |
|
|
rd := rt;
|
377 |
2 |
rhoads |
c_source := c_from_memory;
|
378 |
17 |
rhoads |
mem_source := mem_read16; --address=(short)imm+r[rs];
|
379 |
46 |
rhoads |
when "100110" => --LWR //Not Implemented
|
380 |
|
|
when "101000" => --SB *(char*)ptr=(char)r[rt];
|
381 |
17 |
rhoads |
a_source := a_from_reg_source;
|
382 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
383 |
17 |
rhoads |
alu_function := alu_add;
|
384 |
|
|
mem_source := mem_write8; --address=(short)imm+r[rs];
|
385 |
46 |
rhoads |
when "101001" => --SH *(short*)ptr=(short)r[rt];
|
386 |
17 |
rhoads |
a_source := a_from_reg_source;
|
387 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
388 |
17 |
rhoads |
alu_function := alu_add;
|
389 |
|
|
mem_source := mem_write16;
|
390 |
46 |
rhoads |
when "101010" => --SWL //Not Implemented
|
391 |
17 |
rhoads |
a_source := a_from_reg_source;
|
392 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
393 |
17 |
rhoads |
alu_function := alu_add;
|
394 |
|
|
mem_source := mem_write32; --address=(short)imm+r[rs];
|
395 |
46 |
rhoads |
when "101011" => --SW *(long*)ptr=r[rt];
|
396 |
17 |
rhoads |
a_source := a_from_reg_source;
|
397 |
113 |
rhoads |
b_source := b_from_signed_imm;
|
398 |
17 |
rhoads |
alu_function := alu_add;
|
399 |
|
|
mem_source := mem_write32; --address=(short)imm+r[rs];
|
400 |
46 |
rhoads |
when "101110" => --SWR //Not Implemented
|
401 |
|
|
when "101111" => --CACHE
|
402 |
|
|
when "110000" => --LL r[rt]=*(long*)ptr;
|
403 |
|
|
when "110001" => --LWC1
|
404 |
|
|
when "110010" => --LWC2
|
405 |
|
|
when "110011" => --LWC3
|
406 |
|
|
when "110101" => --LDC1
|
407 |
|
|
when "110110" => --LDC2
|
408 |
|
|
when "110111" => --LDC3
|
409 |
|
|
when "111000" => --SC *(long*)ptr=r[rt]; r[rt]=1;
|
410 |
|
|
when "111001" => --SWC1
|
411 |
|
|
when "111010" => --SWC2
|
412 |
|
|
when "111011" => --SWC3
|
413 |
|
|
when "111101" => --SDC1
|
414 |
|
|
when "111110" => --SDC2
|
415 |
|
|
when "111111" => --SDC3
|
416 |
2 |
rhoads |
when others =>
|
417 |
|
|
end case;
|
418 |
|
|
|
419 |
71 |
rhoads |
if c_source = c_from_null then
|
420 |
2 |
rhoads |
rd := "000000";
|
421 |
|
|
end if;
|
422 |
|
|
|
423 |
|
|
if intr_signal = '1' then
|
424 |
|
|
rs := "111111"; --interrupt vector
|
425 |
|
|
rt := "000000";
|
426 |
6 |
rhoads |
rd := "101110"; --save PC in EPC
|
427 |
|
|
alu_function := alu_or;
|
428 |
|
|
shift_function := shift_nothing;
|
429 |
|
|
mult_function := mult_nothing;
|
430 |
|
|
branch_function := branch_yes;
|
431 |
2 |
rhoads |
a_source := a_from_reg_source;
|
432 |
|
|
b_source := b_from_reg_target;
|
433 |
6 |
rhoads |
c_source := c_from_pc;
|
434 |
|
|
pc_source := from_lbranch;
|
435 |
61 |
rhoads |
mem_source := mem_fetch;
|
436 |
2 |
rhoads |
end if;
|
437 |
|
|
|
438 |
|
|
rs_index <= rs;
|
439 |
|
|
rt_index <= rt;
|
440 |
|
|
rd_index <= rd;
|
441 |
|
|
imm_out <= imm;
|
442 |
|
|
alu_func <= alu_function;
|
443 |
|
|
shift_func <= shift_function;
|
444 |
|
|
mult_func <= mult_function;
|
445 |
|
|
branch_func <= branch_function;
|
446 |
|
|
a_source_out <= a_source;
|
447 |
|
|
b_source_out <= b_source;
|
448 |
|
|
c_source_out <= c_source;
|
449 |
|
|
pc_source_out <= pc_source;
|
450 |
|
|
mem_source_out <= mem_source;
|
451 |
|
|
|
452 |
|
|
end process;
|
453 |
|
|
|
454 |
|
|
end; --logic
|
455 |
|
|
|