332:437 Lecture 10 Verilog Language Details

Slides:



Advertisements
Similar presentations
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Advertisements

Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Synchronous Sequential Logic
Combinational Logic.
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
Verilog - 1 Writing Hardware Programs in Abstract Verilog  Abstract Verilog is a language with special semantics  Allows fine-grained parallelism to.
ELEN 468 Lecture 151 ELEN 468 Advanced Logic Design Lecture 15 Synthesis of Language Construct I.
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Overview Logistics Last lecture Today HW5 due today
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,
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
Programmable Logic Architecture Verilog HDL FPGA Design Jason Tseng Week 5.
ECE 2372 Modern Digital System Design
Verilog Language Concepts
1 An Update on Verilog Ξ – Computer Architecture Lab 28/06/2005 Kypros Constantinides.
Introduction to FPGA Development Justin Thiel Two Sigma Investments.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Verilog for Synthesis Ing. Pullini Antonio
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
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.
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
Introduction to ASIC flow and Verilog HDL
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
An Introduction to Verilog: Transitioning from VHDL
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
ELEN 468 Advanced Logic Design
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
‘if-else’ & ‘case’ Statements
Verilog Coding Guideline
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Behavioral Modeling in Verilog
Chapter 3: Dataflow Modeling
UNIT 3: Behavioral Descriptions
332:437 Lecture 10 Verilog Language Details
332:437 Lecture 7 Verilog Hardware Description Language Basics
SYNTHESIS OF SEQUENTIAL LOGIC
ECE 434 Advanced Digital System L10
COE 202 Introduction to Verilog
332:437 Lecture 8 Verilog and Finite State Machines
332:437 Lecture 7 Verilog Hardware Description Language Basics
332:437 Lecture 10 Verilog Language Details
332:437 Lecture 7 Verilog Hardware Description Language Basics
Verilog Synthesis Synthesis vs. Compilation
The Verilog Hardware Description Language
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
The Verilog Hardware Description Language
Supplement on Verilog combinational circuit examples
ECE 551: Digital System Design & Synthesis
332:437 Lecture 8 Verilog and Finite State Machines
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

332:437 Lecture 10 Verilog Language Details Parameters Blocking Assignment Operator Delay time units Arrays of registers FIFO Example Flip-flop descriptions Verilog Operators Summary Material from The Verilog Hardware Description Language, by Thomas and Moorby, Kluwer Academic Publishers, VHDL for Programmable Logic, by Kevin Skahill, Addison Wesley Longman. 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Parameters Parameters – hold value that cannot change within design description #(parameter width = 8, delay=10) assign #(delay) xout <= xin1 ^ xin2; 11/29/2018 Thomas: Digital Systems Design Lecture 10

Blocking Assignment Operator Can be used everywhere, including in functions & tasks MAY NOT BE SYNTHESIZED INTO WIRES OR MEMORY ELEMENTS Blocking assignment –- immediate, not scheduled, holds only 1 value at a time = is the blocking assignment operator 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 8-Bit AND Gate AND gate code that works properly Does not declare variable “i” – when “i” used in a loop, it gets implicitly declared module will_work (); wire temp, bit; always @(a_bus) begin temp = 1; for (i = 7; i >= 0; i = i - 1) temp = a_bus (i) and temp; end endmodule 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Time Units for #delay Specify by: `timescale <time_unit> / <time_precision> Example: `timescale 10 ns / 1 ns // Each time unit is // 10 ns, maintained to a precision of 1 ns Unit of Measurement Abbreviation seconds s milliseconds ms microseconds us nanoseconds ns picoseconds ps femtoseconds fs 11/29/2018 Thomas: Digital Systems Design Lecture 10

Composite Types -- Memories Arrays of registers reg [0:3] table8xr4 [0:7]; initial begin table8xr4 = {b’000_0, b’001_1, b’010_1, b’011_0, b’100_1, b’101_0, b’110_0, b’111_1}; end 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Arrays Can insert underscore between any two adjoining digits in the array values Hexadecimal and octal fill bit arrays with bits Three equivalent statements: a <= 2’x7A; // bit string hex “01111010” a <= 3’o172; // octal (base 8) a <= 8’b01111010; // binary x and z single digit values automatically fill out to entire width of number When fewer binary, octal, or hexadecimal digits are specified than the width of the number, the unspecified leftmost digits are set to 0 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Verilog Attributes Give some property of a signal full_case – all case items are specified explicitly or by default Causes case statement to be considered to be full, even though all cases are not specified Unspecified cases are treated as don’t cares for synthesis, and no latch is inferred parallel_case – Verilog case statement is allowed to have overlapping case items Statements for items are executed in the order specified Leads to complex logic – a priority encoder Parallel_case means that the synthesis tool assumes that there are no overlapping items in the case statement, and it will implement it as a sum-of-products expression with a MUX 11/29/2018 Thomas: Digital Systems Design Lecture 10

Verilog Attribute Example module synAttributes (output reg f, input a, b, c); always @(*) (* full_case, parallel_case *) case ({a, b, c}) 3’b001: f = 1’b1; 3’b010: f = 1’b1; 3’b011: f = 1’b1; 3’b100: f = 1’b1; 3’b110: f = 1’b0; 3’b111: f = 1’b1; endcase endmodule 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Verilog FIFO Example Concurrent statements – lie outside of process, so order of execution is unimportant Creates an aggregate of correct width to match fifo (i) width – Decimal 0 is a convenient shorthand for an arbitrarily wide vector of zeroes 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 FIFO module fifo (clk, rst, oe, rd, wr, rdinc, wrinc, rdptrclr, wrptrclr, data_in, data_out); parameter wide = 31, deep = 20, counter = 5; input clk, rst, oe, rd, wr, rdinc, wrinc, rdptrclr, wrptrclr; input [wide:0] data_in, output [wide:0] data_out; reg [wide:0] data_outx; wire negrst; reg [wide:0] fifo [deep:0]; reg [counter:0] wrptr; reg [counter:0] rdptr; reg [counter:0] realrdptr; reg [counter:0] realrdptrb; reg [counter:0] i; 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 FIFO (continued) // fifo register array always @(posedge rst or posedge clk) begin if (rst == 1'b1) begin for (i = 0; i < deep; i = i + 1) begin fifo [i] <= 'b0; end end else begin if (wr == 1'b1) fifo [wrptr] <= data_in; end end 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 FIFO (continued) // read pointer always @(posedge rst or posedge clk) begin if (rst == 1'b1) rdptr <= 32'b0; else if (clk == 1) begin if (rdptrclr == 1'b1) rdptr <= 'b0; else if (rdinc == 1'b1) rdptr <= realrdptr + 1; end 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 FIFO (continued) // force Synopsys to give us a rdptr flip-flop register // this had to be coded structurally, because Synopsys // design_analyzer refused to create a flip-flop for rdptr GTECH_FD2 (rdptr [0], clk, negrst, realrdptr [0], realrdptrb [0]), (rdptr [1], clk, negrst, realrdptr [1], realrdptrb [1]), (rdptr [2], clk, negrst, realrdptr [2], realrdptrb [2]), (rdptr [3], clk, negrst, realrdptr [3], realrdptrb [3]), (rdptr [4], clk, negrst, realrdptr [4], realrdptrb [4]), (rdptr [5], clk, negrst, realrdptr [5], realrdptrb [5]); 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 FIFO (continued) // write pointer always @(posedge rst or posedge clk) begin if (rst == 1'b1) wrptr <= 32'b0; else if (clk == 1) begin if (wrptrclr == 1'b1) wrptr <= 'b0; else if (wrinc == 1'b1) wrptr <= wrptr + 1; end end 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 FIFO (concluded) // three-state control of outputs always @(oe) begin if ((oe == 1'b1) && (rd == 1’b1)) data_outx <= fifo [wrptr]; else data_outx <= 'bz; end assign data_out = data_outx; endmodule 11/29/2018 Thomas: Digital Systems Design Lecture 10

Synthesized Priority Encoder (*parallel_case*) case({w, x, y, z}) 4’b1xxx: j = a; 4’bx1xx: j = b; 4’bxx1x: j = c; 4’bxxx1: j = d; default: j = 0; endcase 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Level Sensitive Latch always @(clk, d) begin if (clk == 1’b 1) q <= d; end 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 T Flip-Flop module tff_logic (input t, input clk, output q); always @(posedge clk) begin if (t == 1’b1) q <= not (q); else q <= q; end endmodule 11/29/2018 Thomas: Digital Systems Design Lecture 10

8-bit Register Description module reg_logic (input [0:7] d, input clk, output [0:7] q); always @(posedge clk) begin q <= d; end endmodule 11/29/2018 Thomas: Digital Systems Design Lecture 10

Alternate Clocking Descriptions Give up now on writing a single process for design_analyzer with events on both the rising and falling clock edges It will never let you do it Instead, write this as two separate processes Moral: Only a subset of the legal Verilog code can be synthesized by design_analyzer 11/29/2018 Thomas: Digital Systems Design Lecture 10

8-bit Register, Asynchronous Reset, Synchronous Preset module reg_logic (input d [0:7], input reset, input init, input clk, output q [0:7]); always @(posedge clk, posedge reset) begin if (reset == 1’b1) q <= 8’b0; else if (init == 1’b1) q <= 8’b11111111; // decimal -1 q <= d; end endmodule 11/29/2018 Thomas: Digital Systems Design Lecture 10

Problems with Don’t Cares Synthesis treats x as a 1 that cannot occur Real hardware never has signals with x Comparing x to 0 or 1 with === operator always evaluates to false WHY? Because 0 or 1 does not EXACTLY match x 11/29/2018 Thomas: Digital Systems Design Lecture 10

Verilog Relational Operators Obvious: ==, !=, <, <=, >, >= Unknown (x) or high-impedance (z) values are treated as 0 Case equality: === Unknown (x) or high-impedance (z) values must match exactly Case inequality: !== 11/29/2018 Thomas: Digital Systems Design Lecture 10

Concatenation Operator Collects multiple signals into an n-bit value {a, b, c, d} Aggregates 4 signals a, b, c, d into a 4-bit value in the order specified 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Boolean Operators Logical negation ! Logical AND && Logical OR || Bitwise negation ~ Bitwise AND & Bitwise | Bitwise XOR ^ Equivalence ^~ or ~^ 11/29/2018 Thomas: Digital Systems Design Lecture 10

Advanced Boolean Operators Single bit AND of all operand bits & Single bit OR of all operand bits | Single bit NAND of all operand bits ~& Single bit NOR of all operand bits ~| Single bit XOR of all operand bits ^ Single bit XNOR of all operand bits ~^ Left Shift << Right shift >> Arithmetic shift left <<< Arithmetic shift right >>> Conditional as in the C language ?: Convert to signed $signed (m) Convert to unsigned $unsigned (m) 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Arithmetic Operators Adding + Subtracting - Multiplying * Dividing / Often refuses to synthesize hardware for this Power ** Modulus % 11/29/2018 Thomas: Digital Systems Design Lecture 10

Thomas: Digital Systems Design Lecture 10 Summary Parameters Blocking Assignment Operator Delay time units Arrays of registers FIFO Example Flip-flop descriptions Verilog Operators 11/29/2018 Thomas: Digital Systems Design Lecture 10