Verilog Basics Nattha Jindapetch November 2008. Agenda Logic design review Verilog HDL basics LABs.

Slides:



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

ECE 551 Digital Design And Synthesis
Supplement on Verilog adder examples
Synchronous Sequential Logic
Combinational Logic.
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
Combinational Logic with Verilog Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer.
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
CSE 341 Verilog HDL An Introduction. Hardware Specification Languages Verilog  Similar syntax to C  Commonly used in  Industry (USA & Japan) VHDL 
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
 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.
The Multicycle Processor II CPSC 321 Andreas Klappenecker.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
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.
ELEN 468 Advanced Logic Design
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi.
B. RAMAMURTHY Hardware Description Language 8/2/
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Overview Logistics Last lecture Today HW5 due today
INTRODUCTION TO VERILOG HDL Presented by m.vinoth.
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
ECE 2372 Modern Digital System Design
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
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.
CH71 Chapter 7 Hardware Description Language (HDL) By Taweesak Reungpeerakul.
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.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
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.
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.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Introduction to ASIC flow and Verilog HDL
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
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 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.
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
Verilog Introduction Fall
‘if-else’ & ‘case’ Statements
Lecture 2 Supplement Verilog-01
Hardware Description Languages: Verilog
Sequential logic circuits
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Introduction to Verilog
Behavioral Modeling in Verilog
The Verilog Hardware Description Language
Supplement on Verilog adder examples
The Verilog Hardware Description Language
The Verilog Hardware Description Language
Verilog for Testbenches
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Verilog Basics Nattha Jindapetch November 2008

Agenda Logic design review Verilog HDL basics LABs

Logic Design Review

Basic Logic gates

Additional Logic Gates

Two Types Combinational circuit No "memory" Its output depends only upon the current state of its inputs. Sequential circuit Contains memory elements Its output depends not only upon the current state of its inputs, but also on the current state of the circuit itself. Two Styles: Synchronous and Asynchronous

Combinational Circuits: examples Multiplexers 2 n x 1 multiplexer receives 2 n input bits and n selector bits, and outputs exactly one of the input bits, determined by the pattern of the selector bits.

Combinational Circuits: examples Demultiplexers 1 x 2 n DMUX is the inverse of MUX It takes 1 input and transmits that input on exactly one of its outputs, determined by the pattern of its n selector bits.

Combinational Circuits: examples Encoders 2 n x n encoder takes 2 n inputs and sets each of its n outputs, based upon the pattern of its inputs. an encoder is the inverse of a decoder.

Combinational Circuits: examples Decoders An n x 2 n decoder takes n inputs and sets exactly one of its 2 n outputs, based upon the pattern of its inputs.

Sequential Circuits Circuits with feedback Cross-coupled NOR gates R SQ Q’ 0 No change Reset Set 1 Not allowed

Sequential Elements Latches vs Flip-Flops Latches work on Level-sensitive Flip-Flops work on Edge-triggered RS, JK, D, T S RQ Q’ 0 No change Reset Set 1 Not allowed J KQ Q’ 0 No change Toggle DQ TQ 01 10

Counters Synchronous counter Clock of synchronous counter are same clock. Asynchronous counter Clock of second flip- flop is Q of first flip- flop. The clock of asynchronous counter are different source.

Registers A register is used for storing several bits of digital data. It basically consists of a set of flip-flops.flip-flops each flip-flop representing one bit of the register. Thus, an n-bit register has n flip-flops. A Simple Shift Register Consisting of D-type Flip-flops

Verilog HDL basics

HDL (Hardware Description Language) Big picture: Two main HDLs out there VHDL Designed by committee on request of the Department of Defense Based on Ada Verilog HDL Designed by a company for their own use Based on C Both now have IEEE standards Both are in wide use

Verilog Description Styles Verilog supports a variety of description styles Structural explicit structure of the circuit e.g., each logic gate instantiated and connected to others Behavioral program describes input/output behavior of circuits Mixed

Verilog Module module module-name (list-of-port); input/output declarations local net declarations parallel statements endmodule

Structural Module: example1 module half_adder (s, a, b, co); inputa, b; outputs, co; wire w0, w1, w2; assign w0 = a & b, w1 = ~w0, w2 = a | b, s = w1 & w2, co = w0; endmodule a bw0 w1 w2 co s a b s co

Structural Module: example1 module full_adder (s, a, b, co, ci); inputa, b, ci; outputs, co; wire w0, w1, w2; assign co = w1 | w2; half_adder i0 (.co(w1),.s(w0),.a(a),.b(b)); half_adder i1 (.co(w2),.s(s),.a(w0),.b(ci)); endmodule

Structural Module: example1 module adder4 (s, a, b, co, ci); input [3:0] a, b; input ci; output [3:0]s, outputco; wire w0, w1, w2; full_adder i0 (.co(w0),.s(s[0]),.a(a[0]),.b(b[0]),.ci(ci)); full_adder i1 (.co(w1),.s(s[1]),.a(a[1]),.b(b[1]),.ci(w0)); full_adder i2 (.co(w2),.s(s[2]),.a(a[2]),.b(b[2]),.ci(w1)); full_adder i3 (.co(co),.s(s[3]),.a(a[3]),.b(b[3]),.ci(w2)); endmodule

Behavioral Module: example1 module adder4 (s, a, b, co, ci); input [3:0] a, b; inputci; output [3:0]s, outputco; reg [3:0]s; regco; or b or ci) {co, s} = a + b + ci; endmodule

Verilog Data Types  Possible Values:  0: logic 0, false  1: logic 1, true  X: unknown logic value  Z: High impedance state  Registers and Nets (wires) are the main data types  Integer, time, and real are used in behavioral modeling, and in simulation  Note that they are not synthesized !

Verilog Registers Abstract model of a data storage element A reg holds its value from one assignment to the next The value “ sticks ” Register type declarations reg a; // a scalar register reg [3:0] b; // a 4-bit vector register

Verilog Nets Nets (wires) model physical connections They don’t hold their value They must be driven by a “driver” (i.e. a gate output or a continuous assignment) Their value is Z if not driven Wire declarations wire d; // a scalar wire wire [3:0] e; // a 4-bit vector wire

Verilog Parameters Used to define constants parameter size = 16, value = 8; wire [size-1:0] bus; // defines a 15:0 bus

Verilog Operators Arithmetic operators:+, -, *, /, % Logical operators:&&, ||, ! Bitwise operators:&, |, ~, ^, ^~ Equality operators:==, !=, Relational operators:>, =, <= Reduction operators:&, ~&, |, ~|, ^ Shift operators:>>, << Conditional:?:

Example2: 4:1 multiplexer module mux4 (s, d, z); //bitwise operators input [1:0] s; input [3:0] d; output z; assign z =(~s[1] & ~s[0] & d[0]) | (~s[1] & s[0] & d[1]) | ( s[1] & ~s[0] & d[2]) | ( s[1] & s[0] & d[3]) ; endmodule

Example2: 4:1 multiplexer module mux4 (s, d, z); //using conditional operators input [1:0] s; input [3:0] d; output z; assign z = s[1] ? (s[0] ? d[3] : d[2]) : (s[0] ? d[1] : d[0]); endmodule

Verilog Assignments Two types: Continuous Assignments assign values to nets This means combinational logic Procedural Assignments assign values to registers Only allowed inside procedural blocks (initial and always)

Continuous Assignments Models combinational logic using a logical expression instead of gates Assignment is evaluated whenever any signal changes wire a, b, out; assign out = ~(a & b); wire [15:0] sum, a, b; wire cin, cout; assign {cout,sum} = a + b + cin;

Procedural Assignments Assigns values to register types They do not have a duration The register holds the value until the next procedural assignment to that variable They occur only within procedural blocks initial and always They are triggered when the flow of execution reaches them

always Blocks When is an always block executed? always Starts at time 0 or b or c) Whenever there is a change on a, b, or c Used to describe combinational logic foo) Whenever foo goes from low to high Used to describe sequential logic bar) Whenever bar goes from high to low

Inside always blocks Procedural assignments if statements case statements for, while, forever statements wait statements

Blocking vs Non-blocking

begin q1 = x1; q2 = q1; z1 = q2; end Blocking begin q1 <= x1; q2 <= q1; z1 <= q2; end Non-Blocking

Quick Review Continuous assignments to wires assign variable = exp; Result in combinational logic Procedural assignment to regs Always inside procedural blocks (always blocks in particular for synthesis) blocking variable = exp; non-blocking variable <= exp; Can result in combinational or sequential logic

Quick Review module name (args…); input …; // define inputs output …; // define outputs wire… ; // internal wires reg …; // internal regs, possibly output // the parts of the module body are // executed concurrently endmodule

comment in Verilog_HDL // Single-line comment /*…………. …………..*/ multiple-line comment module mux2_1(out,a,b,sel); // port declare. input a,b,sel; output out; wire sel_,a1,b1 /* structural design using logic operator mux2_1 */ not (sel_,sel); and (a1,a,sel),(b1,b,sel); or (out,a1,b1); endmodule;

Naming in Verilog_HDL ข้อกำหนด ในการตั้งชื่อไฟล์ การตั้งชื่ออุปกรณ์ และ การเชื่อมต่อ สายสัญญาณ จะต้องไม่เป็นคำสงวนของภาษา ระหว่างข้อความ หรือตัวเลข สามารถใช้ เครื่องหมาย _ หรือ $ ได้ ตัวแรกที่ตั้งชื่อต้องเป็น ตัวอักษร a-z หรือ A-Z หรือ _ ตัวอักษรตัวใหญ่ และ ตัวเล็ก จะมีความหมายแตกต่างกัน

ศึกษาเพิ่มเติม.... Evita_Verilog Teerayod_Verilog_Thai