Supplement on Verilog for Algorithm State Machine Chart

Slides:



Advertisements
Similar presentations
Counters Discussion D8.3.
Advertisements

Traffic light contoller using FSM
CPSC 321 Computer Architecture Andreas Klappenecker
CDA 3100 Recitation Week 11.
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Supplement on Verilog adder examples
Synchronous Sequential Logic
Multiplication and Division
Table 7.1 Verilog Operators.
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
FSM examples.
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
Pulse-Width Modulated DAC
1 COMP541 Sequencing and Control Montek Singh Mar 29, 2007.
Logic Design Review – 3 Basic Sequential Circuits Lecture L14.3 Verilog.
Arbitrary Waveform Discussion 12.2 Example 34. Recall Divide-by-8 Counter Use q2, q1, q0 as inputs to a combinational circuit to produce an arbitrary.
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.
2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.
Design example Binary Multiplier.
Registers and Shift Registers Discussion D8.2. D Flip-Flop X 0 Q 0 ~Q 0 D CLK Q ~Q D gets latched to Q on the rising edge of the clock. Positive.
Verilog Descriptions of Digital Systems. Electronic Lock // // Electronic combinational lock // module lock(seg7,key, valid_key, col, row, mclk, resetL)
Figure 7.1. Control of an alarm system. Memory element Alarm Sensor Reset Set OnOff 
Verilog Digital System Design Z. Navabi, 2006
Registers & Counters M. Önder Efe
Figure A flip-flop with an enable input. D Q Q Q R Clock E 0 1.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
1 ECE 545—Digital System Design with VHDL Lecture 6 Behavioral VHDL Coding (for Synthesis): Finite State Machines and ASMs 9/30/08.
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
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.
Register Transfer Level & Design with ASM
Final Project. System Overview Description of Inputs reset: When LOW, a power on reset is performed. mode: When LOW, NORMal mode selected When HIGH,
Figure ASM chart for the bit counter.. Figure Verilog code for the bit-counting circuit (Part a). module bitcount (Clock, Resetn, LA, s,
Digital Electronics.
ECE/CS 352 Digital System Fundamentals© T. Kaminski & C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Fall 2000 Chapter 5 – Part 2 Tom Kaminski & Charles.
SYEN 3330 Digital SystemsJung H. Kim 1 SYEN 3330 Digital Systems Chapter 7 – Part 2.
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.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 10: Data-Converter Example Spring 2009 W.
1 (c) W. J. Dally Digital Design: A Systems Approach Lecture 7: Data Path State Machines.
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..
Exp#7 Finite State Machine Design in Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Overview Logistics Last lecture Today HW5 due today
Supplement on Verilog FF circuit examples
Figure 8.1. The general form of a sequential circuit.
Supplement on Verilog Sequential circuit examples: FSM
CS Fall 2005 – Lec. #5 – Sequential Logic - 1
Pulse-Width Modulation (PWM)
Analog-to-Digital Converters
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
Verilog.
ESE 437: Sensors and Instrumentation
ECE 448 Lecture 13 Multipliers Timing Parameters
6. Registers and Counters
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.
ASM and Micro-programmed State Machines
The Verilog Hardware Description Language
Foundations for Datapath Design
Supplement on Verilog combinational circuit examples
Lecture 4: Continuation of SystemVerilog
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:

Supplement on Verilog for Algorithm State Machine Chart Based on Fundamentals of Digital Logic with Verilog Design and Fundamental of Logic Design Chung-Ho Chen

Problem: Bit Counter Count the number of 1s’ in A And store the number of 1s in B B = ; while A  do if a 1 then + end if; Right-shift end while;

ASM Chart for Bit Counter Initialize B S2 S1 Start another ? B = ; while A  do if a 1 then + end if; Right-shift end while; s=1, start counting Load B Shift A Update B (a0=1) Conditional output S2 which performs the shift is actually shifted at the next clock edge, so the checking of A, and a0 are performed before the shift of A.

Datapath for the bit counter If n = 8, need how many bits? A shift register A counter register Need to test if a0=1 Need test if A=0? Need load/enable signals +1 +1 A <> 0?

ASM Chart for Bit Counter to Verilog Code module bitcount (Clock, Resetn, LA, s, Data, B, Done); input Clock, Resetn, LA, s; input [7:0] Data; output reg [3:0] B; output reg Done; wire [7:0] A; wire z; reg [1:0] Y, y; reg EA, EB, LB; // control circuit parameter S1 = 2'b00, S2 = 2'b01, S3 = 2'b10; always @(s, y, z) begin: State_table case (y) S1: if (!s) Y = S1; else Y = S2; S2: if (z == 0) Y = S2; else Y = S3; S3: if (s) Y = S3; else Y = S1; default: Y = 2'bxx; endcase end always @(posedge Clock, negedge Resetn) begin: State_flipflops if (Resetn = = 0) y <= S1; else y <= Y; … continued in Part b. ASM Chart for Bit Counter to Verilog Code LB Start another ? y: PS Y: NS s=1, start counting EA Conditional output Z EB

ASM Chart for Bit Counter to Verilog Code always @(y, A[0]) begin: FSM_outputs // Control data path // defaults EA = 0; LB = 0; EB = 0; Done = 0; case (y) S1: LB = 1; S2: begin EA = 1; if (A[0]) EB = 1; else EB = 0; end S3: Done = 1; endcase   // datapath circuit // counter B always @(negedge Resetn, posedge Clock) if (!Resetn) B <= 0; else if (LB) else if (EB) B <= B + 1; shiftrne ShiftA (Data, LA, EA, 0, Clock, A); assign z = ~| A; // reduction NOR. endmodule ASM Chart for Bit Counter to Verilog Code Outputs in a state LB Start another ? s=1, start counting EA Conditional output Z EB

Shift Right Register module shiftrne (R, L, E, w, Clock, Q); parameter n = 4; input [n-1:0] R; input L, E, w, Clock; output reg [n-1:0] Q; integer k;   always @(posedge Clock) begin if (L) Q <= R; else if (E) Q[n-1] <= w; for (k = n-2; k >= 0; k = k-1) Q[k] <= Q[k+1]; end endmodule