Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

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

Nikhil Gupta. FPGA Challenge Takneek 2012

Digital Design with FPGAs. By Neeraj Kulkarni

Verilog 1 - Fundamentals

Digital Integrated Circuits

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

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

Hardware Description Languages (HDLs) Verilog

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

Synthesis of Combinational and Sequential Circuits with Verilog

Chap 6 Introduction to HDL (d)

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

Register Transfer Level in Verilog: Part I

Verilog introduction. Embedded and Ambient Systems Lab

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

Design Using Verilog

Hardware Description Language VHDL (1) Introduction

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

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

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

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

ENEE245 Digital Circuits and Systems Lab Manual

Verilog Hardware Description Language ROOM: B405

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

ENEE245 Digital Circuits and Systems Lab Manual

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

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

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

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

Lecture #2: Verilog HDL

ECE 551: Digital System *

CSE140L: Components and Design Techniques for Digital Systems Lab

FPGA Design Challenge Techkriti Digital Logic Design using Verilog Part 2 By Neeraj Kulkarni

Synthesizable Verilog

Verilog for Synthesis Ing. Pullini Antonio

Brief Introduction to Verilog HDL (Part 1)

Topics. Midterm Finish Chapter 7

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

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

CSE140L: Components and Design

Verilog Tutorial (Structure, Test)

Verilog Module 1 Introduction and Combinational Logic

Chapter 2 Using Hardware Description Language Verilog. Overview

Online Verilog Resources

Lecture 15: System Modeling and Verilog

Verilog 1 - Fundamentals

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

PINE TRAINING ACADEMY

Two hours - online EXAM PAPER MUST NOT BE REMOVED FROM THE EXAM ROOM UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

Graphics: Alexandra Nolte, Gesine Marwedel, Universität Dortmund. RTL Synthesis

Verilog for High Performance

Workshop on Digital Circuit Design in FPGA

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

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

Introduction to Verilog HDL. Verilog 1

Contents. Appendix D Verilog Summary Page 1 of 16


ECE 574: Modeling and Synthesis of Digital Systems using Verilog and VHDL. Fall 2017 Final Exam (6.00 to 8.30pm) Verilog SOLUTIONS

CSCB58 - Lab 3. Prelab /3 Part I (in-lab) /2 Part II (in-lab) /2 TOTAL /8

ECEN 468 Advanced Logic Design

Combinational Logic II

RTL Design (Using ASM/SM Chart)

Verilog Tutorial. Introduction. T. A.: Hsueh-Yi Lin. 2008/3/12 VLSI Digital Signal Processing 2

VERILOG. Deepjyoti Borah, Diwahar Jawahar

CS429: Computer Organization and Architecture

Introduction to Verilog/System 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

Digital Design with SystemVerilog

EEL 4783: HDL in Digital System Design

EECS150 - Digital Design Lecture 10 Logic Synthesis

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

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

HDLs and SystemVerilog. Digital Computer Design

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

Lecture 32: SystemVerilog

Verilog HDL. Gate-Level Modeling

Verilog. Verilog for Synthesis

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

Writing Circuit Descriptions 8

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

MODELING LANGUAGES AND ABSTRACT MODELS. Giovanni De Micheli Stanford University. Chapter 3 in book, please read it.

Digital Design (VIMIAA01) Introduction to the Verilog HDL

EECS150 - Digital Design Lecture 8 - Hardware Description Languages

VHDL VS VERILOG.

Verilog HDL. Testing & Verification Dept. of Computer Science & Engg,, IIT Kharagpur

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

EE 231 Fall EE 231 Homework 8 Due October 20, 2010

Module 4. Design of Embedded Processors. Version 2 EE IIT, Kharagpur 1

Chapter 4 :: Topics. Introduction. SystemVerilog. Hardware description language (HDL): allows designer to specify logic function only.

(ii) Simplify and implement the following SOP function using NOR gates:

L3: Introduction to Verilog (Combinational Logic)

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

C-Based Hardware Design

Graduate Institute of Electronics Engineering, NTU. Lecturer: Chihhao Chao Date:

Readings: Storage unit. Can hold an n-bit value Composed of a group of n flip-flops. Each flip-flop stores 1 bit of information.

Digital Integrated Circuits

EECS150 - Digital Design Lecture 10 Logic Synthesis

Transcription:

Verilog Fundamentals Shubham Singh Junior Undergrad. Electrical Engineering

VERILOG FUNDAMENTALS HDLs HISTORY HOW FPGA & VERILOG ARE RELATED CODING IN VERILOG

HDLs HISTORY HDL HARDWARE DESCRIPTION LANGUAGE

EARLIER DESIGNERS USED BREADBOARDS FOR DESIGNING SOLDERLESS BREADBOARD PRINTED CIRCUIT BOARD

HDLs ENABLED LOGIC LEVEL SIMULATION AND TESTING GATE LEVEL DESCRIPTION SIMULATE MANUAL

THEN DESIGNERS BEGAN TO USE HDLs FOR HIGHER LEVEL DESIGN BEHAVIOURAL ALGORITHM SIMUALTE MANUAL REGISTER TRANSFER LEVEL MANUAL GATE LEVEL MANUAL SIMULATE SIMULATE

HDLs LED TO TOOLS FOR AUTOMATIC TRANSLATION BEHAVIOURAL ALGORITHM SIMULATE MANUAL REGISTER TRANSFER LEVEL SIMULATE LOGIC SYNTHESIS SIMULATE GATE LEVEL AUTOPLACE & ROUTE

THE CURRENT SITUATION C,C++ COMPILERS ARE NOT AVAILABLE TO CONVERT BEHAVIOURAL LEVEL TO REGISTER TRANSFER LEVEL BEHAVIOURAL VERILOG STRUCTURAL VERILOG LOGIC SYNTHESIS GATE LEVEL MATLAB

MUX 4 : GATE LEVEL DESIGNING modulemux4(input a,b,c,d, input[1:0] sel, output out); wire[1:0] sel_b; not not0( sel_b[0], sel[0] ); not not1( sel_b[1], sel[1] ); wire n0, n1, n2, n3; and and0( n0, c, sel[1] ); and and1( n1, a, sel_b[1] ); and and2( n2, d, sel[1] ); and and3( n3, b, sel_b[1] ); wirex0, x1; nor nor0( x0, n0, n1 ); nor nor1( x1, n2, n3 ); wirey0, y1; or or0( y0, x0, sel[0] ); or or1( y1, x1, sel_b[0] ); nand nand0( out, y0, y1 ); endmodule

MUX 4 : REGISTER TRANSFER LEVEL Module mux4( input a, b, c, d input[1:0] sel, Output out ); wire out, t0, t1; assign out = ( sel == 0 )? a : ( sel == 1 )? b : ( sel == 2 )? c : ( sel == 3 )? d : 1 bx; endmodule

VERILOG & FPGAs

VERILOG Verilog is a HARDWARE DESCRIPTION LANGUAGE. HDLs are used to describe a digital system Not a programming language despite the syntax being similar to C Synthesized (analogous to compiled for C) to give the circuit logic diagram

FPGAs Field A Programmable Gate Array Fully configurable IC FPGAs contain programmable logic components called logic blocks. Contain hierarchy of reconfigurable interconnects that allow the blocks to be wired together. Logic FPGA Blocks can be configured to any complex circuit. can be made to work as a Xor gate, a Counter or even bigger- an entire Processor!

An FPGA

Logic Blocks

HOW TO PROGRAM FPGAs Configured using a Hardware Description Language Can be configured by any way by the user Basic Idea : BEHAVIOURAL DESCRIPTION OF REQUIRED CIRCUIT VERILOG SYNTHESISER A COMPLETE CIRCUIT DIAGRAM

Synthesis of VERILOG :

CODING IN VERILOG BREAKING CIRCUITS INTO VARIOUS BUILDING BLOCKS CALLED MODULE DEFINING MODULE CONNECTING VARIOUS MODULES

CODING IN VERILOG Communication between a module and its environment is achieved by using Ports Ports inout are of three types: input, output,

AN EXAMPLE : 4029 COUNTER Name: 4029 Input Ports: One Output Ports: Four Size Driver type Internal Logic: At every rising edge of the clock, increment the output by one

MODULE A Black Box in Verilog with inputs, outputs and internal logic working. So, a module can be used to implement a counter. A module is defined as module <specific type>(<port list>);

DEFINING 4029 MODULE Way 1: module 4029(clk,out,reset,enable); Way 2: module 4029(clk, a, b, c, d, reset, enable); Input and Output Ports in each of the above? EVERY Every PORT MUST HAVE A DIRECTION AND BITWIDTH module ends with the statement endmodule

DECLARING PORTS Way 1: input clk; input reset; input enable; output a,b,c,d; Way 2: input clk; input reset; input enable; output [3:0] out;

DRIVERS IN VERILOG We need drivers for this module in order to interact with the ports and describe its logical working. Two types of drivers: Can store a value (for example, flip-flop) : REG Cannot store a value, but connects two points (for example, a wire) : WIRE

DRIVERS IN 4029 Ports defined as wires? clk reset enable We do not need to stores the values of these ports in our logical block. Ports defined as reg? a,b,c,d out We need to store them so that we could modify their values when required.

DEFINING DRIVERS FOR 4029 Way 1: wire clk; wire reset; wire enable; reg a,b.c,d; Way 2: wire clk; wire reset; wire enable; reg [3:0] out;

Defining Internal Logic

OPERATORS AND CONDITIONAL OPERATORS All the arithmetic as well as logical operators in Verilog are similar to C, except ++ and -- which are not available in Verilog. Conditional statements are also similar to C with following modifications: { is replaced by begin. } is replaced by end.

COMBINATIONAL CIRCUITS Combinational circuits are acyclic interconnections of gates. And, Or, Not, Xor, Nand, Nor Multiplexers, Decoders, Encoders. OUTPUT IS A FUNCTION OF PRESENT INPUT ONLY

How are these gates, muxs etc. abstracted in Verilog? Gates, Add, Multiply : by simple operators like in C Multiplexers : by control statements like ifelse, case, etc Gate level implementation of above high level operators done by Verilog synthesizer.

SEQUENTIAL CIRCUITS Circuits containing state elements are called sequential circuits OUTPUT DEPENDS ON THE PRESENT INPUT AS WELL AS ON ITS PRESENT STATE. How do you implement such an element in Verilog?

always block Syntax always @(condition) begin //Code end Blocks starting with keyword always run simultaneously. @ symbol is used to specify the condition which should be satisfied for the execution of this block.

Usage of always block always The code in this block will keep on executing. always @(a) The code in this block will be executed every time the value of a changes. always @(posedge clk) This block is executed at every positive edge of clk.

always @ BLOCK It is an abstraction provided in Verilog to mainly implement sequential circuits. Also used for combinational circuits.

BLOCKING AND NON-BLOCKING ASSIGNMENTS Non-blocking assignments happen in parallel. always @ ( #sensitivity list # ) begin B <= A ; C <= B ; (A,B) = (1,2) -> (B,C) = (1,2) end Blocking assignments happen sequentially. always @ ( #sensitivity list # ) begin B =A; C=B; end (A,B) = (1,2) -> (B,C) = (1,1)

POINTS TO NOTE Use always@(*) block with blocking assignments for combinational circuits Use always@( posedge CLK) block with nonblocking assignments for sequential circuits. Do not mix blocking and non-blocking assignments.

A COMPLETE 4029 MODULE module 4029 ( input wire clk, input wire reset, input wire enable, output [3:0] reg out); //You can declare direction as well as data type //in the module definition.

always @(posedge clk) begin if (reset == 0 && enable == 0) begin out <= out +1; end end

always @(reset or enable) begin if (reset == 1 b1) begin out <= 0; end end endmodule

AN EXAMPLE

ANOTHER EXAMPLE

WRONG SOLUTION

ANOTHER WAY : MULTIPLE always BLOCK

WRONG SOLUTION

Connecting Various Modules

Various modules are interconnected to make a larger circuit (or module). Each sub-module has a separate Verilog file. A sub-module may have another submodule in its circuit. One needs to indicate the top level module before synthesis.

EXAMPLE module 4029(input wire clk, output [3:0]reg out); module 7447(input [3:0] reg in, output [6:0] reg bcd); module TOP(input wire clk, output [6:0] reg bcd);

INSTANTIATION USED TO INTERCONNECT VARIOUS MODULES In the above example, we need to instantiate the two sub-modules in the top level module THIS IS DONE AS FOLLOWS: wire [3:0] c; 4029 counter (.clk(clk),.out(c) ); 7447 decoder (.in(c),.bcd(bcd));

Problem Statement Level 1 : Theoretical Questions on basic syntax of Verilog Level 2 : Design a digital system using Verilog. (weightage will be given to how much modular your circuit is )