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



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

ECE 451 Verilog Exercises. Sept 14, James Barnes

Registers & Counters

Modeling Registers and Counters

Understanding Verilog Blocking and Non-blocking Assignments

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

Memory Elements. Combinational logic cannot remember

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

An Integer Square Root Algorithm

Combinational Logic Design Process

Computer organization

A New Paradigm for Synchronous State Machine Design in Verilog

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

16-bit ALU, Register File and Memory Write Interface

Finite State Machine Design and VHDL Coding Techniques

Asynchronous Counters. Asynchronous Counters

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

Systems I: Computer Organization and Architecture

Introduction to CMOS VLSI Design (E158) Lecture 8: Clocking of VLSI Systems

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

Cascaded Counters. Page 1 BYU

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

Digital Design with VHDL

FINITE STATE MACHINE: PRINCIPLE AND PRACTICE

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

Chapter 13: Verification

VHDL GUIDELINES FOR SYNTHESIS

(1) D Flip-Flop with Asynchronous Reset. (2) 4:1 Multiplexor. CS/EE120A VHDL Lab Programming Reference

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

Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann

Digital Design Verification

A Verilog HDL Test Bench Primer Application Note

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

State Machines in VHDL

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

Module 3: Floyd, Digital Fundamental

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;

Lecture 7: Clocking of VLSI Systems

Register File, Finite State Machines & Hardware Control Language

Lecture 10 Sequential Circuit Design Zhuo Feng. Z. Feng MTU EE4800 CMOS Digital IC Design & Analysis 2010

Chapter 5. Sequential Logic

CSE140 Homework #7 - Solution

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

Finite State Machine. RTL Hardware Design by P. Chu. Chapter 10 1

Vending Machine using Verilog

Topics of Chapter 5 Sequential Machines. Memory elements. Memory element terminology. Clock terminology

Digital Design with Synthesizable VHDL

3. VERILOG HARDWARE DESCRIPTION LANGUAGE

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

Chapter 7: Advanced Modeling Techniques

Multiplexers Two Types + Verilog

Manchester Encoder-Decoder for Xilinx CPLDs

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

Design of Digital Circuits (SS16)

Chapter 2 Verilog HDL for Design and Test

Using Xilinx ISE for VHDL Based Design

Getting the Most Out of Synthesis

Lecture-3 MEMORY: Development of Memory:

Sequential Circuit Design

Digital Logic Design Sequential circuits

Chapter 8. Sequential Circuits for Registers and Counters

Asynchronous & Synchronous Reset Design Techniques - Part Deux

EE 42/100 Lecture 24: Latches and Flip Flops. Rev B 4/21/2010 (2:04 PM) Prof. Ali M. Niknejad

CS 61C: Great Ideas in Computer Architecture Finite State Machines. Machine Interpreta4on

Instruction Set Architecture. Datapath & Control. Instruction. LC-3 Overview: Memory and Registers. CIT 595 Spring 2010

Verilog: Blocks

Digital Electronics Part I Combinational and Sequential Logic. Dr. I. J. Wassell

Synthesizable Finite State Machine Design Techniques Using the New SystemVerilog 3.0 Enhancements

Microprocessor & Assembly Language

Lecture 11: Sequential Circuit Design

Lecture 10: Sequential Circuits

路 論 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:

Digital Logic Design. Basics Combinational Circuits Sequential Circuits. Pu-Jen Cheng

NAME AND SURNAME. TIME: 1 hour 30 minutes 1/6

Engr354: Digital Logic Circuits

List of Experiment. 8. To study and verify the BCD to Seven Segments DECODER.(IC-7447).

APPENDIX-I. Synchronous communication creation

Lab1 : 2-1 MUX. 1. Change to Lab1 directory. It contains the mux.v and mux_text.v files. use this command : cd Lab1

DIGITAL COUNTERS. Q B Q A = 00 initially. Q B Q A = 01 after the first clock pulse.

LFSR BASED COUNTERS AVINASH AJANE, B.E. A technical report submitted to the Graduate School. in partial fulfillment of the requirements

ECE410 Design Project Spring 2008 Design and Characterization of a CMOS 8-bit Microprocessor Data Path

PROGETTO DI SISTEMI ELETTRONICI DIGITALI. Digital Systems Design. Digital Circuits Advanced Topics

Contents COUNTER. Unit III- Counters

Counters are sequential circuits which "count" through a specific state sequence.

Flip-Flops and Sequential Circuit Design. ECE 152A Winter 2012

Flip-Flops and Sequential Circuit Design

E158 Intro to CMOS VLSI Design. Alarm Clock

ASYNCHRONOUS COUNTERS

CpE358/CS381. Switching Theory and Logical Design. Class 10

BINARY CODED DECIMAL: B.C.D.

DATA SHEET. HEF40193B MSI 4-bit up/down binary counter. For a complete data sheet, please also download: INTEGRATED CIRCUITS

The 104 Duke_ACC Machine

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

Timing Methodologies (cont d) Registers. Typical timing specifications. Synchronous System Model. Short Paths. System Clock Frequency

Digital Circuit Design Using Xilinx ISE Tools

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

CHAPTER 3 Boolean Algebra and Digital Logic

DM74LS191 Synchronous 4-Bit Up/Down Counter with Mode Control

Transcription:

More Verilog 8-bit Register with Synchronous Reset module reg8 (reset, CLK, D, Q); input reset; input [7:0] D; output [7:0] Q; reg [7:0] Q; if (reset) Q = 0; else Q = D; module // reg8 Verilog - 1 Verilog - 2 N-bit Register with Asynchronous Reset Shift Register Example module regn (reset, CLK, D, Q); input reset; parameter N = 8; // Allow N to be changed input [N-1:0] D; output [N-1:0] Q; reg [N-1:0] Q; always @(posedge CLK or posedge reset) if (reset) Q = 0; else if (CLK == 1) Q = D; module // regn // 8-bit register can be cleared, loaded, shifted left // Retains value if no control signal is asserted module shiftreg (CLK, clr, shift, ld, Din, SI, Dout); input clr; // clear register input shift; // shift input ld; // load register from Din input [7:0] Din; // Data input for load input SI; // Input bit to shift in output [7:0] Dout; reg [7:0] Dout; if (clr) Dout <= 0; else if (ld) Dout <= Din; else if (shift) Dout <= { Dout[6:0], SI }; Verilog - 3 module // shiftreg Verilog - 4 Blocking and Non-Blocking Assignments Swap (continued) Q = A " # $ Q <= A ' temp = B; B = A; A = temp; Verilog - 5 A <= B; B <= A; A = B; ( posedge CLK A <= B; B = A; B <= A; Verilog - 6

Non-Blocking Assignment # $ ) $$ * $ +), +-./" // this implements 3 parallel flip-flops B = A; C = B; D = C; // this implements a shift register {D, C, B} = {C, B, A}; // this implements a shift register B <= A; C <= B; D <= C; Verilog - 7 Counter Example 0 122 // 8-bit counter with clear and count enable controls module count8 (CLK, clr, cnten, Dout); input clr; // clear counter input cnten; // enable count output [7:0] Dout; // counter value reg [7:0] Dout; if (clr) Dout <= 0; else if (cnten) Dout <= Dout + 1; module Verilog - 8 Finite State Machines Verilog FSM - Reduce 1s example Mealy outputs 4 5 46 ' inputs combinational logic next state Moore outputs current state // State assignment parameter zero = 0, one1 = 1, two1s = 2; module reduce (clk, reset, in, out); input clk, reset, in; reg out; reg [1:0] state; // state register reg [1:0] next_state; 3 3 // Implement the state register if (reset) state = zero; else state = next_state; Verilog - 9 Verilog - 10 Moore Verilog FSM (cont d) Mealy Verilog FSM for Reduce-1s example always @(in or state) case (state) // defaults next_state = zero; zero: // last input was a zero if (in) next_state = one1; one1: // we've seen one 1 if (in) next_state = two1s; two1s: // we've seen at least 2 ones out = 1; if (in) next_state = two1s; // Don t need case default because of default assignments case module module reduce (clk, reset, in, out); input clk, reset, in; reg out; reg state; // state register reg next_state; parameter zero = 0, one = 1; if (reset) state = zero; else state = next_state; always @(in or state) next_state = zero; case (state) zero: // last input was a zero if (in) next_state = one; one: // we've seen one 1 if (in) next_state = one; out = 1; case module Verilog - 11 Verilog - 12 6

Restricted FSM Implementation Style Single-always Moore Machine (Not Recommed) " )7 22 1 module reduce (clk, reset, in, out); input clk, reset, in; reg out; reg [1:0] state; // state register parameter zero = 0, one1 = 1, two1s = 2; Verilog - 13 Verilog - 14 Single-always Moore Machine (Not Recommed) Delays case (state) zero: if (in) state = one1; else state = zero; one1: if (in) state = two1s; out = 1; else state = zero; two1s: if (in) state = two1s; out = 1; else state = zero; default: state = zero; case module Verilog - 15 All outputs are registered This is confusing: the output does not change until the next clock cycle 3 1 0 8 45 45 module and_gate (out, in1, in2); input in1, in2; assign #10 out = in1 in2; module Verilog - 16 6 Verilog Propagation Delay Initial Blocks assign #5 c = a b; assign #4 {Cout, S} = Cin + A + B; ) 0 always @(A or B or Cin) #4 S = A + B + Cin; #2 Cout = (A B) (B Cin) (A Cin); assign #3 zero = (sum == 0)? 1 : 0; always @(sum) if (sum == 0) #6 zero = 1; else #3 zero = 0; Verilog - 17 Verilog - 18

Tri-State Buffers Test Fixtures 9: 6$ $; module tstate (EnA, EnB, BusA, BusB, BusOut); input EnA, EnB; input [7:0] BusA, BusB; output [7:0] BusOut; < < = 11= 12 assign BusOut = EnA? BusA : 8 bz; assign BusOut = EnB? BusB : 8 bz; module Test Fixture (Specification) Simulation Circuit Description (Synthesizeable) Verilog - 19 Verilog - 20 Verilog Clocks Verilog Clocks > + module clockgenerator (CLK); parameter period = 10; parameter howlong = 100; output CLK; reg CLK; module clock_gen (masterclk); `define PERIOD = 10; " " initial CLK = 0; #(period/2); repeat (howlong) CLK = 1; #(period-period/2); CLK = 0; #(period/2); $finish; output masterclk; reg masterclk; initial masterclk = 0; always #`PERIOD/2 masterclk = ~masterclk; " # module // clockgenerator module Verilog - 21 Verilog - 22 Example Test Fixture Simulation Driver module stimulus (a, b, c); parameter delay = 10; module full_addr1 (A, B, Cin, S, Cout); output a, b, c; input A, B, Cin; reg [2:0] cnt; output S, Cout; initial assign {Cout, S} = A + B + Cin; cnt = 0; module repeat (8) #delay cnt=cnt+1; #delay $finish; assign {c, a, b} = cnt; module module driver; // Structural Verilog connects test-fixture to full adder wire a, b, cin, sum, cout; stimulus stim (a, b, cin); full_addr1 fa1 (a, b, cin, sum, cout); initial $monitor ("@ time=0d cin=b, a=b, b=b, cout=d, sum=d", $time, cin, a, b, cout, sum); module Verilog - 23 module stimulus (a, b); parameter delay = 10; output a, b; reg [1:0] cnt; initial cnt = 0; repeat (4) #delay cnt = cnt + 1; #delay $finish; assign {a, b} = cnt; module Verilog - 24 $ # "

Test Vectors Verilog Simulation module testdata(clk, reset, data); input clk; output reset, data; reg [1:0] testvector [100:0]; reg reset, data; integer count; initial $readmemb("data.b", testvector); count = 0; { reset, data } = testvector[0]; count = count + 1; #1 { reset, data } = testvector[count]; module 32 ) 0? Verilog - 25 Verilog - 26 Intepreted vs. Compiled Simulation Simulation Level 3 "1 1 "1 = " 0 * ' " $ > $ $ 1 @ Verilog - 27 Verilog - 28 Simulation Time and Event Queues Verilog Time '" AA " " " " " 0? + 0 8 $ " B $ 1221B //5 ", "1 = C Verilog - 29 Verilog - 30

Inertial and Transport Delays A few requirements for CSE467... 3 8 DE/+F, D 1 + E E./8 D+F + E 1D $ $ + G E + ; $ 8 ) 1 ; 6) 0 Verilog - 31 Verilog - 32