Professional Documents
Culture Documents
Bernacki Routhier Final Report Lab 4
Bernacki Routhier Final Report Lab 4
1. Team Members
Dakota Bernacki
Noah Routhier
Date: 11/19/20
“On my honor, I have neither given nor received unauthorized aid on this assignment”
Dakota Bernacki
“On his honor, I have neither given nor received unauthorized aid on this assignment”
Noah Routhier
EGRE 426 - Lab 4 - Page 2
2. Implementation Diagram
EGRE 426 - Lab 4 - Page 3
3. Datapath
Datapath Components
Program Counter:
Inputs:
PC_ADDR --Updated Program Counter
PC_rst --When asserted hi resets PC to 0
clk --System clock
Outputs:
PC --The current value of the Program Counter
A simple, 11bit-wide D type register, PC holds the current value of the program
counter. On every rising edge of the clock, it is updated with the new program
counter value.
Instruction Memory:
Inputs:
PC --The current value of the Program Counter
prog_flash --The instruction to be stored in the Instruction Memory
ins_wr --When asserted hi allows the memory to be programmed
ins_rst --When asserted hi resets all instruction location values to 0
clk --System clock
Outputs:
Instruction --The current instruction as pointed to by the Program Counter
An assembly of 256 16bit-wide D type registers, the instruction memory holds the
16bit instructions to be executed. It is indexed by the current value of the program
counter and updates its output on every rising edge of the clock.
Control:
Inputs:
Instruction [15-11] --The Opcode of the instruction
Outputs:
ALU_func --The control Opcode for the ALU
I-type --The bit that indicates if an I-type instruction is being executed
reg_WR --The enable line for writing to the register
jump_ins --The indicator line for a jump instruction
data_WR --The enable line for writing to the data memory
mem_to_reg --The select bit for choosing the output of the ALU or data memory
Control interprets the upper 5 bits of the current instruction and generates the
control bits and ALU operation opcode for said instruction. It is composed of
EGRE 426 - Lab 4 - Page 4
Register Memory:
Inputs:
Instruction[4-2] --The address of the RD register
Instruction[7-5] --The address of the RT register
Instruction[10-8] --The address of the RS register
result --The result of the instruction [if applicable]
reg_rst --When asserted hi resets all register location values to 0
reg_WR --When asserted hi allows value on result to be stored
clk --System clock
Outputs:
A --The contents of RS
operand2 --The contents of RT
An assembly of 8 16bit-wide D type registers, the register memory holds the current
values being operated on. It is indexed by the current values of the RD, RS, and RT
segments of the instruction. And it updates its output on every rising edge of the
clock.
ALU:
Inputs:
A --The value of RS
B --The value of RD or the extended immediate value
ALU_func --The operation the ALU is to carry out
Outputs:
ALU_result --The result of the ALU operation
branch_true --The indicator bit for a branch instruction
Data Memory:
Inputs:
dat_addr --The address at which to store mem_data at or output data_read
mem_data --The data to be stored
data_WR --When asserted hi allows the memory to be programmed
data_rst --When asserted hi resets all memory location values to 0
clk --System clock
Outputs:
data_read --The data to be output
An assembly of 256 16bit-wide D type registers, the data memory holds the values
calculated or needed by the program. It is indexed by the output of the ALU and
receives the value of operand2 [RT]. It updates its output on every rising edge of the
clock.
EGRE 426 - Lab 4 - Page 6
4. ALU Control
ALU Control Bits:
The ALU is controlled by a bitstring, of length four, which indexes its switch
statement. Of the 16 possible instructions, only 14 are used. For each instruction,
the bitstring is generated by the control unit and sent to the ALU.
ALU Functions:
1. Addition
Adds input A to input B. No carry is accounted for.
2. Subtraction
Subtracts input B from input A. No overflow accounted for.
3. And
Performs bitwise AND on input A and B.
4. Or
Performs bitwise OR on input A and B.
5. Exclusive Or
Performs bitwise XOR on input A and B.
6. Shift Left Logical
Shifts input A left by the shift amount specified by input B.
7. Shift Right Logical
Shifts input A right by the shift amount specified by input B.
8. Shift Right Arithmetic
Shifts input A right by the shift amount specified by input B; preserves the sign bit of
A during the shift.
9. Set Less Than
If input A is less than input B, the output equals 1. Else the output equals 0.
10. Branch Equal
If input A equals input B set branch_true equal to 1.
11. Branch Less Than
If input A is less than input B set branch_true equal to 1.
12. Branch Less Than or Equal
If input A is less than or equal to input B set branch_true equal to 1.
13. Branch Greater Than
If input A is greater than input B set branch_true equal to 1.
14. Branch Greater Than or Equal
If input A is greater than or equal to input B set branch_true equal to 1.
EGRE 426 - Lab 4 - Page 7
5. Control Unit
Describe the control unit and its inputs and outputs in details.
Control Unit:
The control unit is comprised of a switch statement, indexed by the upper five bits of
the current instruction. Of the 32 possible instructions, only 22 are used. Every time
a new instruction is received, the control unit interprets it and updates the ALU
control signal and the other control bits.
Outputs:
ALU_func
A bitstring of length four that determines the operation that the ALU
performs.
I-type
Set hi for all I-type instructions except branches. This signal controls which
values of the register are used for storing the result and in determining if the
2nd register output or the immediate value is used in the ALU’s calculation.
reg_WR
Set hi when the result of an instruction needs to be stored in the register.
jump_ins
Set hi when the result of an instruction needs to be stored in the register.
This happens only for jump instructions.
data_WR
Set hi when the result of an instruction needs to be stored in the data
memory. This happens only for store word instructions.
mem_to_reg
Set hi when the output of the data memory needs to be stored in the register.
This happens only for load word instructions.
EGRE 426 - Lab 4 - Page 8
Data Memory:
Address Hex Value Binary Value
0x010 0x0000 0000 0000 0000 0000
0x011 0x0000 0000 0000 0000 0000
0x012 0x0000 0000 0000 0000 0000
0x013 0x0000 0000 0000 0000 0000
0x014 0x0000 0000 0000 0000 0000
Others 0x0000 0000 0000 0000 0000
Register file:
Register Name Register # Hex Value Binary Value
n0 1 0x0000 0000 0000 0000 0000
s0 2 0x0000 0000 0000 0000 0000
s1 3 0x0000 0000 0000 0000 0000
s2 4 0x0000 0000 0000 0000 0000
t0 5 0x0000 0000 0000 0000 0000
t1 6 0x0000 0000 0000 0000 0000
t2 7 0x0000 0000 0000 0000 0000
t3 8 0x0000 0000 0000 0000 0000
EGRE 426 - Lab 4 - Page 9
Data Memory:
Address Hex Value Binary Value
0x010 0x0101 0000 0001 0000 0001
0x011 0x0110 0000 0001 00010000
0x012 0x0011 0000 0000 0001 0001
0x013 0x00F0 0000 0000 1111 0000
0x014 0x00FF 0000 0000 1111 1111
Others 0x0000 0000 0000 0000 0000
Register file:
Register Name Register # Hex Value Binary Value
n0 1 0x0000 0000 0000 0000 0000
s0 2 0x0000 0000 0000 0000 0000
s1 3 0x0000 0000 0000 0000 0000
s2 4 0x0000 0000 0000 0000 0000
t0 5 0x0000 0000 0000 0000 0000
t1 6 0x0000 0000 0000 0000 0000
t2 7 0x0000 0000 0000 0000 0000
t3 8 0x0000 0000 0000 0000 0000
EGRE 426 - Lab 4 - Page 10
Register file:
Register Name Register # Hex Value Binary Value
n0 1 0x0000 0000 0000 0000 0000
s0 2 0x0101 0000 0001 0000 0001
s1 3 0x0011 0000 0000 0001 0001
s2 4 0x0004 0000 0000 0000 0100
t0 5 0x0008 0000 0000 0000 1000
t1 6 0x1018 0001 0000 0001 1000
t2 7 0x000F 0000 0000 0000 1111
t3 8 0x00F0 0000 0000 1111 0000
Register file:
Register Name Register # Hex Value Binary Value
n0 1 0x0000 0000 0000 0000 0000
s0 2 0x0110 0000 0001 0001 0000
s1 3 0x0012 0000 0000 0001 0010
s2 4 0x0003 0000 0000 0000 0011
t0 5 0x0001 0000 0000 0000 0001
t1 6 0x1019 0001 0000 0001 1001
t2 7 0x000F 0000 0000 0000 1111
t3 8 0x00F0 0000 0000 1111 0000
EGRE 426 - Lab 4 - Page 11
Register file:
Register Name Register # Hex Value Binary Value
n0 1 0x0000 0000 0000 0000 0000
s0 2 0x0011 0000 0000 0001 0001
s1 3 0x0013 0000 0000 0001 0011
s2 4 0x0002 0000 0000 0000 0010
t0 5 0x0001 0000 0000 0000 0001
t1 6 0x1019 0001 0000 0001 1001
t2 7 0x003C 0000 0000 0011 1100
t3 8 0x00CC 0000 0000 1100 1100
Register file:
Register Name Register # Hex Value Binary Value
n0 1 0x0000 0000 0000 0000 0000
s0 2 0x00FF 0000 0000 1111 1111
s1 3 0x0015 0000 0000 0001 0101
s2 4 0x0000 0000 0000 0000 0000
t0 5 0x0001 0000 0000 0000 0001
t1 6 0x1019 0001 0000 0001 1001
t2 7 0x03C0 0000 0011 1100 0000
t3 8 0x03FC 0000 0011 1111 1100
EGRE 426 - Lab 4 - Page 13
This data is taken directly from the output file [cpu_out.txt] that is generated by our testbench. Said
file has been included in the appendix of this document and the zip file of the code.
8. Bonus Materials
Thus far, the only modifications made to the design for this purpose was to increase the
opcode size from 4 to 5 bits [to support the additional instructions] and to have the ALU not
set the I-type signal for the branch instructions though they are I-type. [to support more
than the single required branch type].
We added four new branch instructions which are not in the standard instruction set for
MIPS:
1. Branch greater than or equal to
2. Branch greater than
3. Branch less than or equal to
4. branch less than
We programmed an excel sheet to translate our mips assembly code into machine code,
which we used to compile our instructions
EGRE 426 - Lab 4 - Page 14
9. Discussion
Simulation Program Optimization:
Originally our simulator required a number of NOPs inserted, after the instruction to be
programmed, equal in length to the total number of instructions executed by the program.
This was quickly changed to only require two additional commands. The first to reset the
registers and PC and the second to set all testbench outputs to 0.
Non-Functioning Components:
NONE
The design is fully functional and performs as expected.
Additional Discussion:
Our testbench outputs the data from the register file and data memory to a text file
cpu_out.txt. (see appendix G)
The CPU was programmed via a .txt file. (see appendix H)
Appendix A consists of the test waveforms of the CPU running the example program.
Appendix A
Example program output testwaves
Whole program: [from programming to completion]
Start of program:
EGRE 426 - Lab 4 - Page 16
End of loop 1:
End of loop 2:
EGRE 426 - Lab 4 - Page 17
End of loop 3:
End of loop 4:
EGRE 426 - Lab 4 - Page 18
Appendix B
top_lvl_tst.vhd:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use STD.textio.all;
use ieee.std_logic_textio.all;
-- Maximum delay for the DUT it's bit_vector size and the number of test cases
constant MAX_DELAY : time := 20 ms;
constant Memory_size : integer := 16;
constant PC_size : integer := 11;
constant ALU_SIZE : integer := 4;
--DUT signals
--Input
signal prog_flash : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal ins_WR : STD_LOGIC;
signal data_flash : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal data_fash_addr : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal prog_data_WR : STD_LOGIC;
signal CLK_sig : STD_LOGIC := '0';
signal ins_rst : STD_LOGIC;
signal reg_rst : STD_LOGIC;
signal data_rst : STD_LOGIC;
signal PC_rst : STD_LOGIC;
--Output
signal t0_reg_out : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal t1_reg_out : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal t2_reg_out : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal t3_reg_out : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal dat_addr16 : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal dat_addr17 : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal dat_addr18 : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal dat_addr19 : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal dat_addr20 : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal ins_out_tb : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
signal PC_out_tb : STD_LOGIC_VECTOR(11-1 downto 0);
EGRE 426 - Lab 4 - Page 20
--File open
file file_ins_mem : text;
file file_cpu_out : text;
begin
--Input generator
stimulus : process
variable instruction : line;
variable SPACE : character;
variable pf_tmp : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
variable ins_WR_tmp : STD_LOGIC;
variable df_tmp : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
variable dfa_tmp : STD_LOGIC_VECTOR(Memory_size-1 downto 0);
variable data_WR_tmp : STD_LOGIC;
variable ins_rst_tmp : STD_LOGIC;
variable reg_rst_tmp : STD_LOGIC;
variable data_rst_tmp: STD_LOGIC;
variable PC_rst_tmp : STD_LOGIC;
begin
file_open(file_ins_mem, "instruction_memory.txt", read_mode);
wait;
file_close(file_cpu_out); --Stop the process to avoid an infinite loop
end process stimulus;
-- Process monitor
monitor : process
variable count : integer := 0;
variable data : line;
variable newline : string(1 to 1) := " ";
variable t0 : string(1 to 4) := "t0: ";
variable t1 : string(1 to 4) := "t1: ";
variable t2 : string(1 to 4) := "t2: ";
variable t3 : string(1 to 4) := "t3: ";
variable mem16 : string(1 to 4) := "16: ";
variable mem17 : string(1 to 4) := "17: ";
variable mem18 : string(1 to 4) := "18: ";
variable mem19 : string(1 to 4) := "19: ";
EGRE 426 - Lab 4 - Page 22
begin
file_open(file_cpu_out, "cpu_out.txt", write_mode);
--Writes to file at power up, after programming, and after each loop
IF ins_out_tb = "1111100000001100" OR PC_out_tb = "00000000000" THEN
write(data, clk_cyc);
write(data, count);
writeline(file_cpu_out, data);
write(data, t0);
write(data, t0_reg_out);
writeline(file_cpu_out, data);
write(data, t1);
write(data, t1_reg_out);
writeline(file_cpu_out, data);
write(data, t2);
write(data, t2_reg_out);
writeline(file_cpu_out, data);
write(data, t3);
write(data, t3_reg_out);
writeline(file_cpu_out, data);
write(data, newline);
writeline(file_cpu_out, data);
write(data, mem16);
write(data, dat_addr16);
writeline(file_cpu_out, data);
write(data, mem17);
write(data, dat_addr17);
writeline(file_cpu_out, data);
write(data, mem18);
write(data, dat_addr18);
writeline(file_cpu_out, data);
write(data, mem19);
write(data, dat_addr19);
writeline(file_cpu_out, data);
EGRE 426 - Lab 4 - Page 23
write(data, mem20);
write(data, dat_addr20);
writeline(file_cpu_out, data);
write(data, newline);
writeline(file_cpu_out, data);
write(data, newline);
writeline(file_cpu_out, data);
ELSE
--NOTHING
END IF;
count := count + 1; --Increments # of clk ticks
end loop;
file_close(file_cpu_out);
nd process monitor;
e
end Behavioral;
EGRE 426 - Lab 4 - Page 24
Appendix C
top_lvl.vhd:
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.numeric_std.ALL;
END top_level;
signal ins_mem_out : ins_mem_file := (others=>(others=>'0')); --Temp for instruction output
EGRE 426 - Lab 4 - Page 25
signal ins_WR_Index : ins_index_addr := (others=>'0'); --Temp for instruction enable
signal reg_mem_out : reg_mem_file := (others=>(others=>'0')); --Temp for reg outputs
signal reg_WR_Index : reg_index_addr := (others=>'0'); --Temp for reg enable
signal data_mem_out : data_mem_file := (others=>(others=>'0')); --Temp for data memory output
signal data_WR_Index: data_index_addr := (others=>'0'); --Temp for data memory enable
begin
--COMPONENET INSTANTIATIONS
--ALU
ALU : ENTITY work.ALU(behavior)
GENERIC MAP(N => N)
PORT MAP(a => A, b => B, func => ALU_func, result => ALU_result, branch => branch_true);
- -Control Logic
Control : ENTITY work.control(behavior)
GENERIC MAP(N => N, ALU_size => ALU_size)
PORT MAP(Instruction => Instruction, ALU_func => ALU_func, I_type => I_type, reg_WR => reg_WR,
jump_ins => jump_ins, data_WR => data_WR, mem_to_reg => mem_to_reg);
--Memory Locations
Program_Counter : ENTITY work.D_Register(behavior) --Write ALWAYS enabled
EGRE 426 - Lab 4 - Page 26
--PROCESSES
--Instruction write and read
instructionwrite : PROCESS(prog_flash, ins_WR, ins_rst, clk) IS
BEGIN
ins_WR_Index(255 downto to_integer(unsigned(PC))+1) <= (others=>'0'); --set signals above desired index
ins_WR_Index(to_integer(unsigned(PC))) <= ins_WR; --set desired index
ins_WR_Index(to_integer(unsigned(PC))-1 downto 0) <= (others=>'0'); --set signals above desired index
END PROCESS;
--Instruction read
Instruction <= ins_mem_out(to_integer(unsigned(PC)));
--Register read
A <= reg_mem_out(to_integer(unsigned(Instruction(10 downto 8)))); --RS
operand2 <= reg_mem_out(to_integer(unsigned(Instruction(7 downto 5)))); --RT
EGRE 426 - Lab 4 - Page 27
--Data read
data_read <= data_mem_out(to_integer(unsigned(ALU_result(7 downto 0)))); --Change if you alter data
mem size
ext_imm(15 downto 0) <= "00000000000" & Instruction(4 downto 0); --Concatenate to extend
--ext_imm(4 downto 0) <= Instruction(4 downto 0);
--ext_imm(15 downto 5) <= "00000000000";
else
calc_addr <= Instruction(10 downto 0);
end if;
END PROCESS;
end structural;
EGRE 426 - Lab 4 - Page 29
Appendix D
ALU.vhd:
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.numeric_std.ALL;
BEGIN
process(a, b, func, logic_tmp, tmp) -- Sensitivity List includes internal signals
BEGIN
case func is
WHEN "0000" => --Add
tmp <= signed(a) + signed(b);
end case;
ND process;
E
END behavior;
EGRE 426 - Lab 4 - Page 32
Appendix E
control.vhd:
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.numeric_std.ALL;
BEGIN
parse : PROCESS(Instruction, parse_ins) IS
BEGIN
parse_ins <= Instruction(N-1 downto N-5); --Collect 5 upper bits of instruction
data_WR = '0';
<
mem_to_reg <= '0';
end case;
ND process;
E
END behavior;
EGRE 426 - Lab 4 - Page 37
Appendix F
D_register_scalable.vhd:
Library IEEE;
use IEEE.std_logic_1164.all;
begin
up_counter : process(clk, rst)
begin
if(rst = '1') then
q <= (others => '0');
elsif(rising_edge(clk) AND (en = '1')) then
q <= d;
end if;
end process up_counter;
end behavior;
EGRE 426 - Lab 4 - Page 38
Appendix G
cpu_out.txt
Clock Cycles: 0
t0: 0000000000000000
t1: 0000000000000000
t2: 0000000000000000
t3: 0000000000000000
16: 0000000000000000
17: 0000000000000000
18: 0000000000000000
19: 0000000000000000
20: 0000000000000000
Clock Cycles: 33
t0: 0000000000000000
t1: 0000000000000000
t2: 0000000000000000
t3: 0000000000000000
16: 0000000100000001
17: 0000000100010000
18: 0000000000010001
19: 0000000011110000
20: 0000000011111111
Clock Cycles: 60
t0: 0000000000001000
t1: 0001000000011000
t2: 0000000000001111
t3: 0000000011110000
16: 1111111100000000
17: 0000000100010000
18: 0000000000010001
19: 0000000011110000
20: 0000000011111111
Clock Cycles: 75
t0: 0000000000000001
t1: 0001000000011001
t2: 0000000000001111
t3: 0000000011110000
16: 1111111100000000
EGRE 426 - Lab 4 - Page 39
17: 1111111100000000
18: 0000000000010001
19: 0000000011110000
20: 0000000011111111
Clock Cycles: 88
t0: 0000000000000001
t1: 0001000000011001
t2: 0000000000111100
t3: 0000000011001100
16: 1111111100000000
17: 1111111100000000
18: 0000000011111111
19: 0000000011110000
20: 0000000011111111
16: 1111111100000000
17: 1111111100000000
18: 0000000011111111
19: 0000000011111111
20: 0000000011111111
16: 1111111100000000
17: 1111111100000000
18: 0000000011111111
19: 0000000011111111
20: 0000000011111111
EGRE 426 - Lab 4 - Page 40
Appendix H
instruction_memory.txt
Appendix I
Example code assembly:
100100000001
//ensure n0 is 0 0 0000 sl n0 n0 16 9010 0000
001110001000
$v0 = 0040hex; //64 1000000 1 0001 addi t0 n0 1 3881 0001
100101001000
2 0002 sl t0 t0 6 9486 0110
001110001010
$v1 = 1010hex; //4112 1000000010000 3 0003 addi t1 n0 1 38A1 0001
100101011010
4 0004 sl t1 t1 12 95AC 1100
001111011011
5 0005 addi t1 t1 16 3DB0 0000
001110001100
$v2 = 000Fhex; //15 1111 6 0006 addi t2 n0 15 38CF 1111
001110001110
$v3 = 00F0hex; //240 11110000 7 0007 addi t3 n0 15 38EF 1111
100101111110
8 0008 sl t3 t3 4 97E4 0100
001110000010
$t0 = 0000hex; //0 0 9 0009 addi s0 n0 0 3820 0000
001110000101
$a0 = 0010hex; //16 10000 10 000A addi s1 n0 16 3850 0000
001110000110
$a1 = 0005hex; //5 101 11 000B addi s2 n0 5 3865 0101
101010110110
$a1 = $a1 –1; //Decriment loop count 13 000D subi s2 s2 1 AB61 0001
011100100010
$t0 = Mem[$a0]; //Load a0 14 000E lw s0 s1 0 7220 0000
100100000000
//... 16 0010 sl n0 n0 8 9008 1000
EGRE 426 - Lab 4 - Page 42
101001001000
$v0 = $v0 ÷ 8; //v0/8 [SRL>>3] 18 0012 srl t0 t0 3 A483 0011
101010000000
//n0 is now 0x00FF 20 0014 subi n0 n0 1 A801 0001
100100000000
//n0 is now 0xFF00 21 0015 sl n0 n0 8 9008 1000
Mem[$a0] = 100000100000
FF00hex; //Store 0xFF00 in a0 22 0016 sw n0 0(s1) 8200 0000
111110000001
} 23 0017 j After F81D 1101
010010000000
else //IF a0,t0 <= 0x100 24 0018 Sneak beq n0 n0 Done 4807 0111
100101101100
$v2 = $v2 × 4; //v2*4 [SLL<<2] 25 0019 Else sl t2 t2 2 96C2 0010
101010000000
//n0 is now 0x00FF 27 001B subi n0 n0 1 A801 0001
Mem[$a0] = 100000100000
00FFhex; //Store 0x00FF in a0 28 001C sw n0 0(s1) 0 8200 0000
100100000001
//reset n0 register 30 001E sl n0 n0 16 9010 0000
111110000000
} 31 001F j Loop F80C 1100
Appendix J
Instruction types:
I-Type
Opcode rs rt immediate
5 3 3 5
J-Type
Opcode addr
5 11
Register layout:
Appendix K
Instruction set:
Fun Forma
Instruction Mnemonic Opcode c t Operation
set less than slt 00100 00 R slt rd, rs, rt; if rs < rt, rd = 1, else rd = 0
branch greater than bgt 01010 I bgt rt, rs; if rs > rt then PC = PC+1+imm
branch less than blt 01100 I blt rt, rs; if rs < rt then PC = PC+1+imm
set less than immediate slti 10001 I slti rt, rs, imm; if rs < imm , rt = 1, else rt = 0
shift right logical srl 10100 I srl rt, rs, imm; rt = rs >> imm
ALU instructions:
add 0000
subtract 0001
and 0010
or 0011
xor 0100
sll 0101
srl 0110
sra 0111
set less than 1000
branch equal 1001
branch less than 1010
branch less than or equal 1011
branch greater than 1100
branch greater than or
equal 1101
x 1110
x 1111