Workshop Topics - Outline

Slides:



Advertisements
Similar presentations
FSM and Efficient Synthesizable FSM Design using Verilog
Advertisements

Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Table 7.1 Verilog Operators.
//HDL Example 5-1 // //Description of D latch (See Fig.5-6) module D_latch (Q,D,control); output Q; input.
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
Finite State Machine (FSM)  When the sequence of actions in your design depend on the state of sequential elements, a finite state machine (FSM) can be.
Introduction to Verilog
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
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.
ELEN468 Lecture 101 ELEN 468 Advanced Logic Design Lecture 10 Behavioral Descriptions IV.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 4 - Verilog 2 (Sequential.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
ELEN 468 Advanced Logic Design
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
ECE 301 – Digital Electronics Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #17)
ECE 331 – Digital Systems Design Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #19)
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior : initial blocks execute.
Sequential Logic in Verilog
1 COMP541 State Machines Montek Singh Feb 8, 2012.
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
ECE 2372 Modern Digital System Design
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
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.
ECE 551 Digital Design And Synthesis
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
EEE2243 Digital System Design Chapter 4: Verilog HDL (Sequential) by Muhazam Mustapha, January 2011.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
Module : FSM Topic : types of FSM. Two types of FSM The instant of transition from the present to the next can be completely controlled by a clock; additionally,
Register Transfer Level & Design with ASM
Verilog for Synthesis Ing. Pullini Antonio
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
Finite State Machine (FSM) Nattha Jindapetch December 2008.
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
Introduction to ASIC flow and Verilog HDL
Verilog hdl – II.
Introduction to Verilog
1 COMP541 State Machines - II Montek Singh Feb 13, 2012.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 9: State Machines & Reset Behavior Spring.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Modeling of Finite State Machines Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur.
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 8.1. The general form of a sequential circuit.
© Copyright 2004, Gaetano Borriello and Randy H. Katz
Supplement on Verilog Sequential circuit examples: FSM
Verilog Coding Guideline
CSE 370 – Winter Sequential Logic-2 - 1
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
The Verilog Hardware Description Language
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
Presentation transcript:

Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System Workshop 5 - Data types A Workshop 6 - Data types B Workshop 7 - Operators Workshop 8 - Signed arithmetic Workshop 9 - Behavioral modeling A Workshop 10 - Behavioral modeling B Workshop 11 - Behavioral modeling C Workshop 12 - Data flow modeling Workshop 13 - Coding Styles

Workshop 12 - Coding Styles Processor Stack FIFO Pipeline Finite State Machines – Moore and Mealy – State Diagram – Coding styles Exercise 12 Actel HDL coding style.pdf. Writing successful RTL Descriptions in verilog.pdf. FSMs and Synchronization.pdf

Processor Stack Processor Stack is a Last-In-First-Out (LIFO) Register Array. Last value pushed on the stack is the first one popped off it. A Stack is controlled by a single, internal, Stack Pointer (SP) Register, containing the current read/write location. SP content is used to push data into specific Stack location as well as pop data from specific Stack location. Stack has data I/O port, clock, reset, push, pop control signals and error flag (read from empty or write to full). inout data stack_array[0] stack_array[7] push pop err clk nrst

Guidelines for Stack Coding // Initialize stack array registers to zero using for loop or $readmeh If (rst) begin sp = 0 ; full = 0 ; empty = 1 ; err = 0 ; dout = 0 ; end else begin // out of reset if (push) // write to stack begin if (empty) begin stack[sp] = din ; empty = 0 ; end else if (full) err = 1 ; // no vacant place for write else begin stack[sp] = din ; sp = sp + 1 ; end /* increment stack if (sp==depth-1) full = 1 ; pointer (sp) */ end else if (pop) // read from stack begin if (sp == 0 && empty = 0) begin dout = stack[sp] ; empty = 1; end else if (sp == 0 && empty = 1) err = 1 ; // read from empty stack? else if (sp != 0) sp = sp-1 ; // decrement stack pointer if (full) full = 0; end end assign dataIO = (pop)? Dout : 8’bZ ; // continuous assignment

Stack Simulation

FIFO Register File First-In-First-Out is more complicated than stack. Like pipeline, it has 2 ends to be controlled. FIFO has distinct input and output and often used to balance between 2 clock domains with different data rates. There are 2 main conventions in representing FIFO read and write pointers: a. point to the next valid (reg) address. b. point to the most currently used one. In this course, we shall adopt the former convention (a). The read pointer must point to valid next data to be read. The write pointer must point to the unused register into which the next data will be written.

FIFO Schematics fifo_array[7] fifo_array[0] data_in clki nrst write read clko fifo_array[0] fifo_array[7] data_out pointer read and write pointers are internal

Guidelines for behavioral FIFO Coding // Initialize all FIFO register file to zero reg[width-1:0] fifo[0:depth-1] If (rst) begin wp=0;full=0;empty=1; end //wp points to 1st empty slot assign dout = fifo[0] ; // first stage of fifo is output always@(posedge clk) begin if (rd & ~wr) begin // shift-out (assumes: at least 1 valid value in fifo) for (i = 1 ; i < wp ; i = i + 1) begin // shift all valid entries fifo[i-1] <= fifo[i] ; wp <= wp-1 ; full <= 0 ; end if (wp==0) begin empty <= 1 ; else empty <= 0 ; end end If (~rd & wr) begin // shift-in (assumes: at least 1 entry free) fifo[wp] <= din ; wp <= wp + 1 ; empty <= 0 ; if (wp==depth) full <= 1 ; else full <= 0 ; end If(rd & wr) begin //simult shift-in/shift-out. At least 1 valid entry for (i = 1 ; i < wp ; i = i + 1) fifo[i-1] <= fifo [i] ; fifo[wp-1] <= din ; end end

FIFO Simulation

Pipeline Pipelines, queues, and FIFOs are common logic structures which are all related, in the sense that data moves from one storage location to another synchronously, based on a strobe signal, usually a clock. always @(posedge clock) begin // use non-blocking assignments out <= pipe[3] ; pipe[3] <= pipe[2] ; pipe[2] <= pipe[1] ; pipe[1] <= in ; end // assignments order is irrelevant s1out s2out in stage1 stage2 stage3 out

Pipe Stage as Separate Module It is common to make a single pipe stage module and use it repetitively, as follows: module pipeline(out, in, clock) ; input clock, in ; output wire out ; wire s1out, s2out ; pipestage s1(s1out, in, clock), s2(s2out, s1out, clock), s3(out, s2out, clock) ; endmodule module pipestage(out, in, clock) ; input clock, in ; output reg out ; always @(posedge clock) out <= in ;

Combinational Logic in Pipeline It is more interesting if there is some combinational logic associated with each pipe stage. Suppose each stage has some logic represented by a function f1, f2, f3 which is applied to the input. module pipeline(out, in, clock) ; input clock, in : output out ; wire s1out, s2out, s1in, s2in, s3in ; assign s1in = f1(in), s2in = f2(s1out), s3in = f3(s2out) ; pipelinestage s1(s1out, s1in, clock), s2(s2out, s2in, clock), s3(out, s3in, clock) ; endmodule in f1 s1 f2 s2 f3 s3 out

Finite State Machines

Two types of Finite State Machines combinational logic sequential logic combinational logic Moore State Machine combinational logic sequential logic combinational logic Mealy State Machine

Moore and Mealy FSMs There are two common variations of state machines, Mealy and Moore machines. Mealy machines produce outputs based on both current state and inputs. Moore machines produce outputs based only on the current state. Typically, the clock is used to change the state based on the inputs which have been seen up to that point. It is often convenient to think that all state machine activities, are taking place on the clock edge: sample inputs compute next state compute outputs change state produce outputs

State Machine Guidelines Draw a state diagram. Label the states. Allocate state encoding. Label the transition conditions. Label the output values. Use parameters for the state variables. Use two procedures (one clocked for the state register and one combinational for the next state logic and the output decode logic). Use a case statement in the combinational procedure. Have a reset strategy (asynchronous or synchronous). Use default assignments and then corner cases. Keep state machine code separate from other code (i.e. don’t mix other logic in with the state machine clocked and combinational procedures).

Sequence Detector State Diagram Sequence detector implemented with Mealy FSM. Detect a sequence of 1011 in serial input and overlapping sequences So, if 1011011 come, sequence is repeated twice. nrst state zero in=0 out=0 state five State one in=1 in=1 in=1 out=1 in=0 out=0 in=1 // parametric states parameter zero = 2’b00, one = 2’b01, two = 2’b10, five = 2’b11 ; in=0 state two in=0 out=0

State Machine Coding module sd_1011( clk, nrst, in, out) ; input clk, nrst, in ; output reg out ; reg [1:0] state ; always @(posedge clk or negedge nrst) begin // use non-blocking assignments if(!nrst) begin out <= 0 ; state <= 2'b00 ; end else begin // Register FSM outputs are Glitch-Free case({state,inp}) //combined state & inp -> smaller code. 3'b000: begin state <= 2'b00 ; out <= 0 ; end 3'b001: begin state <= 2'b01 ; out <= 0 ; end 3'b010: begin state <= 2'b10 ; out <= 0 ; end 3'b011: begin state <= 2'b01 ; out <= 0 ; end 3'b100: begin state <= 2'b00 ; out <= 0 ; end 3'b101: begin state <= 2'b11 ; out <= 0 ; end 3'b110: begin state <= 2'b10 ; out <= 0 ; end 3'b111: begin state <= 2'b01 ; out <= 1 ; end endcase end endmodule

Sequence Detector Simulation