1 Lecture 5: A DataPath and Control Unit. 2 Finite State Machine and Datapath Design a simple datapath and a control unit data path contains: compare.

Slides:



Advertisements
Similar presentations
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Advertisements

Traffic light contoller using FSM
CPSC 321 Computer Architecture Andreas Klappenecker
Verilog.
Synchronous Sequential Logic
Combinational Logic.
Verilog Modules for Common Digital Functions
Table 7.1 Verilog Operators.
COE 405 Design and Synthesis of DataPath Controllers Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd University of Petroleum & Minerals.
Case Study VLSI 系統設計與高階合成           + : delay : multiplier: adder … … + … … FIR Filter tap=4 IIR Case - Filter (1/8)
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
FSM examples.
Pulse-Width Modulated DAC
Conditional Statements  if and else if statements if (expression) if (expression) statements statements { else if (expression) { else if (expression)
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
1 COMP541 Sequencing and Control Montek Singh Mar 29, 2007.
ELEN 468 Lecture 91 ELEN 468 Advanced Logic Design Lecture 9 Behavioral Descriptions III.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
Counters Discussion 12.1 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Design example Binary Multiplier.
ELEN 468 Advanced Logic Design
Advanced Verilog EECS 270 v10/23/06.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Verilog Descriptions of Digital Systems. Electronic Lock // // Electronic combinational lock // module lock(seg7,key, valid_key, col, row, mclk, resetL)
Overview Logistics Last lecture Today HW5 due today
RTL Coding tips Lecture 7,8 Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock.
Verilog Digital System Design Z. Navabi, 2006
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Ceng 450 Project. Pinout of Processor Interrupt is optional Processor in_port[7:0] out_port[7:0] clock rst interrupt.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
Register Transfer Level & Design with ASM
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Verilog for Synthesis Ing. Pullini Antonio
Final Project. System Overview Description of Inputs reset: When LOW, a power on reset is performed. mode: When LOW, NORMal mode selected When HIGH,
Finite State Machine (FSM) Nattha Jindapetch December 2008.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
1 Verilog: Function, Task Verilog: Functions A function call is an operand in an expression. It is called from within the expression and returns a value.
1 (c) W. J. Dally Digital Design: A Systems Approach Lecture 7: Data Path State Machines.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Finite State Machine -Moore & Mealy Machine -State Encoding Techniques.
Pusat Pengajian Kejuruteraan Mikroelektronik EMT 351/4 DIGITAL IC DESIGN Verilog Behavioural Modeling (Part 4) Week #
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Figure Implementation of an FSM in a CPLD..
Overview Logistics Last lecture Today HW5 due today
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
Supplement on Verilog for Algorithm State Machine Chart
Figure 8.1. The general form of a sequential circuit.
Reg and Wire:.
Supplement on Verilog Sequential circuit examples: FSM
Equivalent Behavioral Model Module being Tested (RTL)
A Multiple Clock Cycle Instruction Implementation
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
COE 202 Introduction to Verilog
Supplement on Verilog Sequential circuit examples: FSM
Register-Transfer Level Components in Verilog
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
332:437 Lecture 9 Verilog Example
332:437 Lecture 9 Verilog Example
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
332:437 Lecture 9 Verilog Example
Lecture 7: Verilog Part II
Presentation transcript:

1 Lecture 5: A DataPath and Control Unit

2 Finite State Machine and Datapath Design a simple datapath and a control unit data path contains: compare unit ( larger) compare unit ( larger and equal ) two adders register x, register y, register i control unit generates output signals: (all are active low) yLoad, yclear, xLoad, xClear, iLoad, iClear control unit receives input signals: x < 10, i <= 10, clock, reset

3 Register Module module register (out, in, clear, load, clock); parameter WIDTH = 7; output[WIDTH:0]out; reg[WIDTH:0]out; input[WIDTH:0]in; inputclear, load, clock; clock) if (~clear) out <= 0; else if (~load) out <= in; endmodule

4 Adder Module module adder (sum, a, b); parameter WIDTH = 7; input[WIDTH:0]a, b; output[WIDTH:0]sum; assign sum = a + b; endmodule

5 Module CompareLT module compareLT (out, a, b); // compares a < b parameter WIDTH = 7; input[WIDTH:0]a, b; outputout; assign out = a < b; endmodule

6 Module CompareLEQ module compareLEQ (out, a, b);// compares a <= b parameter WIDTH = 7; input[WIDTH:0]a, b; outputout; assign out = a <= b; endmodule

7 The Control Unit (FSM) module fsm (LT, LEQ, yLoad, yClear, xLoad, xClear, iLoad, iClear, ck, reset); inputLT, LEQ, ck, reset; outputyLoad, yClear, xLoad, xClear, iLoad, iClear; regyLoad, yClear, xLoad, xClear, iLoad, iClear; reg[2:0]cState, nState; ck or negedge reset) if (~reset) cState <= 0; elsecState <= nState;

8 or LT or LEQ) case (cState) 3'b000 :begin // state A yLoad = 1; yClear = 1; xLoad = 1; xClear = 0; iLoad = 1; iClear = 0; nState = 3'b001; end 3'b001 :begin // state B yLoad = 1; yClear = 1; xLoad = 0; xClear = 1; iLoad = 0; iClear = 1; nState = 3'b010; end 3'b010 :begin // state C yLoad = 1; yClear = 1; xLoad = 1; xClear = 1; iLoad = 1; iClear = 1; if (LEQ) nState = 3'b001; if (~LEQ & LT) nState = 3'b011; if (~LEQ & ~LT) nState = 3'b100; end

9 3'b011 :begin // state D yLoad = 1; yClear = 0; xLoad = 1; xClear = 1; iLoad = 1; iClear = 1; nState = 3'b101; end 3'b100 :begin // state E yLoad = 1; yClear = 1; xLoad = 1; xClear = 0; iLoad = 1; iClear = 1; nState = 3'b101; end default :begin // required to satisfy synthesis rules yLoad = 1; yClear = 1; xLoad = 1; xClear = 1; iLoad = 1; iClear = 1; nState = 3'b000; $display (“unknown state: %b", cState); end endcase endmodule

10 Wiring the Datapath and FSM module simpleComputation (yIn, y, x, ck, reset); parameter WIDTH = 7; inputck, reset; input[WIDTH:0]yIn; output[WIDTH:0]y, x; wire[WIDTH:0]i, addiOut, addxOut; wireyLoad, yClear, xLoad, xClear, iLoad, iClear; register#(WIDTH) I (i, addiOut, iClear, iLoad, ck), Y (y, yIn, yClear, yLoad, ck), X (x, addxOut, xClear, xLoad, ck);

11 Wiring the Datapath and FSM adder#(WIDTH)addI(addiOut, 1, i), addX(addxOut, y, x); compareLT#(WIDTH)cmpX(xLT0, x, 0); compareLEQ #(WIDTH)cmpI(iLEQ10, i, 10); fsm ctl (xLT0, iLEQ10, yLoad, yClear, xLoad, xClear, iLoad, iClear, ck, reset); endmodule

12 Using If-Else-If module mark1; reg [31:0]m [0:8191];// 8192 x 32 bit memory reg [12:0]pc;// 13 bit program counter reg [31:0]acc;// 32 bit accumulator reg [15:0]ir;// 16 bit instruction register regck;// a clock signal always ck)ir = m [pc]; // fetch an ck) if (ir[15:13] == 3'b000) // begin decoding pc = m [ir [12:0]]; // and executing else if (ir[15:13] == 3'b001) pc = pc + m [ir [12:0]];

13 else if (ir[15:13] == 3'b010) acc = -m [ir [12:0]]; else if (ir[15:13] == 3'b011) m [ir [12:0]] = acc; else if ((ir[15:13] == 3'b101) || (ir[15:13] == 3'b100)) acc = acc - m [ir [12:0]]; else if (ir[15:13] == 3'b110) if (acc < 0) pc = pc + 1; pc = pc + 1;//increment program counter end endmodule

14 Using Case in Verilog module mark1Case; reg [31:0]m [0:8191];// 8192 x 32 bit memory reg [12:0pc;// 13 bit program counter reg [31:0]acc;// 32 bit accumulator reg [15:0]ir;// 16 bit instruction register regck;// a clock signal always ck) ir = m ck)

15 case (ir [15:13]) 3'b000 :pc = m [ir [12:0]]; 3'b001 :pc = pc + m [ir [12:0]]; 3'b010 :acc = -m [ir [12:0]]; 3'b011 :m [ir [12:0]] = acc; 3'b100, 3'b101 :acc = acc - m [ir [12:0]]; 3'b110 :if (acc < 0) pc = pc + 1; endcase pc = pc + 1; end endmodule

16 Tasks: Mutiply case (ir [15:13]) 3'b000 :pc = m [ir [12:0]]; 3'b001 :pc = pc + m [ir [12:0]]; 3'b010 :acc = -m [ir [12:0]]; 3'b011 : m [ir [12:0]] = acc; 3'b100, 3'b101 :acc = acc - m [ir [12:0]]; 3'b110 :if (acc < 0) pc = pc + 1; 3'b111 :acc = acc * m [ir [12:0]]; //multiply endcase

17 Using Tasks in Verilog module mark1Task; reg [15:0]m [0:8191];// 8192 x 16 bit memory reg [12:0]pc;// 13 bit program counter reg [12:0]acc;// 13 bit accumulator regck;// a clock signal always begin: executeInstructions reg[15:0]ir; // 16 bit instruction register

18 Using Tasks in ck) ir = m ck) case (ir [15:13]) // other case expressions as before 3'b111 :multiply (acc, m [ir [12:0]]); endcase pc = pc + 1; end

19 Task Multiply task multiply; inout[12:0]a; input[15:0]b; begin: serialMult reg[5:0]mcnd, mpy; //multiplicand and multiplier reg[12:0]prod;//product mpy = b[5:0]; mcnd = a[5:0];

20 Task Multiply prod = 0; repeat (6) // repeat 6 times begin if (mpy[0]) prod = prod + {mcnd, 6'b000000}; prod = prod >> 1; mpy = mpy >> 1; end a = prod; end endtask endmodule

21 Tasks A Verilog task is similar to a software procedure. It is called from a calling statement and after execution, returns to the nest statement. It can not be used in an expression. Local variables may be declared within it.