The Verilog Hardware Description Language

Slides:



Advertisements
Similar presentations
Verilog.
Advertisements

The Verilog Hardware Description Language
Supplement on Verilog adder examples
Verilog Intro: Part 1.
Hardware Description Language (HDL)
Combinational Logic with Verilog Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer.
16/04/20151 Hardware Descriptive Languages these notes are taken from Mano’s book It can represent: Truth Table Boolean Expression Diagrams of gates and.
Anurag Dwivedi.  Verilog- Hardware Description Language  Modules  Combinational circuits  assign statement  Control statements  Sequential circuits.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
1 Brief Introduction to Verilog Weiping Shi. 2 What is Verilog? It is a hardware description language Originally designed to model and verify a design.
ECE 551 Digital System Design & Synthesis Lecture 08 The Synthesis Process Constraints and Design Rules High-Level Synthesis Options.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
ECE 353 Computer Systems Lab I Verilog Hardware Description Language.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
Hardware Description Language HDL. 2 Hardware Description Language HDL  Describes circuits and systems in text. −As a software program.  Can be processed.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
Lecture 7 Verilog Additional references Structural constructs
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
ECE 2372 Modern Digital System Design
ECE/CS 352 Digital Systems Fundamentals
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
C ONTINUOUS A SSIGNMENTS. C OMBINATIONAL L OGIC C IRCUITS each output of a Combinational Logic Circuit  A function of the inputs - Mapping functions.
1 An Update on Verilog Ξ – Computer Architecture Lab 28/06/2005 Kypros Constantinides.
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
CPEN Digital System Design
Module 2.1 Gate-Level/Structural Modeling UNIT 2: Modeling in Verilog.
Module 1.2 Introduction to Verilog
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Introduction to ASIC flow and Verilog HDL
ECE 171 Digital Circuits Chapter 8 Hardware Description Language Herbert G. Mayer, PSU Status 11/23/2015 Copied with Permission from prof. Mark
Introduction to Verilog. Data Types A wire specifies a combinational signal. – Think of it as an actual wire. A reg (register) holds a value. – A reg.
Introduction to Verilog
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter1: Introduction Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 1-1 Chapter 1: Introduction Prof. Ming-Bo.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
1 A hardware description language is a computer language that is used to describe hardware. Two HDLs are widely used Verilog HDL VHDL (Very High Speed.
Introduction to Verilog COE 202 Digital Logic Design Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals.
Hardware Description Languages: Verilog
An Introduction to Verilog: Transitioning from VHDL
ELEN 468 Advanced Logic Design
Reg and Wire:.
Discussion 2: More to discuss
Verilog Introduction Fall
Lecture 2 Supplement Verilog-01
Hardware Description Languages: Verilog
Hardware Description Languages
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Chapter 4 Combinational Logic
Introduction to Verilog
Hardware Descriptive Languages these notes are taken from Mano’s book
Behavioral Modeling in Verilog
Introduction to Verilog
VHDL Hardware Description Language
102-1 Under-Graduate Project Verilog
Hardware Descriptive Languages these notes are taken from Mano’s book
The Verilog Hardware Description Language
Supplement on Verilog adder examples
Chapters 4 – Part3: Verilog – Part 1
The Verilog Hardware Description Language
COE 202 Introduction to Verilog
Presentation transcript:

The Verilog Hardware Description Language

GUIDELINES How to write HDL code:

GUIDELINES How NOT to write HDL code:

Think Hardware NOT Software Poorly written HDL code will either be: Unsynthesizable Functionally incorrect Lead to poor performance/area/power results

Conventions Verilog IS case sensitive Syntax is based on C CLOCK, clock and Clock are different Syntax is based on C but is interpreted differently

Verilog code basic structure module module_name (ports); input input_signals; output output_signals; inout bidirectional signals; wire wire_signals; reg register_type_variables; primitive/component (ports); concurrent/sequential assignments endmodule

Port types PORT DIRECTION SIGNAL TYPE - input -output -inout scalar ( input x; ) vector (input [WIDTH -1 : 0] x)

Module port declaration example (1/2) module and_gate (o, i1, i2); output o; input i1; input i2; endmodule

Module port declaration example (2/2) module adder (carry, sum, i1, i2); output carry; output [3:0] sum; input [3:0] i1, i2; endmodule

Example

Verilog Primitives Verilog primitives are models of common combinational logic gates Their functionality is built into the language and can be instantiated in designs directly The output port of a primitive must be first in the list of ports

Structural description example (implicit connection) module gates (o,i0,i1,i2,i3); output o; input i0,i1,i2,i3; wire s1, s2; and a0 (s1, i0, i1); and a1 (s2, i2, i3); and a2 (o, s1, s2); endmodule

Structural description example (explicit connection) module gates (o,i0,i1,i2,i3); output o; input i0,i1,i2,i3; wire s1, s2; and a0 ( .o (s1), .i1 (i0), .i2 (i1) ); and a1 ( .o (s2), .i1 (i2), .i2 (i3) and a2 ( .o (o), .i1 (s1), .i2 (s2) endmodule

Verilog operators Arithmetic Bitwise Relational +, - , *, Synthesizable /, % Non-synthesizable Bitwise & AND | OR ~ NOT ^ XOR ~^ XNOR Relational =, <, >, <=, >=

User-Defined Primitives Truth Table Models primitive my_UDP (y, x1, x2, x3); output y; //the output of a primitive cannot be a vector!! input x1, x2, x3; table //x1 x2 x3 : y 0 0 0 : 0; 0 0 1 : 1; 0 1 0 : 0; 0 1 1 : 0; 1 0 0 : 1; 1 0 1 : 0; 1 1 0 : 1; 1 1 1 : 0; endtable endprimitive

Truth tables with don’t cares table //? Represents a don’t care condition // on the input //i1 i2 i3 : y 0 0 0 : 0 0 0 1 : 1 0 1 0 : 0 0 1 1 : 0 1 ? ? : 1 endtable

variable assignment variable_name = value; //blocking assignment variable_name <= value; //non-blocking assignment Examples output a; output [6:0] b; reg [3:0] c; wire [2:0] d; Correct Incorrect a = 1; a <= 3; b <= 7’b0101001; b = 9’b000011011; b[1] = 0; c <= 0; d <= 0; d <= {b , c}; b <= {c, d}; b[5:2] <= c;

Propagation delay Used to assign variables or primitives with delay, modeling circuit behaviour # 5 and (s, i0, i1); -- 5 ns and gate delay #5 assign s = i0 & i1; -- 5 ns and gate delay #1 assign a = b; --1 ns wire delay Not synthesizable, is ignored by synthesis tools Useful in testbenches for creating input signal waveforms always #20 clk = ~clk -- 40 ns clock period #0 rst_n = 0; #10 rst_n = 1;

Concurrent statements –delta time b = ~ a; (a = 1, b = 1, c =0) c = a ^ b; Time a b c 0 1 1 0 δ 1 0 0 2δ 1 0 1

Continuous assignment Multiple driver error assign c = a & b; …. assign c = d | e;

Combinational circuit description module gates (d, a, c); output d; input a, c; wire d; //wire b; assign d = c ^ (~a); // assign b = ~a; // assign d = c ^ b; endmodule

Arithmetic unit description (full-adder) module add1 (cout, sum, a, b, cin); input a, b; input cin; output sum; output cout; wire cout; wire sum; assign {cout,sum} = a + b + cin; endmodule

Example Describe a 5-bit multiplier in Verilog.

Conditional assignment - describing MUXs assign = select_signal ? assignment1 : assignment1 module mux (o, s, i0, i1); output o; input i0, i1; input s; wire o; assign o = s ? i1 : i0; //if s =1 then o = i1, else o =i0 endmodule

TESTBENCH `timescale 1ns / 100ps module testbench_name (); reg ….; //declaration of register variables for DUT inputs wire …; //declaration of wires for DUT outputs DUT_name(DUT ports); initial $monitor(); //signals to be monitored (optional) initial begin #100 $finish; //end simulation end initial begin clk = 1’b0; //initialize clk #10 a = 0; #10 a = 1; … always # 50 clk = ~clk; //50 ns clk period (if there is a clock) endmodule

TESTBENCH EXAMPLE `timescale 1ns / 100ps module mux_tb (); reg i0, i1, s; wire o; mux M1 (o, s, i0, i1); initial begin #100 $finish; //end simulation end initial begin //stimulus pattern #10 i0 = 0; i1=0; s=0; #10 i0=1; #10 i0 = 0; i1=1; #10 i0=0; i1= 0; s=1; end endmodule