Docsity

Mini MIPS, Fibonacci C-Code, Instruction Set | CS 3710, Study notes of Computer Science

Toggle sidebar
bg1
1
Mini-MIPS
From Weste/Harris
CMOS VLSI Design
CS/EE 3710
Based on MIPS
๎šŠIn fact, itโ€™s based on the multi-cycle MIPS
from Patterson and Hennessy
๎š„Your CS/EE 3810 book...
๎šŠ8-bit version
๎š„8-bit data and address
๎š„32-bit instruction format
๎š„8 registers numbered $0-$7
z$0 is hardwired to the value 0
CS/EE 3710
Instruction Set
CS/EE 3710
Instruction Encoding
CS/EE 3710
Fibonacci C-Code
CS/EE 3710
Fibonacci C-Code
Cycle 1: f1 = 1 + (-1) = 0, f2 = 0 โ€“ (-1) = 1
Cycle 2: f1 = 0 + 1 = 1, f2 = 1 โ€“ 1 = 0
Cycle 3: f1 = 1 + 0 = 1, f2 = 1 โ€“ 0 = 1
Cycle 4: f1 = 1 + 1 = 2, f2 = 2 โ€“ 1 = 1
Cycle 5: f1 = 2 + 1 = 3, f2 = 3 โ€“ 1 = 2
Cycle 6: f1 = 3 + 2 = 5, f2 = 5 โ€“ 2 = 3
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Mini MIPS, Fibonacci C-Code, Instruction Set | CS 3710 and more Study notes Computer Science in PDF only on Docsity!

Mini-MIPS

From Weste/Harris

CMOS VLSI Design

CS/EE 3710

Based on MIPS

ยŠ In fact, itโ€™s based on the multi-cycle MIPS

from Patterson and Hennessy

ย„ Your CS/EE 3810 book...

ยŠ 8-bit version

ย„ 8-bit data and address

ย„ 32-bit instruction format

ย„ 8 registers numbered $0-$

z $0 is hardwired to the value 0

CS/EE 3710

Instruction Set

CS/EE 3710

Instruction Encoding

CS/EE 3710

Fibonacci C-Code

CS/EE 3710

Fibonacci C-Code

Cycle 1: f1 = 1 + (-1) = 0, f2 = 0 โ€“ (-1) = 1 Cycle 2: f1 = 0 + 1 = 1, f2 = 1 โ€“ 1 = 0 Cycle 3: f1 = 1 + 0 = 1, f2 = 1 โ€“ 0 = 1 Cycle 4: f1 = 1 + 1 = 2, f2 = 2 โ€“ 1 = 1 Cycle 5: f1 = 2 + 1 = 3, f2 = 3 โ€“ 1 = 2 Cycle 6: f1 = 3 + 2 = 5, f2 = 5 โ€“ 2 = 3

CS/EE 3710

Fibonacci Assembly Code

Compute 8 th^ Fibonacci number (8โ€™d13 or 8โ€™h0D) Store that number in memory location 255

CS/EE 3710

Fibonacci Machine Code

101000

4

Assembly Code Machine Code

CS/EE 3710

Architecture

CS/EE 3710

Architecture

CS/EE 3710

Another View

CS/EE 3710

Control FSM

CS/EE 3710

Read_First Template

CS/EE 3710

Write_First Template

CS/EE 3710

Read_First waveforms

CS/EE 3710

Write_First Waveforms

CS/EE 3710

Block RAM Organization

Each block is 18k bits...

Block RAM is Single or Dual ported

CS/EE 3710

Recall โ€“ Overall System

Clock Clk

Clk

CS/EE 3710

Recall โ€“ Overall System

Clock Clk

Clk

So, what are the implications of using a RAM that has both clocked reads and writes instead of clocked writes and async reads? (weโ€™ll come back to this question...)

CS/EE 3710

mips Block Diagram

CS/EE 3710

mips.v

// simplified MIPS processor module mips #(parameter WIDTH = 8, REGBITS = 3) (input clk, reset, input [WIDTH-1:0] memdata, output memread, memwrite, output [WIDTH-1:0] adr, writedata); wire [31:0] instr; wire zero, alusrca, memtoreg, iord, pcen, regwrite, regdst; wire [1:0] aluop,pcsource,alusrcb; wire [3:0] irwrite; wire [2:0] alucont; controller cont(clk, reset, instr[31:26], zero, memread, memwrite, alusrca, memtoreg, iord, pcen, regwrite, regdst, pcsource, alusrcb, aluop, irwrite); alucontrol ac(aluop, instr[5:0], alucont); datapath #(WIDTH, REGBITS) dp(clk, reset, memdata, alusrca, memtoreg, iord, pcen, regwrite, regdst, pcsource, alusrcb, irwrite, alucont, zero, instr, adr, writedata); endmodule

CS/EE 3710

Controller

State Codes

Useful constants to compare against

State Register

CS/EE 3710

Control FSM

CS/EE 3710

Next State Logic

CS/EE 3710

Synthesis Report

CS/EE 3710

Synthesis Report

CS/EE 3710

Synthesis Report

Two register files? Why?

CS/EE 3710

Datapath

Fairly complex...

Not really, but it does have lots of registers instantiated directly

It also instantiates muxes...

Instruction Register

CS/EE 3710

Datapath continued

Flops and muxes...

RF and ALU

CS/EE 3710

Flops and MUXes

CS/EE 3710

Back to the Memory Question

ยŠ What are the implications of using RAM that

is clocked on both write and read?

ย„ Book version was async read

ย„ So, letโ€™s look at the sequence of events that

happen to read the instruction

ย„ Four steps โ€“ read four bytes and put them in four

slots in the 32-bit instruction register (IR)

CS/EE 3710

Instruction Fetch

CS/EE 3710

Instruction Fetch

CS/EE 3710

Instruction Fetch

  • Memread, irwrite, addr, etc are set up just after clk edge
  • Data comes back sometime after that (async)
  • Data is captured in ir0 โ€“ ir3 on the next rising clk edge
  • How does this change if reads are clocked?

CS/EE 3710

mips + exmem

One of those rare cases where using both edges of the clock is useful!

mips is expecting async reads exmem has clocked reads

CS/EE 3710

Memory Mapped I/O

ยŠ Break memory space into pieces (ranges)

ย„ For some of those pieces: regular memory

ย„ For some of those pieces: I/O

z That is, reading from an address in that range results in getting data from an I/O device z Writing to an address in that range results in data going to an I/O device