Dataflow Verilog ECEn 224.

Slides:



Advertisements
Similar presentations
Digital System Design-II (CSEB312)
Advertisements

VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Counters Discussion D8.3.
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
EE 361 Fall 2003University of Hawaii1 Hardware Design Tips EE 361 University of Hawaii.
Combinational Logic.
Chap. 6 Dataflow Modeling
Verilog Modules for Common Digital Functions
Review for Exam 2 Using MUXs to implement logic
Table 7.1 Verilog Operators.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
//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.
ECE 551 Digital System Design & Synthesis Lecture 08 The Synthesis Process Constraints and Design Rules High-Level Synthesis Options.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
ELEN 468 Lecture 151 ELEN 468 Advanced Logic Design Lecture 15 Synthesis of Language Construct I.
Copyright © 2007 Elsevier4- Chapter 4 :: Hardware Description Languages Digital Design and Computer Architecture David Money Harris and Sarah L. Harris.
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.
2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Advanced Verilog EECS 270 v10/23/06.
D Flip-Flops in Verilog Discussion 10.3 Example 27.
Quad 2-to-1 Multiplexer Discussion D7.4 Example 7.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Overview Logistics Last lecture Today HW5 due today
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
Programmable Logic Architecture Verilog HDL FPGA Design Jason Tseng Week 5.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
Workshop Topics - Outline
Introduction Verilog is a HARDWARE DESCRIPTION LANGUAGE (HDL) A hardware description language is a language or means used to describe or model a digital.
Introduction to FPGA Development Justin Thiel Two Sigma Investments.
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.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
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,
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
February 6, 2009http://csg.csail.mit.edu/6.375/L02-1 Verilog 1 - Fundamentals Complex Digital Systems Arvind February 6, 2009 FA module adder( input.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
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.
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Digital System Design Verilog ® HDL Dataflow Modeling Maziar Goudarzi.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
1 Lecture 1: Verilog HDL Introduction. 2 What is Verilog HDL? Verilog Hardware Description Language(HDL)? –A high-level computer language can model, represent.
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
ELEN 468 Advanced Logic Design
Reg and Wire:.
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Behavioral Modeling in Verilog
Chapter 3: Dataflow Modeling
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value
Basic Logic Gates and Truth Tables
Verilog.
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value
The Verilog Hardware Description Language
Supplement on Verilog combinational circuit examples
Presentation transcript:

Dataflow Verilog ECEn 224

Motivation Structural design can be cumbersome Lots of typing 32-bit busses & logic Structural designs are static At least in Verilog (not so for VHDL) Little or no parameterization possible ECEn 224

A Dataflow MUX – Version 1 module mux21(q, sel, a, b); input sel, a, b; output q; assign q = (~sel & a) | (sel & b); endmodule Much simpler, less typing, familiar C-like syntax. Synthesizer turns it into optimized gate-level design. ECEn 224

A Dataflow MUX – Version 2 module mux21(q, sel, a, b); input sel, a, b; output q; assign q = sel ? b : a; endmodule Even simpler, uses C-like ternary ( ?: ) construct ECEn 224

Dataflow Operators ECEn 224

Bitwise vs. Logic Operators Similar to C assign q = ((a<4’b1101) && ((c&4’b0011)!=0)) ? 1’b0:1’b1; “1101” Pseudo-code (not real Verilog): if (a<4’b1101 && (c&4’b0011) != 0) then q <= ‘0’; else q <= ‘1’; 4 4 < a 1 q 4 c 4 1 “0011” 4 Use &&, ||, ! for 1-bit quantities (results of comparisions) Use &, |, ~ for bit-by-bit logical operations ECEn 224

Reduction Operators wire[3:0] x; wire z; assign z = &x; // Same as z = x[3] & x[2] & x[1] & x[0] ECEn 224

Concatenation and Replication Operators wire[3:0] x, y; wire[7:0] z, q, w, t; wire[31:0] m, n; assign x = 4’b1100; assign y = 4’b0101; assign z = {x, x}; // z is 8’b11001100 assign q = {x, y}; // q is 8’b11000101 assign w = {4’b1101, y}; // w is 8’b11010101 assign t = {2{x}}; // same as {x, x} assign m = {{4{x}}, {2{q}}}; // m is 32’b11001100110011001100010111000101 ECEn 224

Operator Precedence Similar to C ECEn 224

A Note on Matching Widths This a valid 2:1 MUX statement: But the following is not: Why? wire a, b, sel, q; assign q = (~sel & a) | (sel & b); wire[3:0] a, b, q; wire sel; assign q = (~sel & a) | (sel & b); ECEn 224

More On Matching Wire Widths This is an acceptable substitute: It turns the sel and ~sel values into 4-bit versions for AND-ing and OR-ing A more elegant version: wire[3:0] a, b, q; wire sel; assign q = ({4{~sel}}&a)|({4{sel}}&b); wire[3:0] a, b, q; wire sel; assign q = sel ? b: a; ECEn 224

Design Example: A 2:4 Decoder module decode24(q, a); output[3:0] q; input[1:0] a; assign q = (4’b0001) << a; endmodule Can you see how to make a 3:8 or 4:16 decoder in the same fashion? ECEn 224

Multi-bit Design and Parameterization ECEn 224

A Dataflow MUX – Multi-Bit module mux21(q, sel, a, b); input sel; input[15:0] a, b; output[15:0] q; assign q = sel ? b : a; endmodule 16 a 1 16 q 16 b s Key Ideas: The predicate must evaluate to true or false (1 or 0) The parts getting assigned must be all same widths. ECEn 224

A Dataflow MUX – Parameterized Width module mux21n(q, sel, a, b); parameter WID = 16; input sel; input[WID-1:0] a, b; output[WID-1:0] q; assign q = sel ? b : a; endmodule By default, this is now a 16-bit wide MUX. When instantiating, the default value of 16 can be overridden: mux21n M1(q, sel, a, b); // Instance a 16-bit version mux21n #(4) M0(q, sel, a, b); // Instance a 4-bit version Does this work for a 1-bit MUX? ECEn 224

Using Parameterization Careful planning often allows you to write one design which can be reused Reuse is a common goal in design Simplifies your work Eliminates errors Saves time later Whenever possible, plan for reuse ECEn 224

Parameterization Exercise Design a 4:1 MUX that works with any size operands (arbitrary bit-width) Either: Build arbitrary bit-width 2:1 MUX Structurally instance 3 of these to make a 4:1 MUX or Write an arbitrary bit-width 4:1 MUX using the ?: operator ECEn 224

4:1 MUX – Method 1 module mux41n(q, sel, a, b, c, d); parameter WID=16; input[1:0] sel; input[WID-1:0] a, b, c, d; output[WID-1:0] q; wire[WID-1:0] tmp1, tmp2; mux21n #(WID) M0(tmp1, sel[0], a, b); mux21n #(WID) M1(tmp2, sel[0], c, d); mux21n #(WID) M2(q, sel[1], tmp1, tmp2); endmodule If the mux21n cells are parameterizable for bit-width this works… If not, it doesn’t work… ECEn 224

4:1 MUX – Method 2 module mux41(q, sel, a, b, c, d); parameter WID=16; input[1:0] sel; input[WID-1:0] a, b, c, d; output[WID-1:0] q; assign q = (sel==2'b00) ? a: (sel==1) ? b: (sel==2’b10) ? c: d; endmodule Cascaded ?: operators form an if-then-else structure Note how sel can be compared to bit patterns (2’b00) or to numbers (1) ECEn 224

Behavioral Verilog ECEn 224

Used for Sequential Circuits and Combinational Circuits module dff(clk, d, q); input clk, d; output reg q; always @(posedge clk) q <= d; endmodule You can use this as a DFF for your design. Figure out how to parameterize it for arbitrary input/output widths Remainder of behavioral design not covered in this class… ECEn 224

Conclusion With what you know… Behavioral Design You can do reasonable designs Must structurally instance all storage elements (flip flops) Behavioral Design A number of nuances with respect to timing semantics Not recommended beyond simple FF’s for this class You will learn full range of behavioral design in later courses ECEn 224