Register Transfer Level & Design with ASM

Slides:



Advertisements
Similar presentations
Register Transfer Level
Advertisements

1ASM Algorithmic State Machines (ASM) part 1. ASM2 Algorithmic State Machine (ASM) ‏ Our design methodologies do not scale well to real-world problems.
Table 7.1 Verilog Operators.
Hardware Description Language (HDL)
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
Give qualifications of instructors: DAP
EKT 221 : Digital 2 ASM.
Spring 20067W. Rhett Davis with minor modifications by Dean Brock ECE 406 at UNASlide 1 ECE 406 Design of Complex Digital Systems Lecture 10: 9: State.
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
Chapter 8 Sequencing and Control Henry Hexmoor1. 2 Datapath versus Control unit  Datapath - performs data transfer and processing operations  Control.
Design at the Register Transfer Level
3/20/20091 More State Machines. Multiple processes.
The Control Unit: Sequencing the Processor Control Unit: –provides control signals that activate the various microoperations in the datapath the select.
1 COMP541 Sequencing and Control Montek Singh Mar 29, 2007.
Chapter 7. Register Transfer and Computer Operations
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
ELEN 468 Advanced Logic Design
FINITE STATE MACHINES (FSMs) Dr. Konstantinos Tatas.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts,
Algorithmic State Machines
Advanced Verilog EECS 270 v10/23/06.
1 KU College of Engineering Elec 204: Digital Systems Design Lecture 20 Datapath and Control Datapath - performs data transfer and processing operations.
Sequential Logic in Verilog
Verilog Digital System Design Z. Navabi, 2006
1 COMP541 State Machines Montek Singh Feb 8, 2012.
1 KU College of Engineering Elec 204: Digital Systems Design Lecture 21 Multiplier Example Example: (101 x 011) Base 2 Note that the partial product summation.
Chap 8. Sequencing and Control. 8.1 Introduction Binary information in a digital computer –data manipulated in a datapath with ALUs, registers, multiplexers,
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
EEE2243 Digital System Design Chapter 4: Verilog HDL (Sequential) by Muhazam Mustapha, January 2011.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
Module 1.2 Introduction to Verilog
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
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.
VHDL Discussion Finite State Machines
Algorithmic state machines
Datapath - performs data transfer and processing operations The control unit sends: – Control signals – Control outputs The control unit receives: – External.
VHDL Discussion Finite State Machines IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Introduction to ASIC flow and Verilog HDL
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
ECE DIGITAL LOGIC LECTURE 21: FINITE STATE MACHINE Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/24/2015.
ASM Charts. Outline  ASM Charts Components of ASM Charts ASM Charts: An Example  Register Operations  Timing in ASM Charts  ASM Charts => Digital.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 9: State Machines & Reset Behavior Spring.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
1 (c) W. J. Dally Digital Design: A Systems Approach Lecture 7: Data Path State Machines.
Design at the Register Transfer Level Algorithmic State Machines 07.
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 #
Lecture 5. Verilog HDL #3 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Figure Implementation of an FSM in a CPLD..
Supplement on Verilog for Algorithm State Machine Chart
Figure 8.1. The general form of a sequential circuit.
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL Code.
Chap 7. Register Transfers and Datapaths
Supplement on Verilog Sequential circuit examples: FSM
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
SYNTHESIS OF SEQUENTIAL LOGIC
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
COE 202 Introduction to Verilog
REGISTER TRANSFER LEVEL (RTL) DESIGN Using ASM CHART
Supplement on Verilog Sequential circuit examples: FSM
KU College of Engineering Elec 204: Digital Systems Design
ASM and Micro-programmed State Machines
The Verilog Hardware Description Language
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Presentation transcript:

Register Transfer Level & Design with ASM Logic and Digital System Design - CS 303 Erkay Savaş Sabancı University

Overview Register transfer level (RTL) to model complex digital systems a level of abstraction used in describing the operation of a synchronous digital circuits a circuit's behavior is defined in terms of the transfer of data between hardware registers, and the operations performed on data. Goal: Algorithmic expression of a digital system Algorithmic State Machine (ASM) charts to model complex digital systems to map a complex design into hardware

Register Transfer Level Designing a complex digital system using state tables becomes difficult as the number of states increases Remedy partition the system into modular subsystems each module is designed separately modules are connected to each other A digital module is best defined by set of registers operations on the binary information stored in them

Register Transfer Level Register operations move, copy, shift, count, clear, load, add, subtract A digital system is said to be represented at the register transfer level (RTL) when it is specified by the following three components Set of registers Operations performed on the data stored in the registers The control supervises the sequence of operations in the system

The Control Control logic Transfer statement Initiates the sequence of operations generates timing (control) signals that sequence the operations in prescribed manner The outputs of control logic are binary signals that initiate the various operations in registers Certain conditions that depend on the previous operations may determine the sequence of future operations Transfer statement R2  R1 (“replacement” operation) Conditional transfer statement if (T1 = 1) then R2  R1 T1 is a control signal

Register Transfer Operations In register transfer operations, clock is not explicitly shown but, transfer is assumed to happen at the clock edge. previous example if (T1 = 1) then R2  R1 T1 may become 1 before the clock edge, but actual transfer happens exactly at the clock edge. Examples: if (T3 = 1) then (R2  R1, R1  R2) R1  R1 + R2 R3  R3 + 1 R4  shr R4 R5  0

Types of Register Operations Four categories transfer operations arithmetic operations logic operations shift operations

Datapath and Control One obvious distinction Control Datapath Unit Control signals Control inputs Status signals One obvious distinction design of datapath (data processing path) design of control circuit

Hardware Algorithm & ASM Chart (Digital) hardware algorithm is a procedure for implementing a digital circuit with given pieces of hardware equipments specifies the control sequence and datapath tasks Algorithmic state machine (ASM) chart is a special type of flowchart used to define digital hardware algorithms. state machine is another term for a sequential circuit ASM chart describes the sequence of events, events that occur at state transitions.

ASM Chart Three basic elements State box Decision box Conditional box

State Box START R  0 A 1011 state assignment name The output signals (e.g., START) in the box take the specified values in the current state if not specified in other states they are 0. The notation R  0 means that the register is cleared to 0 when the system transits from A to the next state

State Box Control R R  0 name A 1011 START state assignment START RESET_R R

Decision Box Decision box has two or more branches going out. J 1 Decision box has two or more branches going out. Decision is made based on the value of one or more input signals (e.g., signal J) Decision box must follow and be associated with a state box. Thus, the decision is made in the same clock cycle as the other actions of the state.

Decision Box Control R 1 Control Datapath Unit J J START RESET_R 1 Control Unit Datapath Control signals Status signals inputs Control START R RESET_R J

Conditional Box A conditional box must follow a decision box. Register operation or output A conditional box must follow a decision box. A conditional box is attached to a state box through one or more decision boxes. Therefore, the output signals in the conditional output box are asserted in the same clock cycle as those in the state box to which it is attached. The output signals can change during the current state as a result of changes on the inputs. The conditional output signals are sometimes referred as Mealy outputs since they depend on the input signals as well.

Conditional Box Control R S0 1 J Register operation or output J START 1 START R  0 ENABLE S0 Control START J START RESET_R RESET_R R ENABLE

Example: Traffic Control Major road Minor road sensor car/start_timer timed’ car’ major=G minor=R major=R minor=G timed

Datapath & Control Datapath Sensor car Control Counter MAJOR MINOR timed start_ timer Counter

Example: ASM Chart ASM Block G MAJOR car 1 start_timer R MINOR 1 timed Datapath Control Sensor car Counter MAJOR MINOR start_ timer car timed start_timer 1 ASM Block R MINOR timed

Traffic Controller with a Timer There is an abundance of states. states from s0 to s255 map to a simple counter we can just separate the traffic light controller from the timer. MAJOR G car 1 MINOR s0 MINOR s255

Linked ASM Charts G MAJOR car start 1 start_timer R MINOR timeup timed 1 IDLE start 1 timeup s0 s255

Linked ASM Charts G MAJOR car start 1 start_timer R MINOR timeup timed 1 CNT  0 IDLE start 1 COUNT CNT  CNT+1 timeup 1

Linked ASM Charts G MAJOR car start 1 start_timer R MINOR timed IDLE 1 CNT  0 IDLE start 1 COUNT CNT  CNT+1 CNT==255 1

Traffic Control Example - Schematic Note that present_state, start_timer and timed outputs are normally not shown (they are internal). Here, they are used for debugging

Verilog Code – Counter 1/4 `timescale 1ns / 1ps module Counter(input clk, reset, start, output reg timeup); reg pres_state; reg next_state; reg[2:0] CNT; parameter ST_IDLE=1'b0, ST_COUNT=1'b1; parameter LIMIT = 3'd6; //Sequential circuit state transitions always@(posedge clk or posedge reset) begin if(reset) pres_state <= ST_IDLE; else pres_state <= next_state; end ... reset start timeup

Verilog Code – Counter 2/4 ... //Combinational state transition circuit always@(*) begin case (pres_state) ST_IDLE: if(start) next_state = ST_COUNT; else next_state = ST_IDLE; end ST_COUNT: if(timeup) next_state = pres_state; default: endcase

Verilog Code – Counter 3/4 ... // sequential internal registry update. always@(posedge clk) begin case(pres_state) ST_IDLE: CNT <= 0; ST_COUNT: CNT <= CNT + 1; endcase end

Verilog Code – Counter 4/4 ... //Combinational output circuit always@(*) begin case (pres_state) ST_COUNT: if(CNT == LIMIT) timeup = 1'b1; else timeup = 1'b0; default: endcase end endmodule

Verilog Code –Trafic Light 1/4 `timescale 1ns / 1ps module TraficLight (clk, reset, car, timed, MAJOR, MINOR, start_timer, pres_state); input clk, reset, car, timed; output MAJOR, MINOR, start_timer, pres_state; reg next_state; reg pres_state; reg MAJOR; reg MINOR; reg start_timer; parameter ST_G = 1'b0, ST_R = 1'b1; // FSM starts //Sequential circuit state transitions always@(posedge clk or posedge reset) begin if(reset) pres_state <= ST_G; else pres_state <= next_state; end ... MAJOR reset MINOR car start_timer timed pres_state

Verilog Code –Trafic Light 2/4 ... //Combinational circuit for state transition always@(*) case (pres_state) ST_G: begin if(car) next_state = ST_R; else next_state = pres_state; end ST_R: if(timed) next_state = ST_G; default: endcase

Verilog Code –Trafic Light 3/4 ... //Combinational circuits outputs always@(*) case(pres_state) ST_G: begin if(car) start_timer = 1; // Mealy output else start_timer = 0; // Mealy output end default: start_timer = 0; endcase // FSM ends

Verilog Code –Trafic Light 4/4 ... // DATAPATH STARTS: We have 2 register at datapath MAJOR and MINOR //DATAPATH starts always@(*) begin case(pres_state) ST_R: MAJOR = 0; // Moore output MINOR = 1; // Moore output end default: MAJOR = 1; // Moore output MINOR = 0; // Moore output endcase //DATAPATH ends endmodule

Traffic Control Example - Simulation Note 1: 0 is state Green and 1 is state Red for present_state. Note 2: Second time the “car” signal is asserted, the system is not affected, because the system is designed in this way (i.e., the car signal is effective only when the present state is Green).

Traffic Control Example - Verilog Code Please see the files “TrafficLight.v” and “Counter.v” for verilog codes of the traffic control example. Note that these modules are seperate and they are used in a schematic file called “TrafficControl_sch.sch”, and, in a verilog file called “TrafficControl.v”.

ASM Block A structure consisting of one state box and all the decision and conditional boxes associated with it. A  A + 1 e f R  0 T1 T2 T3 T4 1 001 010 011 100

ASM Block One input path, any number of exit paths Each ASM block describes the state of a system during one clock-pulse interval The register operations within the state and conditional boxes in the example are executed with a common clock pulse when the system in this state (e.g., T1 in the example) The same clock pulse transfer the system controller to one of the next states (e.g., T2, T3, or T4) T1 001 A  A + 1 1 e 1 f R  0 T2 010 T3 T4 011 100

Timing Considerations 1/4 The pulses of the common clock are applied to registers in the datapath all flip-flops in the control We can assume that inputs are also synchronized with the clock Since they are the outputs of another circuit working with the same common clock. Synchronous inputs

Timing Considerations 2/4 Major difference between a conventional flow chart and ASM chart is in the time relations among the various operations Example A  A + 1 start e f R  0 T1 T2 T3 T4 1 001 010 011 100

Timing Considerations 3/4 If it were a conventional flowchart A  A + 1 start = 1 if e = 1 then R  0 next state is T4 else if f = 1 then next state is T3 next state is T2 T1 001 A  A + 1 start 1 e 1 f R  0 T2 T3 T4 010 011 100

Timing Considerations 4/4 But, in ASM chart, interpretation is different all operations in a block occur in synchronism with the clock “start” is asserted in T1 input signals “e” and “f” are checked in T1 The following operations are executed simultaneously during the next positive edge of clock A  A + 1 R  0 (if e = 1) control transfer to the next state T1 001 A  A + 1 start 1 e 1 f R  0 T2 T3 T4 010 011 100 clock present state T1 next state T2 or T3 or T4

Example: Binary Multiplier Sequential multiplier Algorithm: successive additions and shifting multiplicand x0 x1 x2 x3 × y0 y1 y2 y3 multiplier partial product x0 y0 x0 y1 x0 y2 x0 y3 x1 y0 x1 y1 x1 y2 x1 y3 x2 y0 x2 y1 x2 y2 x2 y3 + z7 z0 z1 z2 z3 z4 z5 z6 x3 y0 x3 y1 x3 y2 x2 y3 product

Hardware Algorithm for Multiplier Input: X, Y, n = log2X Output: Z = X  Y Step 0. if (Start == 0) do nothing else go to Step 1; Step 1. Q  X; B  Y; A  0; C  0; CNT  n; go to Step 2; Step 2. CNT  CNT-1; if(Q0 == 1) A  A+B; C  Carry(A+B); go to Step 3; Step 3. CAQ  shr(CAQ); C  0; if (CNT == 0) go to Step 0; else go to Step 2;

Schematic of Binary Multiplier Register Configuration if CNT= 0 then Z = 1 Register B multiplicand Check for zero Z Control logic Q0 CNT S (start) Parallel adder C cout n sum multiplier Register Q Register A Product

Example: ASM Chart T0 1 T1 T3 T2 1 A  shr A, An-1  C 1 T0 1 A  A + B, C  Cout 1 S Shift Right CAQ, C  0 T3 QX; A  0 B  Y; C  0 CNT  n 1 T1 CNT==0 CNT  CNT - 1 T2 Q0 A  shr A, An-1  C Q  shr Q, Qn-1  A0 C  0

Example: ASM Chart T0 1 T2 T1 1 A  shr A, An-1  C 1 T0 1 A  A + B, C  Cout 1 S Shift Right CAQ, C  0 T2 1 QX; A  0 B  Y; C  0 P  n CNT=0 CNT  CNT - 1 T1 Q0 A  shr A, An-1  C Q  shr Q, Qn-1  A0 C  0

Multiplier – Verilog Code 1/7 module TopModule(x, y, n, clk, start, reset, out, state, cnt); input [3:0] x, y, n; input clk, start, reset; output [8:0] out; output [1:0] state; output [3:0] cnt; reg [8:0] out; reg [1:0] state; reg [3:0] b, a, q, cnt; reg c; parameter t0=0, t1=1, t2=2, t3=3; parameter zero = 0; ...

Multiplier – Verilog Code 2/7 ... module TopModule(x, y, n, clk, start, reset, out, state); always @ * begin case (state) t0: out = {c, a, q}; t1: t2: t3: default: endcase end

Multiplier – Verilog Code 3/7 ... always @(posedge clk or posedge reset) begin if (reset) state <= t0; a <= zero; b <= zero; c <= zero; q <= zero; cnt <= zero; end else T0 S from T3 to T1 reset

Multiplier – Verilog Code 4/7 ... always @(posedge clk or posedge reset) begin if (reset) else case (state) t0: if(start) state <= t1; state <= t0; T0 S from T3 to T1 reset

Multiplier – Verilog Code 5/7 ... always @(posedge clk or posedge reset) begin if (reset) else case (state) t1: b <= y; q <= x; cnt <= n; state <= t2; end S QX; A  0 B  Y; C  0 CNT  n 1 T1 to T2 to T0 from T0

Multiplier – Verilog Code 6/7 ... always @(posedge clk or posedge reset) begin if (reset) else case (state) t2: if(q[0] == 1'b0) cnt <= cnt - 1; state <= t3; end {c, a} <= a + b; Q0 A  A + B, C  Cout 1 CNT  CNT - 1 T2 To T3

Multiplier – Verilog Code 7/7 ... always @(posedge clk or posedge reset) begin if (reset) else case (state) t3: if(cnt == 0) begin {c, a, q} <= {1'b0, c, a, q[3:1]}; state <= t0; end else begin state <= t2; endcase endmodule CNT==0 1 Shift Right CAQ, C  0 T3 from T2 to T2 to T0

Multiplier – Test Code 1/4 `timescale 1ns / 1ps module topmoduleTest; // Inputs reg [3:0] x; reg [3:0] y; reg [3:0] n; reg clk; reg start; reg reset; // Outputs wire [8:0] out; wire [1:0] state; wire [3:0] cnt; ...

Multiplier – Test Code 2/4 `timescale 1ns / 1ps module topmoduleTest; ... // Instantiate the Unit Under Test (UUT) TopModule uut ( .x(x), .y(y), .n(n), .clk(clk), .start(start), .reset(reset), .out(out), .state(state), .cnt(cnt) );

Multiplier – Test Code 3/4 `timescale 1ns / 1ps module topmoduleTest; ... initial begin // Initialize Inputs x = 0; y = 0; n = 0; clk = 0; start = 0; reset = 0;

Multiplier – Test Code 4/4 module topmoduleTest; ... initial begin // Wait 15 ns for global reset to finish #15 reset = 1; #10 reset = 0; #5 start = 1; n = 4; x = 10; y = 13; start = 0; #200; end always #10 clk = ~clk; endmodule

Multiplier – Simulation 1/3

Multiplier – Simulation 2/3

Multiplier – Simulation 3/3