Overview Last lecture Today K-Maps Verilog Structural constructs

Slides:



Advertisements
Similar presentations
Hardware Description Languages (HDL): Verilog
Advertisements

Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Verilog Intro: Part 1.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
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.
ECE 353 Computer Systems Lab I Verilog Hardware Description Language.
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Lecture 7 Verilog Additional references Structural constructs
Overview Logistics Last lecture Today HW5 due today
ECE 2372 Modern Digital System Design
ECE/CS 352 Digital Systems Fundamentals
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
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.
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.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Electrical and Computer Engineering University of Cyprus LAB 1: VHDL.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Introduction to ASIC flow and Verilog HDL
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Binary Numbers For digital systems, the.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
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.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
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.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
EGR 2131 Unit 4 Combinational Circuits: Analysis & Design
COMP541 Combinational Logic - 3
Design Entry: Schematic Capture and VHDL
Discussion 2: More to discuss
Verilog Introduction Fall
VLSI Testing Lecture 5: Logic Simulation
Lecture 7 Logistics Last lecture Today Homework 2 due today
‘if-else’ & ‘case’ Statements
COMP541 Combinational Logic - 3
Vishwani D. Agrawal Department of ECE, Auburn University
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Hardware Descriptive Languages these notes are taken from Mano’s book
Behavioral Modeling in Verilog
Overview Last lecture Today K-Maps Verilog Structural constructs
Introduction to Verilog
SYNTHESIS OF SEQUENTIAL LOGIC
Lecture 1.3 Hardware Description Languages (HDLs)
Hardware Descriptive Languages these notes are taken from Mano’s book
332:437 Lecture 8 Verilog and Finite State Machines
Review Advancing technology changes the trade-offs and design techniques 2x transistors per chip every 18 months ASIC, Programmable Logic, Microprocessor.
مدار منطقی به نام یگانه مهندس هستی مهدی قدیری
Digital Fundamentals Floyd Chapter 4 Tenth Edition
Introduction to Verilog, ModelSim, and Xilinx ISE
Introduction to Verilog, ModelSim, and Xilinx Vivado
The Verilog Hardware Description Language
332:437 Lecture 8 Verilog and Finite State Machines
CSE 370 – Winter Number syst.; Logic functions- 1
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Overview Last lecture Today K-Maps Verilog Structural constructs Describing combinational circuits

Ways of specifying circuits Schematics Structural description Describe circuit as interconnected elements Build complex circuits using hierarchy Large circuits are unreadable HDLs Hardware description languages Not programming languages Parallel languages tailored to digital design Synthesize code to produce a circuit

Hardware description languages (HDLs) Abel (~1983) Developed by Data-I/O Targeted to PLDs (programmable logic devices) Limited capabilities (can do state machines) Verilog (~1985) Developed by Gateway (now part of Cadence) Syntax similar to C Moved to public domain in 1990 VHDL (~1987) DoD (Department of Defence) sponsored Syntax similar to Ada

Verilog versus VHDL Both “IEEE standard” languages Most tools support both Verilog is “simpler” Less syntax, fewer constructs VHDL is more structured Can be better for large, complex systems Better modularization

Simulation and synthesis “Execute” a design to verify correctness Synthesis Generate a physical implementation from HDL code HDL Description Synthesis Gate or Transistor Description Physical Implementation sometimes called a “netlist” Simulation Simulation Physical Implementation Functional Validation Functional/ Timing Validation Real Chip!

Simulation and synthesis (con’t) Models what a circuit does Multiply is “*”, ignoring implementation options Can include static timing Allows you to test design options Synthesis Converts your code to a netlist Can simulate synthesized design Tools map your netlist to hardware Simulation and synthesis in the CSE curriculum CSE370: Learn simulation CSE467: Learn synthesis

Simulation You provide an environment Using non-circuit constructs Active-HDL waveforms, Read files, print Using Verilog simulation code A “test fixture” Note: We will ignore timing and test benches until later Simulation Test Fixture (Specification) Circuit Description (Synthesizeable)

Specifying circuits in Verilog There are three major styles Instances ‘n wires Continuous assignments “always” blocks Structural Describe explicit circuit elements Describe explicit connections between elements Connections between logic gates Just like schematics, but using text Behavioral Describe circuit as algorithms/programs What a component does Input/output behavior Many possible circuits could have same behavior Different implementations of a Boolean function “Structural” “Behavioral” wire E; and g1(E,A,B); not g2(Y,C); or g3(X,E,Y); wire E; assign E = A & B; assign Y = ~C; assign X = E | Y; reg E, X, Y; always @ (A or B or C) begin E = A & B; Y = ~C; X = E | Y; end

Data types Values on a wire Vectors 0, 1, x (unknown or conflict), z (tristate or unconnected) Vectors A[3:0] vector of 4 bits: A[3], A[2], A[1], A[0] Unsigned integer value Indices must be constants Concatenating bits/vectors e.g. sign extend B[7:0] = {A[3], A[3], A[3], A[3], A[3:0]}; B[7:0] = {4{A[3]}, A[3:0]}; Style: Use a[7:0] = b[7:0] + c[7:0] Not a = b + c; Legal syntax: C = &A[6:7]; // logical and of bits 6 and 7 of A

Data types that do not exist Structures Pointers Objects Recursive types (Remember, Verilog is not C or Java or Lisp or …!)

Numbers Format: <sign><size><base format><number> 14 Decimal number –4’b11 4-bit 2’s complement binary of 0011 (is 1101) 12’b0000_0100_0110 12 bit binary number (_ is ignored) 3’h046 3-digit (12-bit) hexadecimal number Verilog values are unsigned C[4:0] = A[3:0] + B[3:0]; if A = 0110 (6) and B = 1010(–6), then C = 10000 (not 00000) B is zero-padded, not sign-extended

Operators Similar to C operators

Two abstraction mechanisms Modules More structural Heavily used in 370 and “real” Verilog code Functions More behavioral Used to some extent in “real” Verilog, but not much in 370

Basic building blocks: Modules Instanced into a design Never called Illegal to nest module defs. Modules execute in parallel Names are case sensitive // for comments Name can’t begin with a number Use wires for connections and, or, not are keywords All keywords are lower case Gate declarations (and, or, etc) List outputs first Inputs second // first simple example module smpl (X,Y,A,B,C); input A,B,C; output X,Y; wire E and g1(E,A,B); not g2(Y,C); or g3(X,E,Y); endmodule

Modules are circuit components Module has ports External connections A,B,C,X,Y in example Port types input output inout (tristate) Use assign statements for Boolean expressions and  & or  | not  ~ // previous example as a // Boolean expression module smpl2 (X,Y,A,B,C); input A,B,C; output X,Y; assign X = (A&B)|~C; assign Y = ~C; endmodule

Structural Verilog 8 basic gates (keywords): and, or, nand, nor module xor_gate (out,a,b); input a,b; output out; wire abar, bbar, t1, t2; not inva (abar,a); not invb (bbar,b); and and1 (t1,abar,b); and and2 (t2,bbar,a); or or1 (out,t1,t2); endmodule 8 basic gates (keywords): and, or, nand, nor buf, not, xor, xnor

Behavioral Verilog Describe circuit behavior A Not implementation Sum Cin Cout Sum Adder module full_addr (Sum,Cout,A,B,Cin); input A, B, Cin; output Sum, Cout; assign {Cout, Sum} = A + B + Cin; endmodule {Cout, Sum} is a concatenation

Behavioral 4-bit adder “[3:0] A” is a 4-wire bus labeled “A” module add4 (SUM, OVER, A, B); input [3:0] A; input [3:0] B; output [3:0] SUM; output OVER; assign {OVER, SUM[3:0]} = A[3:0] + B[3:0]; endmodule “[3:0] A” is a 4-wire bus labeled “A” Bit 3 is the MSB Bit 0 is the LSB Can also write “[0:3] A” Bit 0 is the MSB Bit 3 is the LSB Buses are implicitly connected If you write BUS[3:2], BUS[1:0] They become part of BUS[3:0]

Continuous assignment Assignment is continuously evaluated Corresponds to a logic gate Assignments execute in parallel Boolean operators (~ for bit-wise negation) assign A = X | (Y & ~Z); assign B[3:0] = 4'b01XX; assign C[15:0] = 4'h00ff; assign #3 {Cout, Sum[3:0]} = A[3:0] + B[3:0] + Cin; bits can assume four values (0, 1, X, Z) Verilog is an event driven simulator When an assignment variable changes, code executes In an always block, code only executes when the triggers change variables can be n-bits wide (MSB:LSB) arithmetic operator Gate delay (used by simulator) multiple assignment (concatenation)

Example: A comparator module Compare1 (Equal, Alarger, Blarger, A, B); input A, B; output Equal, Alarger, Blarger; assign Equal = (A & B) | (~A & ~B); assign Alarger = (A & ~B); assign Blarger = (~A & B); endmodule Top-down design and bottom-up design are both okay  module ordering doesn’t matter  because modules execute in parallel

Comparator example (con’t) // Make a 4-bit comparator from 4 1-bit comparators module Compare4(Equal, Alarger, Blarger, A4, B4); input [3:0] A4, B4; output Equal, Alarger, Blarger; wire e0, e1, e2, e3, Al0, Al1, Al2, Al3, B10, Bl1, Bl2, Bl3; Compare1 cp0(e0, Al0, Bl0, A4[0], B4[0]); Compare1 cp1(e1, Al1, Bl1, A4[1], B4[1]); Compare1 cp2(e2, Al2, Bl2, A4[2], B4[2]); Compare1 cp3(e3, Al3, Bl3, A4[3], B4[3], ); assign Equal = (e0 & e1 & e2 & e3); assign Alarger = (Al3 | (Al2 & e3) | (Al1 & e3 & e2) | (Al0 & e3 & e2 & e1)); assign Blarger = (~Alarger & ~Equal); endmodule

Sequential assigns don’t make any sense assign A = X | (Y & ~Z); assign B = W | A; assign A = Y & Z; “Reusing” a variable in several assign statements is not allowed assign A = X | (Y & ~Z); assign B = W | A; assign X = B & Z; Cyclic dependencies also are bad A depends on X which depends on B which depends on A

Always Blocks Variables that appear on the left hand side in an always block must be declared as “reg”s reg A, B, C; always @ (W or X or Y or Z) begin A = X | (Y & ~Z); B = W | A; A = Y & Z; if (A & B) begin B = Z; C = W | Y; end Sensitivity list Statements in an always block are executed in sequence All variables must be assigned on every control path!!! (otherwise you get the dreaded “inferred latch”)

Functions Use functions for complex combinational logic module and_gate (out, in1, in2); input in1, in2; output out; assign out = myfunction(in1, in2); function myfunction; input in1, in2; begin myfunction = in1 & in2; end endfunction endmodule Benefit: Functions force a result  Compiler will fail if function does not generate a result

Sequential Verilog-- Blocking and non-blocking assignments Blocking assignments (Q = A) Variable is assigned immediately New value is used by subsequent statements Non-blocking assignments (Q <= A) Variable is assigned after all scheduled statements are executed Value to be assigned is computed but saved for later Usual use: Register assignment Registers simultaneously take new values after the clock edge Example: Swap always @(posedge CLK) begin temp = B; B = A; A = temp; end always @(posedge CLK) begin A <= B; B <= A; end

Sequential Verilog-- Assignments- watch out! Blocking versus Non-blocking reg B, C, D; always @(posedge clk) begin B = A; C = B; D = C; end reg B, C, D; always @(posedge clk) begin B <= A; C <= B; D <= C; end

Verilog tips Do not write C-code Do describe hardware circuits Think hardware, not algorithms Verilog is inherently parallel Compilers don’t map algorithms to circuits well Do describe hardware circuits First draw a dataflow diagram Then start coding References Tutorial and reference manual are found in ActiveHDL help http://www.cs.washington.edu/education/courses/cse370/08au/Tutorials/Tutorial_3.htm “Starter’s Guide to Verilog 2001” by Michael Ciletti copies for borrowing in hardware lab When you get more experience, you don’t actually need to draw the diagram, but you still think that way

Summary of two-level combinational-logic Logic functions and truth tables AND, OR, Buf, NOT, NAND, NOR, XOR, XNOR Minimal set Axioms and theorems of Boolean algebra Proofs by re-writing Proofs by perfect induction (fill in truth table) Gate logic Networks of Boolean functions NAND/NOR conversion and de Morgan’s theorem Canonical forms Two-level forms Incompletely specified functions (don’t cares) Simplification Two-level simplification (K-maps)

Solving combinational design problems Step 1: Understand the problem Identify the inputs and outputs Draw a truth table Step 2: Simplify the logic Draw a K-map Write a simplified Boolean expression SOP or POS Use don’t cares Step 3: Implement the design Logic gates and/or Verilog