Lab 4 Design a processor to implement the Fibonacci sequence

Slides:



Advertisements
Similar presentations
Processor Data Path and Control Diana Palsetia UPenn
Advertisements

Computer Science Education
Machine cycle.
Chapter 4 The Von Neumann Model
Chapter 4 The Von Neumann Model
CS/COE1541: Introduction to Computer Architecture Datapath and Control Review Sangyeun Cho Computer Science Department University of Pittsburgh.
Control path Recall that the control path is the physical entity in a processor which: fetches instructions, fetches operands, decodes instructions, schedules.
CS-447– Computer Architecture Lecture 12 Multiple Cycle Datapath
Lec 8: Pipelining Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University.
Computer Structure - Datapath and Control Goal: Design a Datapath  We will design the datapath of a processor that includes a subset of the MIPS instruction.
Henry Hexmoor1 Chapter 10- Control units We introduced the basic structure of a control unit, and translated assembly instructions into a binary representation.
Lab 4 Due date: Friday, December 5 th CSE 140L Fall 2003.
Datapath and Control Andreas Klappenecker CPSC321 Computer Architecture.
1 Computer Organization Today: First Hour: Computer Organization –Section 11.3 of Katz’s Textbook –In-class Activity #1 Second Hour: Test Review.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
Gary MarsdenSlide 1University of Cape Town Chapter 5 - The Processor  Machine Performance factors –Instruction Count, Clock cycle time, Clock cycles per.
ECE Computer Architecture Lecture Notes # 6 Shantanu Dutt How to Add To & Use the Basic Processor Organization To Execute Different Instructions.
Datapath and Control Unit Design
ECE 353 Lab 2 Pipeline Simulator Additional Material.
An Adder A Subtractor. A and B are the inputs of the adder/ subtractor R is the output of the adder/ subtractor F is the control to tell it to add or.
Elements of Datapath for the fetch and increment The first element we need: a memory unit to store the instructions of a program and supply instructions.
Designing a CPU –Reading a programs instruction from memory –Decoding the instruction –Executing the instruction –Transferring Data to/From memory / IO.
Single Cycle Controller Design
MIPS Processor.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
EE204 Computer Architecture
CS161 – Design and Architecture of Computer Systems
Electrical and Computer Engineering University of Cyprus
Basic Computer Organization and Design
CS161 – Design and Architecture of Computer Systems
ECE 353 Lab 3 Pipeline Simulator
Computer Architecture
Control & Execution Finite State Machines for Control MIPS Execution.
Chap 7. Register Transfers and Datapaths
Morgan Kaufmann Publishers The Processor
Morgan Kaufmann Publishers The Processor
Processor (I).
Simple Processor Control Unit
CS/COE0447 Computer Organization & Assembly Language
Design of the Control Unit for Single-Cycle Instruction Execution
The Processor and Machine Language
MIPS processor continued
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Control & Execution Finite State Machines for Control MIPS Execution.
CSCI206 - Computer Organization & Programming
Single-Cycle CPU DataPath.
Manual Example How to manually convert high-level code into circuit
Design of the Control Unit for One-cycle Instruction Execution
CSCI206 - Computer Organization & Programming
A Multiple Clock Cycle Instruction Implementation
MIPS Processor.
Control Unit Introduction Types Comparison Control Memory
Rocky K. C. Chang 6 November 2017
The Processor Lecture 3.2: Building a Datapath with Control
Vishwani D. Agrawal James J. Danaher Professor
Enhancing Data Path M 4-bit Reg X A L U
A register design with parallel load input
COMS 361 Computer Organization
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Control Unit (single cycle implementation)
ECE 353 Lab 3 Pipeline Simulator
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
ECE 352 Digital System Fundamentals
Review: The whole processor
Control Unit (single cycle implementation)
The Processor: Datapath & Control.
Computer Architecture Assembly Language
COMS 361 Computer Organization
MIPS Processor.
Processor: Datapath and Control
Presentation transcript:

Lab 4 Design a processor to implement the Fibonacci sequence You will be given an instruction set You will design a datapath to implement the instructions You will design a FSM to implement an instruction sequence for the fibonacci sequence calculation

Fibonacci Sequence Fibonacci sequence Pseudo code F(1) = 1 F(2) = 1 F(N) = F(N-1) + F(N-2) e.g. 1, 1, 2,3, 5, 8, 13 … With a 4-bit datapath, can only count up to 15, or assume N <= 7, F(7) = 13 Pseudo code int fibonaaci (int N) { int N1 = 1, N2 = 1; int F, temp, c; for (c = N-2; c > 0; c--) { temp = N1; N1 = N1 + N2; N2 = temp; } F = N1; return F;

Datapath we R0 R1 w_addr decoder R2 R3 r_addr1 mux mux r_addr2 load 4 R0 4 R1 2 w_addr decoder 4 R2 4 R3 2 2 r_addr1 mux mux r_addr2 4 4 4 load mux ALU 3 zero_flag alu_op 4 4 mem_in 4 mem_out

FSM & Nano-decoder 3 FSM alu_op 2 r_addr1 start 3 opcode 2 r_addr2 2 zero_flag operand1 2 w_addr 2 operand2 done we load Instruction format: <opcode, operand1, operand2> Instructions: 000 -- -- noop 001 aa -- set R[aa] = 1 010 aa -- increment R[aa] = R[aa] + 1 011 aa -- decrement R[aa] = R[aa] - 1 100 aa -- load R[aa] = mem_in 101 aa -- store mem_out = R[aa] 110 aa bb add R[aa] = R[aa] + R[bb] 111 aa bb copy R[aa] = R[bb]

Nano-decoder opcode opcode opr1 opr2 alu_op raddr1 raddr2 waddr we load noop 000 -- -- 000 -- -- -- - set 001 aa -- 001 -- -- aa 1 incr 010 aa -- 010 aa -- aa 1 decr 011 aa -- 011 aa -- aa 1 load 100 aa -- 100 -- -- aa 1 1 store 101 aa -- 101 aa -- -- - add 110 aa bb 110 aa bb aa 1 copy 111 aa bb 111 bb -- aa 1 Hints: can assign don’t cares so that alu_op = opcode, and raddr2 = opr2 waddr (write address), we (write enable), load, and raddr1 logic more complicated

More on Datapath zero_flag = 1 if the output of the ALU is “0000” Assume 4-bits represent only positive numbers 0 … 15 Increment can be implemented as A + 0, carry_in = 1 Decrement can be implemented as A + “1111”, carry_in = 0 zero_flag = 1 if the output of the ALU is “0000”

Fibonacci Sequence Fibonacci sequence Pseudo code F(1) = 1 F(2) = 1 F(N) = F(N-1) + F(N-2) e.g. 1, 1, 2,3, 5, 8, 13 … With a 4-bit datapath, can only count up to 15, or assume N <= 7, F(7) = 13 Pseudo code int fibonaaci (int N) { int N1 = 1, N2 = 1; int F, temp, c; for (c = N-2; c > 0; c--) { temp = N1; N1 = N1 + N2; N2 = temp; } F = N1; return F;

Pseudo Machine Code Specification Register allocation Wait until start = 1 Assume N-2 is provided at mem_in for computing F(N) Use store instruction to output the final answer F(N) to mem_out and set done = 1 (done = 0 during other cycles) Register allocation R0: count R1: N1 R2: N2 R3: temp Pseudo machine code while (not start) { noop } load R0 // set c = N-2 set R1 // set N1 = 1 set R2 // set N2 = 1 store R0 // test zero while (not zero_flag) { copy R3 R1 add R1 R2 copy R2 R3 decr R0 store R1, done = 1 go back to initial state

FSM (Moore Machine) start/zero_flag state 00 01 1- opcode opr1 opr2 done A: while (not start) { noop } B: load R0 C: set R1 D: set R2 E: store R0 while (not zero_flag) { F: copy R3 R1 G: add R1 R2 H: copy R2 R3 I: decr R0 J: store R1, done = 1 go back to initial state A A A B 000 -- -- B C C B 100 R0 -- C D D B 001 R1 -- D E E B 001 R2 -- E F J B 101 R0 -- F G G B 111 R3 R1 G H H B 110 R1 R2 H I I B 111 R2 R3 I F J B 011 R0 -- J A A B 101 R1 -- 1 * Note: when start = 1, just start the calculation over

Grading Part I (12 out of 36 points) Part II (12 out of 36 points) Part III (12 out of 36 points) Total 36 points 40% of overall grade

Part I Part I (12 out of 36 points) Sample test cases Test the ALU to make sure that the combinational logic works for these alu_ops (set, incr, decr, store, add, copy) For single operand operations, assume operand provided at operand1 (left arm of ALU) Sample test cases set (just set output to 1) incr 4 dec 1 store (just pass operand1 to output) add 2 + 4 copy (just pass operand1 to output) 2 points for each of the 6 test cases. Actual values for test cases during live demo will change ALU 4 3 alu_op zero_flag

Part II Part II (12 out of 36 points) Sample sequence I Test entire datapath and nano-decoder by running through sequences of instructions. You’ll be given two sequences Each sequence is worth 6 points. In each sequence, there will be 3 places where mem_out will be checked and 1 place where zero_flag will be checked, a total of 4 checks, each worth 1.5 points (4 x 1.5 = 6) Actual test sequences will change at live demo Sample sequence I set R1 // next R1 = 1 set R2 // next R2 = 1 add R1 R2 // next R1 = 2 store R1 // mem_out = R1 add R1 R2 // next R1 = 3 decr R2 // next R2 = 0 // zero_flag = 1 store R2 // mem_out = R2 Sample sequence II load R0 // next R0 = 7 (mem_in) load R3 // next R3 = 5 (mem_in) store R3 // mem_out = R3 add R3 R0 // next R3 = 12 decr R0 // next R0 = 6 // zero_flag = 0 incr R3 // next R3 = 13 store R0 // mem_out = R0

Part III Part III (12 out of 36 points) Sample case I Sample case II Test to see if the fibonacci calculator works N-2 is provided for calculating F(N) N will be less than or equal to 7, which means N-2 provided at mem_in will be less than or equal to 5 Two fibonacci calculations will be tested, each worth 6 points For each test, either it works or it doesn’t, i.e. 0 or 6 points Sample case I Provided with N-2 = 5 Calculate F(N) = F(7) = 13 Sample case II Provided with N-2 = 1 Calculate F(N) = F(3) = 2 Assume N-2 >= 0 Implies N >= 2

Summary Following are the steps for Lab 4 Make an ALU. Manually test its functionality for each opcode. This part does not require any state machines. This is a simple combinational logic. Make a register file. This will require use of flip-flops. Test the register file seperately. Make sure it is outputting the current values of the register accurately. Make sure, it gets written with the right value, in the right register and only when the write-enable (WE) signal is 1. Test the value of Mem-out, Mem_in and Zero_Flag.