Chap 6 Introduction to HDL (d)

Similar documents
Hardware Description Language (HDL)

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

Course Topics - Outline

Digital Design with FPGAs. By Neeraj Kulkarni

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

Digital System Design Verilog-Part III. Amir Masoud Gharehbaghi

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

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

EEL 4783: HDL in Digital System Design

Verilog Behavioral Modeling

EECS150 - Digital Design Lecture 10 Logic Synthesis

CSE140L: Components and Design Techniques for Digital Systems Lab

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

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

CSE140L: Components and Design

EECS150 - Digital Design Lecture 10 Logic Synthesis

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

VHDL VS VERILOG.

Behavioral Modeling and Timing Constraints

AN INTRODUCTION TO VERILOG HDL

Contents. Appendix D Verilog Summary Page 1 of 16

Verilog HDL. Gate-Level Modeling

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

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Lecture 15: System Modeling and Verilog

HW1 Modeling Concepts

Chap 6 - Introduction to HDL (b)

HDL for Combinational Circuits. ENEL211 Digital Technology

Design Using Verilog

Chapter 2 Using Hardware Description Language Verilog. Overview

Synthesis of Combinational and Sequential Circuits with Verilog

Lab 7 (All Sections) Prelab: Introduction to Verilog

Image Courtesy CS250 Section 2. Yunsup Lee 9/4/09

CS6710 Tool Suite. Verilog is the Key Tool

Introduction to Digital Design with Verilog HDL

Synthesizable Verilog

Module 2.1 Gate-Level/Structural Modeling. UNIT 2: Modeling in Verilog

Behavioral Modeling and Timing Constraints

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

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

ECEN 468 Advanced Logic Design

Introduction to Verilog

P-1/P-105. Samir Palnitkar. Prentice-Hall, Inc. INSTRUCTOR : CHING-LUNG SU.

Online Verilog Resources

Outline. EECS150 - Digital Design Lecture 5 - Verilog 2. Structural Model: 2-to1 mux. Structural Model - XOR. Verilog Basics Lots of Examples

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

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Verilog for Synthesis Ing. Pullini Antonio

2/14/2016. Hardware Synthesis. Midia Reshadi. CE Department. Entities, Architectures, and Coding.

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

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

Lab 7 (Sections 300, 301 and 302) Prelab: Introduction to Verilog

Sequential Logic Design

Chap 3. Modeling structure & basic concept of Verilog HDL

Hardware Description Language VHDL (1) Introduction

Hardware Description Languages (HDLs) Verilog

Writing Circuit Descriptions 8

Federal Urdu University of Arts, Science and Technology, Islamabad VLSI SYSTEM DESIGN. Prepared By: Engr. Yousaf Hameed.

תכן חומרה בשפת VERILOG הפקולטה להנדסה

DIGITAL SYSTEM DESIGN

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

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

Chapter 6: Hierarchical Structural Modeling

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

Introduction to Verilog

Introduction To Verilog Design. Chun-Hung Chou

Lecture 32: SystemVerilog

Verilog HDL Introduction

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

Course Topics - Outline

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

Verilog Design Principles

Verilog Hardware Description Language ROOM: B405

Digital Design with SystemVerilog

Introduction to Verilog/System Verilog

RTL Design (Using ASM/SM Chart)

Digital Systems Design

Verilog 1 - Fundamentals

Introduction to Verilog HDL

CS6710 Tool Suite. Verilog is the Key Tool. Verilog as HDL (AHT) Verilog has a Split Personality. Quick Review. Synthesis

CAD for VLSI Design - I. Lecture 21 V. Kamakoti and Shankar Balachandran

Under-Graduate Project Logic Design with Behavioral Models

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

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

Programmable Logic Devices Verilog VII CMPE 415

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

Why Should I Learn This Language? VLSI HDL. Verilog-2

HDLs and SystemVerilog. Digital Computer Design

Verilog introduction. Embedded and Ambient Systems Lab

EE 8351 Digital Logic Circuits Ms.J.Jayaudhaya, ASP/EEE

Digital Design (VIMIAA01) Introduction to the Verilog HDL

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

Veriolog Overview. CS/EE 3710 Fall 2010

Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm. Lecture 3

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

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

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

Modeling Concepts. Introduction

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

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

Transcription:

Design with Verilog Chap 6 Introduction to HDL (d) Credit to: MD Rizal Othman Faculty of Electrical & Electronics Engineering Universiti Malaysia Pahang Ext: 6036

VERILOG HDL Basic Unit A module Module Describes the functionality of the design States the input and output ports Example: A Computer Functionality: Perform user defined computations I/O Ports: Keyboard, Mouse, Monitor, Printer 2

Module General definition module module_name ( port_list ); port declarations; variable declaration; description of behavior endmodule Example module HalfAdder (A, B, Sum Carry); input A, B; output Sum, Carry; assign Sum = A ^ B; //^ denotes XOR assign Carry = A & B; // & denotes AND endmodule 3

Dataflow Dataflow: Specify output signals in terms of input signals Example: assign out = (sel & a) (~sel & b); b sel sel_n sel_b out sel_a 4 a

Dataflow Modeling Uses continuous assignment statement Used to describe combinational logic Output of the circuit evaluated whenever an input changes, i.e continuously assigned Can be used ONLY for nets, NOT for register variables Format: assign [ delay ] net = expression; Example: assign sum = a ^ b; Delay: Time duration between assignment from RHS to LHS All continuous assignment statements execute concurrently Order of the statement does not impact the design 5

Dataflow Modeling (cont.) Delay can be introduced Example: assign #2 sum = a ^ b; #2 indicates 2 time-units Associate time-unit with physical time `timescale time-unit/time-precision Example: `timescale 1ns/100 ps Timescale `timescale 1ns/100ps 1 Time unit = 1 ns Time precision is 100ps (0.1 ns) 10.512ns is interpreted as 10.5ns 6

Dataflow Modeling (cont.) Restrictions on Data Types: Can use only wire data type Cannot use reg data type Example: `timescale 1ns/100ps module HalfAdder (A, B, Sum, Carry); input A, B; output Sum, Carry; assign #3 Sum = A ^ B; assign #6 Carry = A & B; endmodule 7

Dataflow Modeling (cont.) 8

1. Implementation of a 2x4 decoder. module decoder_2x4 (out, in0, in1); output out[0:3]; input in0, in1; // Data flow modeling uses logic operators. assign out[0:3] = { ~in0 & ~in1, in0 & ~in1,~in0 & in1, in0 & in1 }; endmodule

2. Implementation of a Full adder. module full_adder (sum, c_out, in0, in1, c_in); output sum, c_out; input in0, in1, c_in; assign { c_out, sum } = in0 + in1 + c_in; endmodule

Behavioral Modeling Behavioral: Algorithmically specify the behavior of the design Example: if (select == 0) begin out = b; end a b Black Box 2x1 MUX out else if (select == 1) begin sel out = a; end 11

2. Behavioral Modeling Behavioral modeling is used to describe complex circuits. It is primarily used to model sequential circuits, but can also be used to model pure combinatorial circuits. The behavior of the design is described using procedural constructs: initial Statements and always Statements

Behavioral Modeling (cont.) always statement : Sequential Block Sequential Block: All statements within the block are executed sequentially When is it executed? Occurrence of an event in the sensitivity list Event: Change in the logical value Statements with a Sequential Block: Procedural Assignments can drive only reg data type. Which means left-side data (output) type cannot be nets. Can occur only within an initial or an always statement. It can model both combinational and sequential logic. 13

Behavioral Modeling (cont.) Example: module mux_2x1(a, b, sel, out); input a, a, sel; output reg out; always @(a or b or sel) begin if (sel == 1) out = a; else out = b; end endmodule Sensitivity List 14

Behavioral Modeling (cont.) Delay in Procedural Assignments Inter-Statement Delay Intra-Statement Delay Inter-Assignment Delay Example: Sum = A ^ B; #2 Carry = A & B; Delayed execution Intra-Assignment Delay Example: Sum = A ^ B; Carry = #2 A & B; Delayed assignment 15

Procedural Statement Two Procedural Statement initial Statement always Statement initial Statement : Executes only once always Statement : Executes in a loop Example: initial begin Sum = 0; Carry = 0; end always @(A or B) begin Sum = A ^ B; Carry = A & B; end 16

Event Control Event Control Edge Triggered Event Control Level Triggered Event Control Edge Triggered Event Control @ (posedge CLK) //Positive Edge of CLK Curr_State = Next_state; Level Triggered Event Control @ (A or B) //change in values of A or B Out = A & B; 17

module cont_proc (in1, in2, out1_cont, out2_cont, out1_proc, out2_proc); input in1, in2; output out1_cont, out2_cont, out1_proc, out2_proc; wire in1, in2,out1_cont, out2_cont; reg out1_proc, out2_proc; //continuous assignment assign #2 out1_cont = in1 in2; assign #1 out2_cont = in1 in2; always@(in1, in2) begin //procedural assignment #2 out1_proc = in1 in2; #1 out2_proc = in1 in2; end endmodule

Loop Statements Loop Statements Repeat While For Repeat Loop Example: repeat (Count) sum = sum + 5; If condition is a x or z it is treated as 0 19

Loop Statements (cont.) While Loop Example: while (Count < 10) begin sum = sum + 5; Count = Count +1; end If condition is a x or z it is treated as 0 For Loop Example: for (Count = 0; Count < 10; Count = Count + 1) begin sum = sum + 5; end 20

Conditional Statements if Statement Format: if (condition) procedural_statement else if (condition) procedural_statement else procedural_statement Example: if (Clk) Q = 0; else Q = D; 21

Conditional Statements (cont.) Case Statement Example 1: case (X) 2 b00: Y = A + B; 2 b01: Y = A B; 2 b10: Y = A / B; endcase 22

Conditional Statements (cont.) Variants of case Statements: casex and casez casez z is considered as a don t care casex both x and z are considered as don t cares Example: casez (X) 2 b1z: A = B + C; 2 b11: A = B / C; endcase 23

1. Implementation of a full adder. module full_adder (sum, c_out, in0, in1, c_in); output sum, c_out; reg sum, c_out input in0, in1, c_in; always @(in0, in1, c_in) {c_out, sum} = in0 + in1 + c_in; endmodule

2. Implementation of a 8-bit binary counter. module ( count, reset, clk ); output [7:0] count; reg [7:0] count; input reset, clk; // consider reset as active low signal always @( posedge clk, negedge reset) begin if(reset == 1'b0) count <= 8'h00; else count <= count + 8'h01; end endmodule

Implementation of a Full adder using Dataflow modeling module full_adder (sum, c_out, in0, in1, c_in); output sum, c_out; input in0, in1, c_in; assign { c_out, sum } = in0 + in1 + c_in; endmodule Implementation of a full adder using Behavioral modeling module full_adder (sum, c_out, in0, in1, c_in); output sum, c_out; reg sum, c_out input in0, in1, c_in; always @(*) {c_out, sum} = in0 + in1 + c_in; endmodule

Homework & Discussion 3. Implementation of a 4x1 multiplexer using Dataflow and Behavioral modeling. Module... endmodule

3. Structural Modeling 1. Data flow: To design combinational ONLY Use assign statement 2. Behavior To design combinational and sequential circuits Uses arithmetic expressions, procedural assignments (initial and always ), or other Verilog control flow structures

3. Structural Modeling A top-down design by combining lower-level logic modules into a larger structural module. Each lower-level modules (sub-modules) must have previously compiled and tested for correct functional operation Structural modeling can be described using build-in gate primitives or module instances in any combination Interconnections between instances are specified using nets

3. Structural Modeling (Example ) Design the circuit based on expression: z1 = x1x2 + x2x3 x4 + x1 x2 x3x4

3. Structural Modeling (Example ) Design a full adder circuit using structural modeling

Group discussion

3. Structural Modeling (homework? ) Design a four-bit ripple adder circuit using structural modeling

Group discussion

4. Mixed-design Modeling Incorporates different modeling styles in the same module Includes gate, module instantiations, continuous assignment and behavioral constructs For example, a full adder can be designed using built-in primitives, dataflow and behavioral modeling

4. Mixed-design Modeling //mixed-designed full adder Module full_adder_mix (a,b,cin,sum,cout); // list inputs and outputs Input a, b, cin; Output sum, cout; // define reg and wire Reg cout; Wire a, b, cin; Wire sum; Wire net1; //built-in primitive Xor (net1, a,b); //behavioral Always @ (a or b or cin) Begin cout=cin & (a^b) (a&b); End //dataflow Assign sum=net1^cin; endmodule

Exercise & Discussion Finite state machine (FSM)