This Lecture. Some components (useful for the homework) Verilog HDL (will continue next lecture)

Similar documents
CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

Hardware description languages

Hardware Description Languages: Verilog

Hardware Description Languages: Verilog. Quick History of HDLs. Verilog/VHDL. Design Methodology. Verilog Introduction. Verilog.

! ISP (circa 1977) - research project at CMU " Simulation, but no synthesis

CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

Techniques for Digital Systems Lab. Verilog HDL. Tajana Simunic Rosing. Source: Eric Crabill, Xilinx

Introduction to Verilog HDL

Synthesizable Verilog

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Introduction to Verilog. Garrison W. Greenwood, Ph.D, P.E.

Introduction to Verilog/System Verilog

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

Digital Design with FPGAs. By Neeraj Kulkarni

Introduction To Verilog Design. Chun-Hung Chou

Contents. Appendix D Verilog Summary Page 1 of 16

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

Chapter 3 working with combinational logic

Spiral 1 / Unit 4 Verilog HDL. Digital Circuit Design Steps. Digital Circuit Design OVERVIEW. Mark Redekopp. Description. Verification.

CSE140L: Components and Design

CSE140L: Components and Design Techniques for Digital Systems Lab

A Brief Introduction to Verilog Hardware Definition Language (HDL)

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

Lecture 7. Summary of two-level combinational-logic. Ways of specifying circuits. Solving combinational design problems. Verilog versus VHDL

Lecture 8: Combinational Verilog. CSE 370, Autumn 2007 Benjamin Ylvisaker. Where We Are. Last lecture: Minimization with K!maps

Verilog Design Principles

Verilog introduction. Embedded and Ambient Systems Lab

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Verilog. Reminder: Lab #1 due tonight! Fall 2008 Lecture 3

Verilog. What is Verilog? VHDL vs. Verilog. Hardware description language: Two major languages. Many EDA tools support HDL-based design

Speaker: Kayting Adviser: Prof. An-Yeu Wu Date: 2009/11/23

N-input EX-NOR gate. N-output inverter. N-input NOR gate

Chap 6 Introduction to HDL (d)

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

Design Using Verilog

Lecture #2: Verilog HDL

Verilog. Like VHDL, Verilog HDL is like a programming language but:

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

Online Verilog Resources

Lecture 15: System Modeling and Verilog

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

Verilog Coding Guideline

Digital Design with SystemVerilog

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Introduction To HDL. Verilog HDL. Debdeep Mukhopadhyay Dept of CSE, IIT Madras 1

Where We Are. Quick History Lesson. Lecture 8: Combinational Verilog. Specifying Circuits. Last lecture: Minimization with K!maps

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

EEL 4783: HDL in Digital System Design

Introduction. Why Use HDL? Simulation output. Explanation

register:a group of binary cells suitable for holding binary information flip-flops + gates

EECS 427 Lecture 14: Verilog HDL Reading: Many handouts/references. EECS 427 W07 Lecture 14 1

Combinational Logic II

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

ECE 4514 Digital Design II. Spring Lecture 7: Dataflow Modeling

structure syntax different levels of abstraction

Here is a list of lecture objectives. They are provided for you to reflect on what you are supposed to learn, rather than an introduction to this

Speaker: Shao-Wei Feng Adviser: Prof. An-Yeu Wu Date: 2010/09/28

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation

Lab 7 (All Sections) Prelab: Introduction to Verilog

Outline. EECS Components and Design Techniques for Digital Systems. Lec 11 Putting it all together Where are we now?

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb UMass Amherst Fall 2017

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb With material by Professor Moritz and Kundu UMass Amherst Fall 2016

ECEN 468 Advanced Logic Design

Synthesis of Combinational and Sequential Circuits with Verilog

a, b sum module add32 sum vector bus sum[31:0] sum[0] sum[31]. sum[7:0] sum sum overflow module add32_carry assign

Chapter 2 Using Hardware Description Language Verilog. Overview

Lab #1. Topics. 3. Introduction to Verilog 2/8/ Programmable logic. 2. Design Flow. 3. Verilog --- A Hardware Description Language

Introduction to Digital Design with Verilog HDL

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified.

C-Based Hardware Design

Hardware Description Language VHDL (1) Introduction

ECEN 468 Advanced Logic Design

Verilog Design Principles

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

Verilog Hardware Description Language ROOM: B405

Verilog. Verilog for Synthesis

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

Chap 6 - Introduction to HDL (b)

Department of Computer Science and Electrical Engineering. Intro to Verilog II

CSE241 VLSI Digital Circuits Winter Recitation 1: RTL Coding in Verilog

UNIT V: SPECIFICATION USING VERILOG HDL

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

Chapter 10. case studies in sequential logic design

Digital Design (VIMIAA01) Introduction to the Verilog HDL

ECEN 449 Microprocessor System Design. Verilog. Texas A&M University

EECS150 - Digital Design Lecture 8 - Hardware Description Languages

Verilog HDL Introduction

HDL. Hardware Description Languages extensively used for:

Verilog Module 1 Introduction and Combinational Logic

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Schematic design. Gate level design. 0 EDA (Electronic Design Assistance) 0 Classical design. 0 Computer based language

EEL 4783: Hardware/Software Co-design with FPGAs

Veriolog Overview. CS/EE 3710 Fall 2010

Chapter 3: Dataflow Modeling

Hardware Description Language (HDL)

EECS150 - Digital Design Lecture 10 Logic Synthesis

Transcription:

Last Lecture The basic component of a digital circuit is the MOS transistor Transistor have instrinsic resistance and capacitance, so voltage values in the circuit take some time to change ( delay ) There exist two kinds: nmos and pmos, with complementary behavior and advantages/disadvantages A logic gate implementing a certain boolean function can be built with a circuit composed of: A Pull-Down network of nmos A Pull-Up network of pmos There exist automatic rules to determine the topology of the Pull- Down and the Pull-Up network for a gate Multiple gates can be connected together to form more complicated components Yesterday in CSE140 we saw logic gates (like NOT and NAND) Today here we will look at slightly more high level components (because it s what you have to implement in homework 2) 1

This Lecture Some components (useful for the homework) Verilog HDL (will continue next lecture) 2

CSE140L: Components and Design Techniques for Digital Systems Lab Some basic digital components 3

Half Adder A,B : Inputs S: Sum C: Carry 4

Half Adder: Checkoff Example 1) Submit the zipped project folder containing ALL of your source code on TED Tutor checks that the files are there, so the checkoff can start 2) Explain the functionality of module TA report example: knows the behavior of the half adder 3) Review of Verilog code TA report example: Verilog code has missing port declaration 4) Compilation of code TA report example: The project compiles correctly 5) Running testbenches to verify functionality TA report example: The testbench demonstrates the functionality of the module by producing the correct output with all possible combinations of inputs 5

Full Adder 6

Full Adder You can use 2 half adders and a OR gate to implement the Full Adder 7

Multiplexer (Example) Four possible display items Temperature (T), Average miles-per-gallon (A), Instantaneous mpg (I), and Miles remaining (M) -- each is 8-bits wide Choose which to display using two inputs x and y Use 8-bit 4x1 mux 8

Multiplexers/selectors 2:1 mux: Z = A'I 0 + AI 1 4:1 mux: Z = A'B'I 0 + A'BI 1 + AB'I 2 + ABI 3 8:1 mux: Z = A'B'C'I 0 + A'B'CI 1 + A'BC'I 2 + A'BCI 3 + AB'C'I 4 + AB'CI 5 + ABC'I 6 + ABCI 7 In general: σ2 n 1 k=0 m k I k shorthand form for a 2 n :1 Mux 1 I0 0 I1 2:1 I2 Z mux 1 1 I3 I0 I1 A For example 4:1 mux A B 0 1 0 Z I0 I1 I2 I3 I4 I5 I6 I7 8:1 mux A B C Z 9

Demultiplexers/decoders Decoders/demultiplexers: general concept single data input, n control inputs, 2 n outputs control inputs (called selects (S)) represent binary index of output to which the input is connected data input usually called enable 1 0 0 1 0 For example 1 0 10

CSE140L: Components and Design Techniques for Digital Systems Lab Verilog HDL Slides from Tajana Simunic Rosing Source: Eric Crabill, Xilinx 11

Hardware description languages Used to describe & model the operation of digital circuits. Specify simulation procedure for the circuit and check its response. Simulation requires a logic simulator. Synthesis: transformation of the HDL description into a physical implementation (transistors, gates) When a human does this, it is called logic design. When a machine does this, it is called synthesis.

HDLs Abel (circa 1983) - developed by Data-I/O targeted to programmable logic devices not good for much more than state machines ISP (circa 1977) - research project at CMU simulation, but no synthesis Verilog (circa 1985) - developed by Gateway (absorbed by Cadence) similar to C delays are the only interaction with the simulator fairly efficient and easy to write IEEE standard VHDL (circa 1987) - DoD sponsored standard VHSIC Hardware Description Language (VHSIC is Very High Speed Integrated Circuit). simulation semantics visible; very general but verbose IEEE standard

Verilog Usage Verilog may be used to model circuits and behaviors at various levels of abstraction: Algorithmic. Behavioral. Logic Gate Transistor An FPGA is a programmable hardware where you can download your synthesized HDL implementation Projects in HDL are tested on FPGAs prior to fabrication Transistor and gate level modeling is not appropriate for design with FPGA devices. https://en.wikipedia.org/wiki/field-programmable_gate_array

Verilog Supports structural and behavioral descriptions Structural explicit structure of the circuit e.g., each logic gate instantiated and connected to others Behavioral program describes input/output behavior of circuit many structural implementations could have same behavior e.g., different implementation of one Boolean function

Structural model module xor_gate (out, a, b); input a, b; output out; wire abar, bbar, t1, t2; inverter inva (abar, a); inverter invb (bbar, b); and_gate and1 (t1, a, bbar); and_gate and2 (t2, b, abar); or_gate or1 (out, t1, t2); a b invb inva and2 and1 or1 endmodule

Behavioral model module xor_gate (out_or, out_and, a, b); input a, b; output out_or, out_and; reg out_or, out_and; always @(a or b) begin out_or = a ^ b; end assign out_and = a & b; endmodule

Data Values For our logic design purposes, we ll consider Verilog to have four different bit values: 0, logic zero. 1, logic one. z, high impedance. x, unknown.

Data Types and Values There are two main data types in Verilog. Wires. Regs. These data types may be single bit or multi-bit. The general syntax is: {bit width} {base}{value} 4 d14 // 4-bit value, specified in decimal 4 he // 4-bit value, specified in hex 4 b1110 // 4-bit value, specified in binary 4 b10xz // 4-bit value, with x and z, in binary

Wires: Data Types continuously assigned values and do not store information. may have multiple drivers assigning values. When multiple drivers exist, the simulator resolves them into a single value for the wire. Every time a driver changes its output value, the resulting wire value is re-evaluated. This behaves much like an electrical wire...

Regs Data Types procedurally assigned values that store information until the next value assignment is made. can be used to model combinational or sequential logic. The name reg does not mean it is a register! A reg may be assigned by multiple processes. Other reg varieties include integer, real, and time.

Lecture 3 22

Checkoff Before Wednesday at 4.30pm (last available office hour) Meet with instructor/ta/tutor during office hours Submit source code on TED For HW2: For 2 modules (picked randomly): quick review of the code You ll be asked to run the testbenches for 2 modules and explain how they work. 23

Modules and Ports Consider a top level module declaration: module testbench; endmodule // Top level modules do not have ports. Consider a module declaration with ports: module two_input_xor (in1, in2, out); input in1, in2; output out; endmodule // We ll add more later Module Ports: define how the module interacts with the external world

Modules and Ports Ports may be of type {input, output, inout} and can also be multiple bits wide. module some_random_design (fred, bob, joe, sam, tom, ky); input fred; // 1-bit input port input [7:0] bob; // 8-bit input port output joe; // 1-bit output port output [1:0] sam; // 2-bit output port inout tom; // 1-bit bidirectional port inout [3:0] ky; // 4-bit bidirectional port // Some design description would be here endmodule

Input port: Port and Data Types driven from outside the module by a wire or a reg, inside the module it can only drive a wire Output port driven from inside the module by a wire or a reg, outside the module it can only drive a wire. Inout port May be driven by a wire, and drive a wire.

Instantiation module testbench; wire sig3; // wire driven by submodule reg sig1, sig2; // regs assigned by testbench two_input_xor my_xor (.in1(sig1),.in2(sig2),.out(sig3)); endmodule module two_input_xor (in1, in2, out); input in1, in2; output out; // We ll add more later endmodule Explicit module connection:.<port>(signal) By default, ports are wires inside the module (so if you want regs instead, you must explicitly state it)

Operators Used in both procedural and continuous assignments. Listed in the order of evaluation precedence: { } is used for concatenation. Say you have two 1-bit data objects, sam and bob. {sam, bob} is a 2-bit value from concatenation {{ }} is used for replication. Say you have a 1-bit data object, ted. {4{ted}} is a 4-bit value, ted replicated four times. Unary operators:! Performs logical negation (test for non-zero). ~ Performs bit-wise negation (complements). & Performs unary reduction of logical AND. Performs unary reduction of logical OR. ^ Performs unary reduction of logical XOR.

Operators cont. Arithmetic operators (signed and can generate carry out): * Multiplication. / Division. % Modulus. + Addition. - Subtraction. Logical shift operators: << Shift left. >> Shift right. Relational operators: > Greater than. < Less than. >= Greater than or equal. <= Less than or equal.

Comparison operators: Operators cont. == Equality operator (compares to z, x are invalid).!= Not equal. Binary bit-wise operators: & Bit-wise logical AND. Bit-wise logical OR. ^ Bit-wise logical XOR. ~^ Bit-wise logical XNOR. Binary logical operators: && Binary logical AND. Binary logical OR. Operator for conditional selection: sel? value_if_sel_is_one : value_if_sel_is_zero oe? driven_value : 1 bz

Continuous Assignment Continuous assignments are made with the assign statement: assign LHS = RHS; The left hand side, LHS, must be a wire. The right hand side, RHS, may be a wire, a reg, a constant, or expressions with operators using one or more wires, regs, and constants. The value of the RHS is continuously driven onto the wire of the LHS. Values x and z are allowed and processed. All assign statements operate concurrently.

Continuous Assignment module two_input_xor (in1, in2, out); input in1, in2; // use these as a wire output out; // use this as a wire assign out = in1 ^ in2; endmodule module two_input_xor (in1, in2, out); input in1, in2; output out; wire product1, product2; assign product1 = in1 &!in2; assign product2 =!in1 & in2; assign out = product1 product2; // could have done all in // assignment of out with // bigger expression endmodule

Continuous Assignment module two_input_xor (in1, in2, out); input in1, in2; output out; assign out = (in1!= in2); endmodule module two_input_xor (in1, in2, out); input in1, in2; output out; assign out = in1? (!in2) : (in2); endmodule What does this line represent?

Procedural Assignment Models combinational and sequential logic Operates concurrently and is preceded by event control. In block statements start with begin and end with end. Single assignments can omit begin and end. A sensitivity list specifies events which cause the execution to begin: always @(a or b) // any changes in a or b always @(posedge a) // a transitions from 0 to 1 always @(negedge a) // a transitions from 1 to 0 always @(a or b or negedge c or posedge d)

Procedural Assignment initial begin // These procedural assignments are executed // one time at the beginning of the simulation. end always @(sensitivity list) begin // These procedural assignments are executed // whenever the events in the sensitivity list // occur. end

Procedural Assignment Inside a block, two types of assignments exist: LHS = RHS; // blocking assignment LHS <=RHS; // non-blocking assignment Do not mix them in a given block. Assignment rules: The left hand side, LHS, must be a reg. The right hand side, RHS, may be a wire, a reg, a constant, or expressions with operators using one or more wires, regs, and constants.

Procedural Assignment Do I use blocking or non-blocking assignments? Blocking assignments are especially useful when describing combinational logic. You can build up complex logic expressions. Blocking assignments make your description evaluate in the order you described it. Non-blocking assignments are useful when describing sequential logic. At a clock or reset event, all memory elements change state at the same time, best modeled by non-blocking assignments. For conditional assignments use if-else and various types of case statements. You also can make use of additional timing control: wait, #delay, repeat, while, etc

Procedural Assignment Example: Blocking Vs Nonblocking Assignments 38

Procedural Assignment Combinational logic using operators: module two_input_xor (in1, in2, out); input in1, in2; output out; reg out; // use these as wires // use this as a wire always @(in1 or in2) begin out = in1 ^ in2; end // Note that all input terms // are in sensitivity list! // Or equivalent expression... // I could have simply used: // always @(in1 or in2) out = in1 ^ in2; endmodule

Procedural Assignment Combinational logic using if-else: module two_input_xor (in1, in2, out); input in1, in2; output out; reg out; // use these as wires // use this as a wire always @(in1 or in2) // Note that all input terms begin // are in sensitivity list! if (in1 == in2) out = 1 b0; else out = 1 b1; end endmodule

Procedural Assignment Combinational logic using case: module two_input_xor (in1, in2, out); input in1, in2; output out; reg out; // use these as wires // use this as a wire always @(in1 or in2) begin case ({in2, in1}) 2 b01: out = 1 b1; 2 b10: out = 1 b1; default: out = 1 b0; endcase end endmodule // Note that all input terms // are in sensitivity list! // Concatenated 2-bit selector

Delay Control You can add delay to continuous assignments. assign #delay LHS = RHS; The #delay indicates a time delay in simulation time units; for example, #5 is a delay of five. This can be used to model physical delays of combinational logic. The simulation time unit can be changed by the Verilog `timescale directive. Syntax: `timescale <reference_time_unit> / <precision>

Delay Control Control the timing of assignments in procedural blocks by: Level triggered timing control. wait (!reset); wait (!reset) a = b; Simple delays. #10; #10 a = b; Edge triggered timing control. @(a or b); @(a or b) c = d; @(posedge clk); @(negedge clk) a = b;

Delay Control Generation of clock and resets in testbench: reg rst, clk; initial begin end always begin end rst = 1 b1; // this happens once at time zero // starts off as asserted at time zero #100; // wait for 100 time units rst = 1 b0; clk = 1 b1; // deassert the rst signal // this repeats forever // starts off as high at time zero #25; // wait for half period clk = 1 b0; // clock goes low #25; // wait for half period

System Tasks The $ sign denotes Verilog system tasks, there are a large number of these, most useful being: $display( The value of a is %b, a); Used in procedural blocks for text output. The %b is the value format (binary, in this case ) $monitor Similar to display, but executes every time one of its parameter changes $finish; Used to finish the simulation. Use when your stimulus and response testing is done. $stop; Similar to $finish, but doesn t exit simulation.

Driving a simulation through a testbench module testbench (x, y); output x, y; reg [1:0] cnt; 2-bit vector initial begin cnt = 0; repeat (4) begin #10 cnt = cnt + 1; $display ("@ time=%d, x=%b, y=%b, cnt=%b", $time, x, y, cnt); end #10 $finish; end initial block executed only once at start of simulation print to a console assign x = cnt[1]; assign y = cnt[0]; endmodule directive to stop simulation

HDLs vs. PLs Program structure instantiation of multiple components of the same type specify interconnections between modules via schematic hierarchy of modules Assignment continuous assignment (logic always computes) propagation delay (computation takes time) timing of signals is important (when does computation have its effect) Data structures size explicitly spelled out - no dynamic structures no pointers Parallelism hardware is naturally parallel (must support multiple threads) assignments can occur in parallel (not just sequentially)