Verilog HDL: Behavioral Counter

Similar documents
HDLs. Introduction to Design Using AHDL AHDL. Subdesign Section

AHDL Training Class. Danny Mok Altera HK FAE P.1. Copyright 1997 Altera Corporation

Lab 4: Register File and Memory 50 points Instructor: Yifeng Zhu Due: One week

Laboratory Exercise 8

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

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

CME341 Assignment 4. module if\_else\_combinational\_logic( input [3:0] a, b, output reg [3:0] y ); * begin

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

Modeling Sequential Circuits in Verilog

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

EECS150 - Digital Design Lecture 10 Logic Synthesis

Table 17-3: Symbols in the Schematic View

ECE 437 Computer Architecture and Organization Lab 6: Programming RAM and ROM Due: Thursday, November 3

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Nikhil Gupta. FPGA Challenge Takneek 2012

Last Lecture. Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal

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.

University of Florida EEL 3701 Drs. Eric M. Schwartz & Karl Gugel. Quartus ROM Creation Instructions (in Quartus Prime Lite 17.1)

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

EECS150 - Digital Design Lecture 10 Logic Synthesis

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

Chapter 9: Sequential Logic Modules

Digital System Design Verilog-Part III. Amir Masoud Gharehbaghi

Lecture #2: Verilog HDL

Spring 2017 EE 3613: Computer Organization Chapter 5: Processor: Datapath & Control - 2 Verilog Tutorial

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

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

Implementing Double Data Rate I/O Signaling in Stratix & Stratix GX Devices. Introduction. DDR I/O Elements. Input Configuration

Introduction. Why Use HDL? Simulation output. Explanation

Designing with ESBs in APEX II Devices

CSE140L: Components and Design Techniques for Digital Systems Lab

Contents. Appendix D Verilog Summary Page 1 of 16

Verilog introduction. Embedded and Ambient Systems Lab

Introduction to Digital Design with Verilog HDL

ECE 4514 Digital Design II. Spring Lecture 2: Hierarchical Design

CS/EE Homework 7 Solutions

ECE 551: Digital System *

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

CSE140L: Components and Design

Chapter 9: Sequential Logic Modules

Workshop on Digital Circuit Design in FPGA

EECS150 - Digital Design Lecture 16 Memory 1

Verilog for Synthesis Ing. Pullini Antonio

MC9S12 has 16 bit address and 16 bit data buses. Not enough pins on MC9S12 to allocate 35 pins for buses and pins for all other functions

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

Lecture 3. Behavioral Modeling Sequential Circuits. Registers Counters Finite State Machines

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

Verilog 1 - Fundamentals

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

Blocking(=) vs Nonblocking (<=) Assignment. Lecture 3: Modeling Sequential Logic in Verilog HDL. Procedural assignments

Synthesis of Combinational and Sequential Circuits with Verilog

EECS150 - Digital Design Lecture 16 - Memory

EEL 4783: HDL in Digital System Design

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

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

CSE 591: Advanced Hardware Design and Verification (2012 Spring) LAB #0

Student Name: Student ID: CSE 591: Advanced Hardware Design Professor: Kyle Gilsdorf

Lecture 15: System Modeling and Verilog

Verilog 1 - Fundamentals

Quartus. Tutorial. Programmable Logic Development System

Asynchronous FIFO Design

Feature EPF10K30E EPF10K50E EPF10K50S

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

University of Technology

Introduction. Purpose. Intended Audience. Conventions. Close

Last Lecture: Divide by 3 FSM

Synchronous Design. Latch Instability. RS Latch. RS Latch Timing. Signal Arrival Times. Simultaneous Switching

Lecture 2: Data Types, Modeling Combinational Logic in Verilog HDL. Variables and Logic Value Set. Data Types. Why use an HDL?

Discontinued IP. Distributed Memory v7.1. Functional Description. Features

In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and

ECE 4514 Digital Design II. Spring Lecture 15: FSM-based Control

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

Introduction to Verilog design. Design flow (from the book) Hierarchical Design. Lecture 2

Introduction to Verilog HDL. Verilog 1

Using Library Modules in Verilog Designs

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

Writing Circuit Descriptions 8

Phase-Locked Loop Reconfiguration (ALTPLL_RECONFIG) Megafunction

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

Synchronous Design. Synchronous design means that all registers are clocked by the same signal. Synchronous design is always desirable in

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

Using Programmable Logic and the PALCE22V10

Binary Counter V3.0. Features

Learning Outcomes. Input / Output. Introduction PICOBLAZE 10/18/2017

Sequential Logic Blocks

Introduction to Verilog design. Design flow (from the book)

EECS 270 Verilog Reference: Sequential Logic

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Verilog Lecture Gandhi Puvvada, USC always statements, Coding a Flip-Flop. blocking and non-blocking assignments. Copyright 2008 Gandhi Puvvada 1

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

VERILOG: FLIP-FLOPS AND REGISTERS


Laboratory Exercise 7

Quick Introduction to SystemVerilog: Sequental Logic

EE431 April 6, 2009 Midterm Material on Assignments 6 to 10

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

Verilog for High Performance

Online Verilog Resources

LeonardoSpectrum & Quartus II Design Methodology

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

Transcription:

Verilog HDL: Behavioral Counter This example describes an 8-bit loadable counter with count enable. The always construct, highlighted in red text, describes how the counter should behave. behav_counter.v module behav_counter( d, clk, clear, load, up_down, qd); // Port Declaration input [7:0] d; input clk; input clear; input load; input up_down; output [7:0] qd; reg [7:0] cnt; assign qd = cnt; always @ (posedge clk) if (!clear) cnt = 8'h00; if (load) cnt = d; if (up_down) cnt = cnt + 1; cnt = cnt - 1; Verilog HDL: Parameterized Counter This example shows how to instantiate an LPM function in Verilog HDL. In this case, an LPM_COUNTER is instantiated using the aclr, clock, and q ports. The parameter values are set with the keyword defparam, as shown in red text. Both the port mapping and the parameter names are referred to by the period (.) operator after the variable name. In this case, the variable is u1. check_lpm.v module check_lpm ( clk, reset, q); // Port Declaration input clk; input reset; output [7:0] q; lpm_counter u1 (.aclr(reset),.clock(clk),.q(q)); defparam u1.lpm_width= 8; defparam u1.lpm_direction= "UP";

Verilog HDL: Synchronous State Machine This is a Verilog example that shows the implementation of a state machine. The first CASE statement defines the outputs that are depent on the value of the state machine variable state. The second CASE statement defines the transitions of state machine and the conditions that control them. statem.v module statem(clk, in, reset, out); input clk, in, reset; output [3:0] out; reg [3:0] out; reg [1:0] state; parameter zero=0, one=1, two=2, three=3; always @(state) case (state) zero: out = 4'b0000; one: out = 4'b0001; two: out = 4'b0010; three: out = 4'b0100; default: out = 4'b0000; case always @(posedge clk or posedge reset) if (reset) state = zero; case (state) zero: state = one; one: if (in) state = zero; state = two; two: state = three; three: state = zero; case

Verilog HDL: Tri-State Instantiation This simple example shows how to instantiate a tri-state buffer in Verilog HDL using the keyword bufif1. The output type is tri. The buffer is instantiated by bufif1 with the variable name b1. tristate.v module Tristate (in, oe, out); input in, oe; output out; tri out; bufif1 b1(out, in, oe); Verilog HDL: Bidirectional Pin This example implements a clocked bidirectional pin in Verilog HDL. The value of OE determines whether bidir is an input, feeding in inp, or a tri-state, driving out the value b. bidir.v module bidirec (oe, clk, inp, outp, bidir); // Port Declaration input oe; input clk; input [7:0] inp; output [7:0] outp; inout [7:0] bidir; reg [7:0] a; reg [7:0] b; assign bidir = oe? a : 8'bZ ; assign outp = b; // Always Construct always @ (posedge clk) b <= bidir; a <= inp;

Instantiating a DFFE This example describes how to generate a D flipflop with enable (DFFE) behaviorally with asynchronous preset and reset signals. Both the preset and reset signals are active low, controlling the output of the DFFE whenever either signal goes low. dffeveri.v module dffeveri (q, d, clk, ena, rsn, prn); // port declaration input d, clk, ena, rsn, prn; output q; reg q; always @ (posedge clk or negedge rsn or negedge prn) //asynchronous active-low preset if (~prn) if (rsn) q = 1'b1; q = 1'bx; //asynchronous active-low reset if (~rsn) q = 1'b0; //enable if (ena) q = d; Verilog HDL: Instantiating MAX+PLUS II Primitives This example describes how to instantiate MAX+PLUS II primitives in Verilog HDL. It instantiates a simple D-type flip-flop, an LCELL primitive, and an open-drain pin. vprim.v module vprim (indata, outdata, clock); input output reg indata, clock; outdata; out_dff, out_lcell; dff d1(.d(indata),.q(out_dff),.clk(clock)); lcell l1(.in(out_dff),.out(out_lcell)); opndrn o1(.in(out_lcell),.out(outdata));

The vprim.v design would look like the following diagram if done in schematic format: Verilog HDL: Parameterized RAM with Separate Input & Output Ports This example shows how to instantiate a memory block using the LPM function lpm_ram_dq. The variable ram uses the lpm_ram_dq function from the LPM library. The ports are initially defined and then mapped to the LPM ports, as shown in red text. The parameter values are then passed through with the keyword defparam. In this example, a 16 x 256 RAM block is instantiated; you can use a similar process to instantiate RAM blocks of other sizes. The lpm_file parameter refers to the Memory Initialization File (.mif) that specifies the initial content of a memory block (RAM or ROM). An MIF is an ASCII text file can be created manually or saved from the output of a simulation. In an MIF, you are required to specify the memory depth and width values and optionally you can specify the radixes used to display and interpret addresses and data values. These values are shown in red text in the extract from the sample file, map_lpm_ram.mif, which is included below. An MIF is used as an input file for memory initialization in the MAX+PLUS II Compiler and Simulator. RAMveri.v // instantiation of lpm_ram_dq, 16-bit data, 256 address location module map_lpm_ram (dataout, datain, addr, we, inclk, outclk); // port instantiation input [15:0] datain; input [7:0] addr; input we, inclk, outclk; output [15:0] dataout; // instantiating lpm_ram_dq lpm_ram_dq ram (.data(datain),.address(addr),.we(we),.inclock(inclk),.outclock(outclk),.q(dataout)); // passing the parameter values defparam ram.lpm_width = 16; defparam ram.lpm_widthad = 8; defparam ram.lpm_indata = "REGISTERED"; defparam ram.lpm_outdata = "REGISTERED"; defparam ram.lpm_file = "map_lpm_ram.mif";

----------------------------------------------------------------------------- Extract from the MIF file Download map_lpm_ram.mif WIDTH = 16; DEPTH = 256; ADDRESS_RADIX = HEX; DATA_RADIX = HEX; CONTENT BEGIN 0 : ffff; 1 : 0000; 2 : bbf3; 3 : 0000; 4 : 0000;... fb : 0000; fc : 0000; fd : 0000; fe : 0000; ff : 0000; END;