Mr. Pradeep J NATIONAL INSTITUTE OF TECHNOLOGY,

Slides:



Advertisements
Similar presentations
Traffic light contoller using FSM
Advertisements

Verilog in transistor level using Microwind
//HDL Example 4-10 // //Gate-level description of circuit of Fig. 4-2 module analysis (A,B,C,F1,F2); input.
Verilog.
//HDL Example 5-1 // //Description of D latch (See Fig.5-6) module D_latch (Q,D,control); output Q; input.
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
FSM examples.
Pulse-Width Modulated DAC
Verilog-HDL Reference: Verilog HDL: a guide to digital design and synthesis, Palnitkar, Samir Some of slides in this lecture are supported by Prof. An-Yeu.
Verilog Tutorial Abdul-Rahman Elshafei COE-561. Abdul-Rahman Elshafei2 Nov 16, 2006 Introduction Purpose of HDL: 1. Describe the circuit in algorithmic.
ENEE 408C Lab Capstone Project: Digital System Design Spring 2006 Class Web Site:
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
FSMs in Verilog and other random things 9/27/02. FSM structure CLK STATE Next State Logic Inputs Output Logic Outputs.
Sequential Logic in Verilog
1 COMP541 State Machines Montek Singh Feb 8, 2012.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
EEE2243 Digital System Design Chapter 4: Verilog HDL (Sequential) by Muhazam Mustapha, January 2011.
Register Transfer Level & Design with ASM
Number Systems and Circuits for Addition Lecture 5 Section 1.5 Thu, Jan 26, 2006.
Hardware languages "Programming"-language for modelling of (digital) hardware 1 Two main languages: VHDL (Very High Speed Integrated Circuit Hardware Description.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL State Machines Anselmo Lastra.
Introduction to ASIC flow and Verilog HDL
Number Systems and Circuits for Addition – Binary Adders Lecture 6 Section 1.5 Fri, Jan 26, 2007.
Introduction to Verilog
1 COMP541 State Machines - II Montek Singh Feb 13, 2012.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Chapter1: Introduction Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 1-1 Chapter 1: Introduction Prof. Ming-Bo.
1 Modeling of Finite State Machines Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur.
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Finite State Machine -Moore & Mealy Machine -State Encoding Techniques.
Lecture 5. Verilog HDL #3 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Figure Implementation of an FSM in a CPLD..
Exp#7 Finite State Machine Design in Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
EECE6017C - Lab 0 Introduction to Altera tools and Basic Digital Logic
Verilog Tutorial Fall
Figure 8.1. The general form of a sequential circuit.
Lecture L5.1 Mealy and Moore Machines
Verilog-HDL Reference: Verilog HDL: a guide to digital design and synthesis, Palnitkar, Samir Some of slides in this lecture are supported by Prof. An-Yeu.
Reg and Wire:.
Supplement on Verilog Sequential circuit examples: FSM
Lecture 2 Supplement Verilog-01
Learning Outcome By the end of this chapter, students are expected to be able to: Design State Machine Write Verilog State Machine by Boolean Algebra and.
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Introduction To Verilog-HDL
Pulse-Width Modulation (PWM)
Digital Logic Design Digital Design, M. Morris Mano and Michael D
COMP541 State Machines Montek Singh Feb 4, 2010.
Adopted from Abdul-Rahman Elshafei’s slides
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
Abdul-Rahman Elshafei COE-561
Verilog.
ESE 437: Sensors and Instrumentation
332:437 Lecture 8 Verilog and Finite State Machines
COE 202 Introduction to Verilog
Supplement on Verilog Sequential circuit examples: FSM
The Verilog Hardware Description Language
Verilog-HDL Reference: Verilog HDL: a guide to digital design and synthesis, Palnitkar, Samir Some of slides in this lecture are supported by Prof. An-Yeu.
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
Supplement on Verilog adder examples
The Verilog Hardware Description Language
332:437 Lecture 8 Verilog and Finite State Machines
Introduction to Digital IC Design
Implementation Of Full Adder Using Spartan-3E FPGA
Lecture 7: Verilog Part II
Presentation transcript:

Mr. Pradeep J NATIONAL INSTITUTE OF TECHNOLOGY, (STB99061) NATIONAL INSTITUTE OF TECHNOLOGY, TIRUCHIRAPPALLI – 620 015 3-DAY TUTORIAL ON VERILOG HDL Organized by IEEE STUDENT BRANCH NIT TRICHY Mr. Pradeep J M.Tech Scholar NIT-T Department of Electronics and Communication Engineering 22 March 2019

Today’s Topic Module Instantiation FSM

MODULE INSTANTIATION A module provides a template from which you can create actual objects. When a module is invoked, Verilog creates a unique object from the template. Each object has its own name, variables, parameters, and I/O interface. The process of creating objects from a module template is called instantiation, and the objects are called instances

4 BIT ADDER

module half_adder(in_a,in_b,sum,carry); input in_a,in_b; output sum,carry; assign sum = in_a ^ in_b; assign carry = in_a & in_b; endmodule module full_adder (in_a,in_b,carryin,sum,carryout); input in_a,in_b,carryin; output sum,carryout; wire sum1,carry1,carry2; half_adder h1(in_a,in_b,sum1,carry1); half_adder h2(sum1,carryin,sum,carry2); assign carryout = carry1 | carry2; module half_adder(in_a,in_b,sum,carry); input in_a,in_b; output sum,carry; assign sum = in_a ^ in_b; assign carry = in_a & in_b; endmodule module full_adder (in_a,in_b,carryin,sum,carryout); input in_a,in_b,carryin; output sum,carryout; wire sum1,carry1,carry2; half_adder h1(in_a,in_b,sum1,carry1); half_adder h2(sum1,carryin,sum,carry2); assign carryout = carry1 | carry2; module adder4bit(a,b,sum,carryin,carryout); input [3:0]a,b; input carry; output [3:0]sum; output carryout; wire [2:0]carry; full_adder f1(a[0],b[0],carryin,sum[0],carry[0]); full_adder f2(a[1],b[1],carry[0],sum[1],carry[1]); full_adder f3(a[2],b[2],carry[1],sum[2],carry[2]); full_adder f4(a[3],b[3],carry[2],sum[3],carryout); Endmodule

module adder_test; wire [3:0]sum; wire carryout; reg [3:0]a,b; reg carryin; adder4bit a1(a,b,sum,carryin,carryout); initial begin #10 a=4'b1010;b=4'b1101;carryin=1'b1; #10 a=4'b1110;b=4'b1001;carryin=1'b0; end $monitor($time,"%b %b %b %b %b",a,b,carryin,sum,carryout); #100 $stop; endmodule

INTRODUCTION TO FSM Combinational and Sequential Circuits In a combinational circuit, the outputs depend only on the applied input values and not on the past history. In a sequential circuit, the outputs depend not only on the applied input values but also on the internal state. The internal states also change with time. The number of states is finite, and hence a sequential circuit is also referred to as a Finite State Machine (FSM). Most of the practical circuits are sequential in nature.

FSM

MEALY AND MOORE MACHINE

EXAMPLE 1

always@(state) begin case(state) s0: color = red; s1: color = green; s2: color = yellow; endcase end endmodule module light(clk,reset,color); input clk,reset; output reg [1:0]color; parameter s0=2'b00,s1=2'b01,s1=2'b10; parameter red = 2'b00, green =2'b01, yellow =2'b10; reg [1:0]state; always@(posedge clk) begin if (reset == 1'b1) state <= s0; else case(state) s0: state <= s1; s1: state <= s2; s2: state <= s0; endcase end

module light_test; wire color; reg clk,reset; light l1(clk,reset,color); initial begin reset = 1'b0; clk = 1'b0; end always #5 clk = ~clk; #3 reset =1'b1; #10 reset = 1'b0; endmodule

EXAMPLE 2

module parity_gen(x,clk,reset,z) input x,clk,reset; output reg z; parameter even =1'b0, odd = 1'b1; reg state; always@(posedge clk) begin if (reset ==1'b1) state <= even; else case(state) even: begin if(x == 1'b1) state <= odd; end odd: begin if(x == 1'b1) state <= even; else state <= odd; end endcase always@(state) begin case(state) even: z=1; odd: z=0; endmodule

module paritygentest; wire z; reg x,reset,clk; parity_gen p1(x,clk,reset,z); initial begin reset = 1'b0; clk = 1'b0; x=1'b0; end always #5 clk = ~clk; initial begin #3 reset =1'b1; #10 reset = 1'b0;x=1'b1; #10 x=1'b0; #10 x=1'b1; end endmodule

EXAMPLE 3

SEQUENCE DETECTOR

always@(present_state,x) begin case(present_state) s0: begin if(x==0) begin next_state = s1; z=0; end else begin next_state = s0; z=0; end end s1: begin if(x==1) begin next_state = s2;z=0; end else begin next_state = s1; z=0; end s2: begin if(x==1) begin next_state = s3;z=0; end else begin next_state = s1;z=0; end s3: begin if(x==1) begin next_state = s0; z=0; end else begin next_state = s1; z=1; end endcase endmodule module sequence_detect(x,clk,reset,z); input x,clk,reset; output reg z; parameter s0=2'b00,s1=2'b01,s2=2'b10,s3=2'b11; reg [1:0]present_state,next_state; always@(posedge clk) begin if(reset ==1) preset_state <= s0; else present_state <= next_state; end

module seq_detect_test; wire z; reg x,reset,clk; sequence_detect(x,clk,reset,z); initial begin clk=1'b0; reset=1'b0; x=1'b0; end always #5 clk=~clk; initial begin #3 reset = 1'b1; #10 reset = 1'b0; #10 x = 1'b0; #10 x = 1'b1; end $monitor($time,"%b%b%b%b",x,clk,reset,z); #100 $stop; endmodule

A<=B B=1 A=0 C<=A

THANK YOU