Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example,

Slides:



Advertisements
Similar presentations
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Advertisements

Synchronous Sequential Logic
Combinational Logic.
Verilog Modules for Common Digital Functions
Combinational Circuits
Table 7.1 Verilog Operators.
2/9/20031 ECE 551: Digital System Design & Synthesis Lecture Set 4 4.1: Verilog – Procedural Assignments &Scheduling Semantics 4.2: Verilog – More Behavioral.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 8: Sequential Design Spring 2009 W. Rhett.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
ECE 551 Digital System Design & Synthesis Lecture 09 Synthesis of Common Verilog Constructs.
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.
ELEN 468 Lecture 151 ELEN 468 Advanced Logic Design Lecture 15 Synthesis of Language Construct I.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Advanced Verilog EECS 270 v10/23/06.
Digital System Design Verilog ® HDL Behavioral Modeling (1) Maziar Goudarzi.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Overview Logistics Last lecture Today HW5 due today
Combinational Logic in Verilog
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
Spring 2007W. Rhett Davis with slight modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 11: Memories,
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
ECE 2372 Modern Digital System Design
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 2: Introduction to Verilog Syntax Spring.
Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 2: Introduction.
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 3: Structural Modeling Spring 2009 W. Rhett.
ECE 551 Digital Design And Synthesis
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.
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example, Modeling Flip-Flops Spring.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Verilog Part 3 – Chapter.
3/4/20031 ECE 551: Digital System Design * & Synthesis Lecture Set 3 3.1: Verilog - User-Defined Primitives (UDPs) (In separate file) 3.2: Verilog – Operators,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
Appendix C Basics of Digital Logic Part I. Florida A & M University - Department of Computer and Information Sciences Modern Computer Digital electronics.
Introduction to ASIC flow and Verilog HDL
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 4: Testing, Dataflow Modeling Spring 2009.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 6: Procedural Modeling Spring 2009 W. Rhett.
Spring 20067W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 Design of Complex Digital Systems Lecture 11: Data Converter,
Verilog® HDL Behavioral Modeling (2)
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 9: State Machines & Reset Behavior Spring.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 10: Data-Converter Example Spring 2009 W.
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.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
ELEN 468 Advanced Logic Design
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Behavioral Modeling in Verilog
COE 202 Introduction to Verilog
332:437 Lecture 8 Verilog and Finite State Machines
Chapter 4: Behavioral Modeling
Supplement on Verilog combinational circuit examples
ECE 551: Digital System Design & Synthesis
332:437 Lecture 8 Verilog and Finite State Machines
Introduction to Verilog – Part-2 Procedural Statements
Presentation transcript:

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example, Modeling Flip-Flops Spring 2007 W. Rhett Davis NC State University with significant material from Paul Franzon, Bill Allen, & Xun Liu

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 2 Conditional Statements: if-else if - else if - else has the following syntax. if ( ) ; else if ( ) ; else ; If the logical value of is true, is executed. If the logical value of is false and the logical value of is true then is executed. If the logical values of both and are false, then is executed. Sutherland guide 10.3

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 3 ALU Example: if-else Code fragment of a 16-bit arithmetic logic unit (ALU) that performs one of 5 operations. if (alu_ctrl == 0) // alu_ctrl is 3 bits ALU_OUT = ALU_IN1 + ALU_IN2;// add else if (alu_ctrl == 1) ALU_OUT = ALU_IN1 - ALU_IN2;// subtract else if (alu_ctrl == 2) ALU_OUT = ALU_IN1 & ALU_IN2;// and else if (alu_ctrl == 3) ALU_OUT = ALU_IN1 | ALU_IN2;// or else if (alu_ctrl == 4) ALU_OUT = ALU_IN1 ^ ALU_IN2;// exor else ALU_OUT = 16’d0;// other 3 undefined

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 4 Conditional Statements: case The syntax of the case statement is: case ( ) : ; : ; default: ; endcase The value of is matched to in sequence, For the first that matches, the corresponding is executed. If no alternatives match, is executed. Sutherland guide 10.3

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 5 ALU Example: case Using the previous example of an ALU, the corresponding implementation using a case statement is: case (alu_ctrl) 3’d0: ALU_OUT = ALU_IN1 + ALU_IN2; 3’d1: ALU_OUT = ALU_IN1 - ALU_IN2; 3’d2: ALU_OUT = ALU_IN1 & ALU_IN2; 3’d3: ALU_OUT = ALU_IN1 | ALU_IN2; 3’d4: ALU_OUT = ALU_IN1 ^ ALU_IN2; default: ALU_OUT = 16’d0;

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 6 case: Comparison Details The case statement literally compares 0, 1, x and z values in the conditional expression bit-by-bit with the alternatives. Thus if the case expression is 4’b10xz, the comparison is looking for an alternative of 4’b10xz. In other words an exact match is required. Also, if the sizes of the evaluated expression and the alternative pattern are unequal, the shortest field is extended with zeros so the sizes are equal.

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 7 Alternatives: casex, casez There are two variants of the case statement defined by the keywords casex and casez. casex treats all x and z values in the case expression or alternatives as don’t cares. casez treats all z values in the case expression or alternatives as don’t care’s. The casex is useful when the state of certain bit positions is immaterial in some of the alternatives. By using casex in such situations, it is possible to reduce the number of alternatives needed. Sutherland guide 10.3

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 8 Procedural Examples l Muxes and Data Selectors reg [1:0] in1, in2, out; reg in3; or in2 or in3) if (in3) out = in1; else out = in2; in1[0] in2[0] in1[1] in2[1] in3 out[0] out[1] 1010 in1[0] in1[1] in1[2] in1[3] in out reg [3:0] in1; regout; reg [1:0] in2; or in2) case (in2) 2’b00 : out = in1[0]; 2’b01 : out = in1[1]; 2’b10 : out = in1[2]; 2’b11 : out = in1[3]; endcase

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 9 Procedural Examples l Priority Selector or Encoder or B or C) casex(A) 3’b1xx : out = B; 3’b01x : out = C; default : out = 2’b0; endcase l Decoder case (address) 2’b00 : line = 4’b0001; 2’b01 : line = 4’b0010; 2’b10 : line = 4’b0100; 2’b11 : line = 4’b1000; endcase

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 10 Latches l Complete the behavior below: or D) if (clock) Q = D; clock D Q l We will not intentionally build latches in this class l Instead, we’ll stick to one type of timing element (edge triggered flip-flops)

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 11 Inferred (Unintentional) Latches l What is happening here? or B or C) begin D = B & C; if (D) E = C; end

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 12 Procedural Examples l What about this? or B) casex (A) 2’b00 : C = B; 2’b01 : C = ~B; endcase

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 13 Procedural Examples l Will this simulate correctly? C = A | B;

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 14 D Flip-Flop Timing Diagram D clock Q D Q Don’t know (Don’t care) “x” Glitches at input do not appear at output. F/F only samples ‘D’ at positive clock edge.

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 15 D Flip-Flop Verilog Description D clock Q module flipflop (D, clock, Q); input D, clock; output Q; reg Q; clock) Q = D; endmodule posedge & negedge are keywords Could also be written as Q <= D; (what’s the difference?)

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 16 Blocking vs. Non Blocking l = is referred to as a blocking assignment, because execution of subsequent code is blocked until the assignment is made. l <= is referred to as non- blocking assignment. Essentially, all non-blocking right-hand-sides are evaluated but no assignments are made until the end of the procedural block. l Example: What’s the difference between the two code fragments to the right? T&M 1.3.3, Sutherland guide 10.2 clk) begin A = Y; B = A; end clk) begin A <= Y; B <= A; end

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 17 Inferring Hardware from Assignments l When given an clock) behavior and asked to draw a schematic, I follow these steps: » For every left-hand side of an assignment, draw a flip-flop whose output is connected to that signal » For non-blocking assignments (<=), set the input of each flip-flop to be the right-hand side of the last assignment for each variable » For blocking assignments (=), work back from the end to figure out the inputs to the flip-flops l When writing your own behavior, it is suggested that you use non-blocking assignments (<=), so that you don’t have to work back from the end.

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 18 Blocking vs. Non Blocking What hardware would be synthesized for this example? A = Y; B = A; A <= Y; B <= A;

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 19 Example reg A, B, C, D; clock) begin C = A; B = C; C = D; end

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 20 Example reg A, B, C, D; clock) begin C <= A; B <= C; C <= D; end

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 21 Example reg A, B, C, D; clock) begin if (A) D <= B; else D <= C; C <= D; end

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 22 Procedural Examples l Is there anything wrong with this code? or B) casex (A) 2’b00 : C = B; 2’b01 : C = ~B; endcase

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 23 Design Example l Design a module named “ALU”. l It has three 3-bit inputs A, B, and C and a 1-bit input E. l It has a 3-bit output R and a 1-bit output O. l When E is 1, » R is the bit-wise XOR of A and B, and » O is 1. l When E is 0, » R is the sum of B and C (both are assumed to be signed integers), and » O is the non-overflow indicator, which is 0 when signed overflow happens.

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 24 A Word About Overflow l Unsigned Overflow occurs when Carry-Out is 1 l Signed Overflow occurs when » the sum of positive numbers is negative OR » the sum of negative numbers is positive …or, equivalently… » the MSBs of the operands are equal AND » the MSB and Carry-Out of the result differ

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 25 Design Example l Draw a schematic to represent the hardware

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 26 Design Example l Write the Verilog module using Data-Flow (continuous assignments) ONLY.

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 27 Design Example l Write a procedural Verilog description (with

Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 28 Summary l How do you model a flip-flop? l What is the difference between blocking and non-blocking assignments? l How do you infer flip-flops for an clock) procedure with blocking or non-blocking assignments? l Is it better to use blocking or non-blocking assignments in an clock) procedure? Why?