RISCy Business - Ece
Personal tools

RISCy Business

From Ece

Jump to: navigation, search

Team RISCy Business is an ECE4713 Computer Architecture project team consisting of Jeff Brantley and Thomas Donaldson. RISCy Business has produced a partial CPU implementation based on the MIPS architecture in the course textbook.

Contents

Overview

Instruction Formats

R-Format:

Opcode rs rt rd func
4 bits 3 bits 3 bits 3 bits 3 bits

I-Format:

Opcode rs rt immediate / address
4 bits 3 bits 3 bits 6 bits

LI-Format:

Opcode rs - long immediate
4 bits 3 bits 1 bit 8 bits

J-Format:

Opcode address
4 bits 12 bits

Register File

$v0 $v1 $v2 $v3 $a0 $a1 $t0 $t1
$0 $1 $2 $3 $4 $5 $6 $7

Instruction Set Summary

Name Mnemonic Operation Note Opcode Funct Format
AddaddR[rd] = R[rs] + R[rt]11110R
SubtractsubR[rd] = R[rs] + R[rt]11111R
Set Less ThansltR[rd] = (R[rs] < R[rt]) ? 1 : 0111110R
Set Less Than UnsignedsltuR[rd] = (R[rs] < R[rt]) ? 1 : 0(1)111111R
Oror R[rt]1111100R
AndandR[rd] = R[rs] & R[rt]1111101R
Nornor R[rt])1111110R
Exclusive OrxorR[rd] = R[rs] ⊕ R[rt]1111111R
Shift Left LogicalsllR[rs] = R[rt] << ZeroExtImm(2)0001I
Shift Right LogicalsrlR[rs] = R[rt] >> ZeroExtImm(2)0010I
Shift Right ArithmeticsraR[rs] = R[rt] >>> ZeroExtImm(2)0011I
Add ImmediateaddiR[rs] = R[rt] + SignExtImm(3)0100I
Load WordlwR[rs] = M[R[rt]+SignExtImm](3)0101I
Store WordswM[R[rt]+SignExtImm] = R[rs](3)0110I
Store BytesbM[R[rt]+SignExtImm](7:0) = R[rs](7:0)(3)0111I
Load Lower ImmediatelliR[rs] = {8’b0, long immediate}1000LI
Load Upper ImmediateluiR[rs] = {long immediate, R[rs](7:0)}1001LI
Branch If Equal To Zerobzif(R[rs]==0) PC=PC+2+BranchAddr(4)1010I
JumpjPC=JumpAddr(5)1011J
Bit Setbset (1’b1 << ZeroExtImm)(2)1100I
Bit ClearbclrR[rs] = R[rt] & ~(1’b1 << ZeroExtImm)(2)1101I
Bit TestbtstR[rs] = (R[rt] & (1’b1 << ZeroExtImm)) != 0 ? 1 : 0(2)1110I
No Operationnop0000
  • (1) Operands considered unsigned numbers (vs. 2’s comp.)
  • (2) ZeroExtImm = { 10{1b’0}, immediate }
  • (3) SignExtImm = { 10{immediate[5]}, immediate }
  • (4) BranchAddr = { 2{immediate[5]}, immediate, 1’b0 }
  • (5) JumpAddr = { address(7:0), 1’b0 }

Test Program

                             |  $v0 = 0040hex;	// initialized values
                             |  $v1 = 1010hex;
                             |  $v2 = 000Fhex;
                             |  $v3 = 00F0hex;
                             |  $t0 = 0000hex;
                             |  $a0 = 0010hex;
                             |  $a1 = 0005hex;
                             |
Loop:    lli $t0, 0          |  while ($a1 > 0) do {
         slt $t0, $t0, $a1   |
         bz $t0, EndLoop     |
         nop                 |
         nop                 |
         nop                 |
         addi $a1, $a1, -1   |      $a1 = $a1 –1;
         lw $t0, 0($a0)      |      $t0 = Mem[$a0];
         lli $t1, 0x00       |      if ($t0 > 0100hex) then {
         lui $t1, 0x01       |
         slt $t0, $t1, $t0   |
         bz $t0, Else        |
         nop                 |
         nop                 |
         nop                 |
         sra $v0, $v0, 3     |          $v0 = $v0 ÷ 8;
         or $v1, $v1, $v0    |          $v1 = $v1 | $v0; //or
         lli $t0, 0x00       |          Mem[$a0] = FF00hex;
         lui $t0, 0xFF       |
         sw $t0, 0($a0)      |
         j EndIf             |
         nop                 |
         nop                 |
         nop                 |
                             |      } else {
Else:    sll $v2, $v2, 2     |          $v2 = $v2 × 4;
         xor $v3, $v3, $v2   |          $v3 = $v3 ⊕ $v2; //xor
         lli $t0, 0xFF       |          Mem[$a0] = 00FFhex;
         sw $t0, 0($a0)      |
                             |      }
EndIf:   addi $a0, $a0, 2    |      $a0 = $a0 + 2;
         j Loop              |  }
         nop                 |
         nop                 |
         nop                 |
EndLoop:                     |  return;

;-------------------------------------------------
; Begin additional test for remaining instructions
;-------------------------------------------------

         add $v1, $v1, $v0   |  $v1 = $v1 + $v0;
         sub $v0, $a0, $v1   |  $v0 = $a0 - $v1;
         and $a1, $v1, $a0   |  $a1 = $v1 & $a0;
         nor $t0, $t1, $a1   |  $t0 = ~($t1 | $a1);
         srl $a1, $t0, 2     |  $a1 = ($t0 >> 2);      // shift in 0's
         bclr $a0, $a0, 1    |  $a0 = $a0 & ~(1 << 1); // clear bit 1
         sb $t0, 0($a0)      |  Mem[$a0] = $t0;
         sb $a1, 1($a0)      |  Mem[$a0 + 1] = $a1;
         bset $t1, $t1, 10   |  $t1 = $t1 | (1 << 10); // set bit 10
         btst $t1, $t1, 10   |  $t1 = ($t1 & (1 << 10)) == 0 ? 1 : 0;
         slt $v2, $v0, $a1   |  $v2 = $v0 < $a1 ? 1 : 0;   // signed operands
         sltu $v3, $v0, $a1  |  $v3 = $v0 < $a1 ? 1 : 0;   // unsigned operands

Datapath Diagram

CPU_Diagram-small.png

Deliverables

Documents

Project Proposal

Final Report (with code)

Final Report (without code)

User Manual

Presentation (PDF)

Simulation Downloads

To obtain and synthesize the entire Verilog description, download the bundle.

Simulation Files Bundle (zip)

To simply program the board, you can download the bit-file directly.

Loadable Bit-file (cpu_test.bit)