VHDL and Verilog for Modeling

Similar documents
Modeling Latches and Flip-flops

Chapter 7: Advanced Modeling Techniques

A Verilog HDL Test Bench Primer Application Note

Asynchronous & Synchronous Reset Design Techniques - Part Deux

Modeling Registers and Counters

Digital Design with VHDL

Chapter 5 :: Memory and Logic Arrays

VHDL GUIDELINES FOR SYNTHESIS

VHDL Test Bench Tutorial

ECE 3401 Lecture 7. Concurrent Statements & Sequential Statements (Process)

ECE232: Hardware Organization and Design. Part 3: Verilog Tutorial. Basic Verilog

Modeling Sequential Elements with Verilog. Prof. Chien-Nan Liu TEL: ext: Sequential Circuit

12. A B C A B C A B C 1 A B C A B C A B C JK-FF NETr

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

Lenguaje VHDL. Diseño de sistemas digitales secuenciales

Registers & Counters

Using Xilinx ISE for VHDL Based Design

LAB #3 VHDL RECOGNITION AND GAL IC PROGRAMMING USING ALL-11 UNIVERSAL PROGRAMMER

More Verilog. 8-bit Register with Synchronous Reset. Shift Register Example. N-bit Register with Asynchronous Reset.

Introduction. Jim Duckworth ECE Department, WPI. VHDL Short Course - Module 1

Implementation Details

if-then else : 2-1 mux mux: process (A, B, Select) begin if (select= 1 ) then Z <= A; else Z <= B; end if; end process;

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

Digital Circuit Design Using Xilinx ISE Tools

Implementation of Web-Server Using Altera DE2-70 FPGA Development Kit

Digital Design with Synthesizable VHDL

Chapter 13: Verification

Quartus II Introduction for VHDL Users

Sprites in Block ROM

A New Paradigm for Synchronous State Machine Design in Verilog

EXPERIMENT 8. Flip-Flops and Sequential Circuits

MAX II ISP Update with I/O Control & Register Data Retention

In this example the length of the vector is determined by D length and used for the index variable.

Memory unit. 2 k words. n bits per word

Introduction to Programmable Logic Devices. John Coughlan RAL Technology Department Detector & Electronics Division

RAPID PROTOTYPING OF DIGITAL SYSTEMS Second Edition

Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview

1. Memory technology & Hierarchy

IS61WV102416ALL IS61WV102416BLL IS64WV102416BLL 1M x 16 HIGH-SPEED ASYNCHRONOUS CMOS STATIC RAM WITH 3.3V SUPPLY JUNE 2014

DDS. 16-bit Direct Digital Synthesizer / Periodic waveform generator Rev Key Design Features. Block Diagram. Generic Parameters.

Lab 1: Introduction to Xilinx ISE Tutorial

! " # # $ '"() * #! +, # / $0123$

A N. O N Output/Input-output connection

To design digital counter circuits using JK-Flip-Flop. To implement counter using 74LS193 IC.

Altera Error Message Register Unloader IP Core User Guide

ECE 451 Verilog Exercises. Sept 14, James Barnes

Building Blocks for PRU Development

Computer Architecture

The 104 Duke_ACC Machine

Traffic Light Controller. Digital Systems Design. Dr. Ted Shaneyfelt

The Advanced JTAG Bridge. Nathan Yawn 05/12/09

SystemVerilog Is Getting Even Better!

Digital Systems Design. VGA Video Display Generation

ESP-CV Custom Design Formal Equivalence Checking Based on Symbolic Simulation

Asynchronous counters, except for the first block, work independently from a system clock.

Life Cycle of a Memory Request. Ring Example: 2 requests for lock 17

Rotary Encoder Interface for Spartan-3E Starter Kit

VGA video signal generation

Latches, the D Flip-Flop & Counter Design. ECE 152A Winter 2012

LAB #4 Sequential Logic, Latches, Flip-Flops, Shift Registers, and Counters

State Machines in VHDL

Module 3: Floyd, Digital Fundamental

FINITE STATE MACHINE: PRINCIPLE AND PRACTICE

Sequential Logic Design Principles.Latches and Flip-Flops

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

Chapter 2 Ensuring RTL Intent

VHDL programmering H2

Chapter 9 Latches, Flip-Flops, and Timers

Finite State Machine Design and VHDL Coding Techniques

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

Wiki Lab Book. This week is practice for wiki usage during the project.

Step : Create Dependency Graph for Data Path Step b: 8-way Addition? So, the data operations are: 8 multiplications one 8-way addition Balanced binary

Quartus II Software Design Series : Foundation. Digitale Signalverarbeitung mit FPGA. Digitale Signalverarbeitung mit FPGA (DSF) Quartus II 1

Combinational Logic Design Process

Digital Design Verification

Arbitration and Switching Between Bus Masters

路 論 Chapter 15 System-Level Physical Design

Below is a diagram explaining the data packet and the timing related to the mouse clock while receiving a byte from the PS-2 mouse:

Lecture-3 MEMORY: Development of Memory:

EC313 - VHDL State Machine Example

E158 Intro to CMOS VLSI Design. Alarm Clock

ModelSim-Altera Software Simulation User Guide

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

Prototyping ARM Cortex -A Processors using FPGA platforms

Introduction to Functional Verification. Niels Burkhardt

An Example VHDL Application for the TM-4

Verilog: Blocks

Getting the Most Out of Synthesis

Memory. The memory types currently in common usage are:

16-bit ALU, Register File and Memory Write Interface

Understanding Verilog Blocking and Non-blocking Assignments

VHDL Reference Manual

Asynchronous Counters. Asynchronous Counters

WEEK 8.1 Registers and Counters. ECE124 Digital Circuits and Systems Page 1

Cascaded Counters. Page 1 BYU

New Verilog-2001 Techniques for Creating Parameterized Models (or Down With `define and Death of a defparam!)

Hardware Implementation of the Stone Metamorphic Cipher

Memory Elements. Combinational logic cannot remember

8 by 8 dot matrix LED displays with Cascadable Serial driver B32CDM8 B48CDM8 B64CDM8 General Description

Transcription:

VHDL and Verilog for Modeling Module 10 Jim Duckworth, WPI 1 VHDL and Verilog for Modeling - Module 10

General examples AND model Flip-flop model SRAM Model Customizing Models Generics in VHDL DDR SDRAM Model Parameters in Verilog Overview Using Files in Verilog for Test Benches Jim Duckworth, WPI 2 VHDL and Verilog for Modeling - Module 10

We have covered VHDL for Modeling VHDL for Synthesis VHDL for testing (simulation) Now - VHDL and Verilog for modeling Describes the expected behavior of a component or device Can be used to test other components for example a model of a CPU could be used to test: UART DRAM memory controller cache controller Jim Duckworth, WPI 3 VHDL and Verilog for Modeling - Module 10

AND gate model -- 74LS08 model (typical delays) ENTITY ls08 IS END ls08; PORT(a, b : IN std_logic; c : OUT std_logic); ARCHITECTURE behav OF ls08 IS BEGIN END behav; c <= 1 AFTER 8 ns WHEN a = 1 AND b = 1 ELSE 0 AFTER 10 ns; Jim Duckworth, WPI 4 VHDL and Verilog for Modeling - Module 10

Simulation Results Jim Duckworth, WPI 5 VHDL and Verilog for Modeling - Module 10

D flip-flop model -- 74LS74 model (typical delays) -- 74LS74 model (typical delays) ENTITY ENTITY ls74 ls74 IS IS PORT(d, PORT(d, clr, clr, pre, pre, clk clk : : IN IN std_logic; std_logic; q : OUT std_logic); q : OUT std_logic); END END ls74; ls74; ARCHITECTURE ARCHITECTURE behav behav OF OF ls74 ls74 IS IS BEGIN BEGIN PROCESS(clk, clr, pre) PROCESS(clk, clr, pre) BEGIN BEGIN IF clr = 0 THEN IF clr = 0 THEN q <= 0 AFTER 25 ns; q <= 0 AFTER 25 ns; ELSIF pre = 0 THEN ELSIF pre = 0 THEN q <= 1 AFTER 13 ns; q <= 1 AFTER 13 ns; ELSIF clk EVENT AND clk = 1 THEN ELSIF clk EVENT AND clk = 1 THEN IF IF d d = = 1 1 THEN THEN q q <= <= 1 1 AFTER AFTER 13 13 ns; ns; ELSE ELSE q q <= <= 0 0 AFTER AFTER 25 25 ns; ns; END END IF; IF; END END IF; IF; END END PROCESS; PROCESS; END END behav; behav; Jim Duckworth, WPI 6 VHDL and Verilog for Modeling - Module 10

Simulation Results Jim Duckworth, WPI 7 VHDL and Verilog for Modeling - Module 10

Adding Constants - same as previous -- 74LS74 model (typical delays) ENTITY ls74 IS PORT(d, clr, pre, clk : IN std_logic; q : OUT std_logic); CONSTANT t_rise : TIME := 13 ns; CONSTANT t_fall : TIME := 25 ns; END ls74; ARCHITECTURE behav OF ls74 IS BEGIN PROCESS(clk, clr, pre) BEGIN IF clr = 0 THEN q <= 0 AFTER t_fall; ELSIF pre = 0 THEN q <= 1 AFTER t_rise; ELSIF clk EVENT AND clk = 1 THEN IF d = 1 THEN q <= 1 AFTER t_rise; ELSE q <= 0 AFTER t_fall; END IF; END IF; END PROCESS; END behav; Jim Duckworth, WPI 8 VHDL and Verilog for Modeling - Module 10

Adding setup and pulse width checks LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY ls74 IS PORT(d, clr, pre, clk : IN std_logic; q : OUT std_logic); CONSTANT t_rise : TIME := 13 ns; CONSTANT t_fall : TIME := 25 ns; CONSTANT t_setup : TIME := 20 ns; CONSTANT t_width : TIME := 25 ns; END ls74; Jim Duckworth, WPI 9 VHDL and Verilog for Modeling - Module 10

Basic D flip-flop description same ARCHITECTURE behav OF ls74 IS BEGIN PROCESS(clk, clr, pre) BEGIN IF clr = '0' THEN q <= '0' AFTER t_fall; ELSIF pre = '0' THEN q <= '1' AFTER t_rise; ELSIF clk'event AND clk = '1' THEN IF d = '1' THEN q <= '1' AFTER t_rise; ELSE q <= '0' AFTER t_fall; END IF; END IF; END PROCESS; Jim Duckworth, WPI 10 VHDL and Verilog for Modeling - Module 10

Add setup and pulse width checks -- process to check data setup time PROCESS(clk) BEGIN IF clk'event AND clk = '1' THEN ASSERT d'last_event > t_setup REPORT "D changed within setup time" SEVERITY ERROR; END IF; END PROCESS; -- process to check clock high pulse width PROCESS(clk) VARIABLE last_clk : TIME := 0 ns; BEGIN IF clk'event AND clk = '0' THEN ASSERT NOW - last_clk > t_width REPORT "Clock pulse width too short" SEVERITY ERROR; ELSE last_clk := NOW; END IF; END PROCESS; END behav; Jim Duckworth, WPI 11 VHDL and Verilog for Modeling - Module 10

Complete LS74 Model Jim Duckworth, WPI 12 VHDL and Verilog for Modeling - Module 10

New testbench Adding the SRAM model Picoblaze Display SRAM Model Jim Duckworth, WPI 13 VHDL and Verilog for Modeling - Module 10

Generics Generics useful for making design units more general purpose Generics allow information to be passed into a design description Example information propagation delays size of component (changing input and output ports) Jim Duckworth, WPI 14 VHDL and Verilog for Modeling - Module 10

LS08 example with generics -- 74LS08 model ENTITY ls08 IS GENERIC(t_rise, t_fall : TIME); END ls08; PORT(a, b : IN std_logic; c : OUT std_logic); ARCHITECTURE behav OF ls08 IS BEGIN END behav; c <= 1 AFTER t_rise WHEN a = 1 AND b = 1 ELSE 0 AFTER t_fall; This is now a parameterized model (general purpose) rather than hard-coded version Actual delay is determined at simulation time (or synthesis) by value passed to model Jim Duckworth, WPI 15 VHDL and Verilog for Modeling - Module 10

Instantiating Components with Generics -- example use of LS08 with generic values ENTITY test IS PORT(in1, in2, in3 : IN std_logic; END test; out1 : OUT std_logic); ARCHITECTURE behav OF test IS BEGIN END behav; COMPONENT ls08 GENERIC(t_rise, t_fall : TIME); PORT(a, b : IN std_logic; c : OUT std_logic); END COMPONENT; SIGNAL int : std_logic; u1: ls08 GENERIC MAP(8 ns, 10 ns) -- typical delays PORT MAP(a => in1, b => in2, c => int); u2: ls08 GENERIC MAP(15 ns, 20 ns)-- max delays PORT MAP(a => int, b => in3, c => out1); Jim Duckworth, WPI 16 VHDL and Verilog for Modeling - Module 10

Another Example (with default values) Can provide default values for generics Only need GENERIC MAP if necessary to change them ENTITY and2 IS GENERIC(t_rise, t_fall : TIME := 10 ns; load : INTEGER := 3); PORT(a, b IN : IN std_logic; c : OUT std_logic); END and2; ARCHITECTURE generic_model OF and2 IS BEGIN c <= 1 AFTER (t_rise + (load * 2 ns)) WHEN a = 1 AND b = 1 ELSE 0 AFTER (t_fall + (load * 2 ns)); END generic_model; u1: and2 GENERIC MAP(5 ns, 7 ns, 4) PORT MAP (a = > ); -- default overridden u2: and2 PORT MAP(a => ); -- uses default values Jim Duckworth, WPI 17 VHDL and Verilog for Modeling - Module 10

Modifying Component Size (also for synthesis) Jim Duckworth, WPI 18 VHDL and Verilog for Modeling - Module 10

Making two copies different size Jim Duckworth, WPI 19 VHDL and Verilog for Modeling - Module 10

Schematic of two shift registers Jim Duckworth, WPI 20 VHDL and Verilog for Modeling - Module 10

DDR SDRAM Model Jim Duckworth, WPI 21 VHDL and Verilog for Modeling - Module 10

DDR SDRAM Model (cont d) Jim Duckworth, WPI 22 VHDL and Verilog for Modeling - Module 10

DDR SDRAM Model (cont d) Jim Duckworth, WPI 23 VHDL and Verilog for Modeling - Module 10

DDR SDRAM Model (cont d) Jim Duckworth, WPI 24 VHDL and Verilog for Modeling - Module 10

Jim Duckworth, WPI 25 VHDL and Verilog for Modeling - Module 10

Verilog Lower Level Module with Parameters Jim Duckworth, WPI 26 VHDL and Verilog for Modeling - Module 10

Jim Duckworth, WPI 27 VHDL and Verilog for Modeling - Module 10

Three copies of XYZ module Jim Duckworth, WPI 28 VHDL and Verilog for Modeling - Module 10

RTL Schematic showing 3 modules Jim Duckworth, WPI 29 VHDL and Verilog VHDL for Modeling - Module 10

(Misc) Using UCF to specify pin options Jim Duckworth, WPI 30 VHDL and Verilog for Modeling - Module 10

Jim Duckworth, WPI 31 VHDL and Verilog for Modeling - Module 10

Jim Duckworth, WPI 32 VHDL and Verilog for Modeling - Module 10

Timing Check Tasks in Verilog Specify block can be used to specify setup and hold times for signals specify and endspecify (Use specparam to define parameters in specify block) $setup (data, clock edge, limit) Displays warning message if setup timing constraint is not met $setup(d, posedge clk, 10) $hold (clock edge, data, limit) Displays warning message if hold timing constraint is not met $hold(d, posedge clk, 2) $width (pulse event, limit) Displays warning message if pulse width is shorter than limit $width(d, posedge clk, 20) specify start edge of pulse $period (pulse event, limit) Check if period of signal is sufficiently long $period(posedge clk, 50) Jim Duckworth, WPI 33 VHDL and Verilog VHDL for Modeling - Module 10

Original Simple SRAM model Jim Duckworth, WPI 34 VHDL and Verilog VHDL for Modeling - Module 10

Adding Timing Checks and Delay Jim Duckworth, WPI 35 VHDL and Verilog VHDL for Modeling - Module 10

Testing with Test Bench Jim Duckworth, WPI 36 VHDL and Verilog VHDL for Modeling - Module 10

Warning Messages Jim Duckworth, WPI 37 VHDL and Verilog VHDL for Modeling - Module 10

ISSI SRAM Verilog Model (partial) // IS61LV25616 Asynchronous SRAM, 256K x 16 = 4M; speed: 10ns. // Note; 1) Please include "+define+ OEb" in running script if you want to check // timing in the case of OE_ being set. // 2) Please specify access time by defining tac_10 or tac_12. // `define OEb `define tac_10 `timescale 1ns/10ps module IS61LV25616 (A, IO, CE_, OE_, WE_, LB_, UB_); parameter dqbits = 16; parameter memdepth = 262143; parameter addbits = 18; parameter Toha = 2; parameter Tsa = 2; `ifdef tac_10 parameter Taa = 10, Thzce = 3, Thzwe = 5; `endif `ifdef tac_12 parameter Taa = 12, Thzce = 5, Thzwe = 6; `endif input CE_, OE_, WE_, LB_, UB_; input [(addbits - 1) : 0] A; inout [(dqbits - 1) : 0] IO; wire [(dqbits - 1) : 0] dout; reg [(dqbits/2-1) : 0] bank0 [0 : memdepth]; Jim Duckworth, WPI 38 VHDL and Verilog for Modeling - Module 10

Micron SRAM on Nexys2 board Complete model is > 1300 lines! Jim Duckworth, WPI 39 VHDL and Verilog for Modeling - Module 10

Jim Duckworth, WPI 40 VHDL and Verilog for Modeling - Module 10

Jim Duckworth, WPI 41 VHDL and Verilog for Modeling - Module 10

Jim Duckworth, WPI 42 VHDL and Verilog for Modeling - Module 10

Additional Verilog System Tasks @ (posedge clk) event control, wait for rising edge of clk wait (state == ENTER && ready == 1 b1) wait for specific condition #123 wait for 123 timescale units $display (print out information) $monitor (displays information when signal changes value) $time and $realtime $fopen and $fclose Integer log_file = $fopen( my_log ) $readmemb and $readmemh Jim Duckworth, WPI 43 VHDL and Verilog for Modeling - Module 10

Decoder Test Bench in Verilog with Files Jim Duckworth, WPI 44 VHDL and Verilog for Modeling - Module 10

Opening file in Verilog Jim Duckworth, WPI 45 VHDL and Verilog for Modeling - Module 10

Jim Duckworth, WPI 46 VHDL and Verilog for Modeling - Module 10

Waveform Generated Jim Duckworth, WPI 47 VHDL and Verilog for Modeling - Module 10

Console (and results file) Jim Duckworth, WPI 48 VHDL and Verilog for Modeling - Module 10