EN2911X: Reconfigurable Computing Lecture 06: Verilog (3)

Similar documents
EN164: Design of Computing Systems Lecture 07: Lab Foundations / Verilog 3

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

ENGN1640: Design of Computing Systems Topic 02: Lab Foundations

Lab #1. Topics. 3. Introduction to Verilog 2/8/ Programmable logic. 2. Design Flow. 3. Verilog --- A Hardware Description Language

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

ECEN 468 Advanced Logic Design

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

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

ECE 2300 Digital Logic & Computer Organization. More Verilog Finite State Machines

ECE 2300 Digital Logic & Computer Organization. More Verilog Finite State Machines

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

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

CSE140L: Components and Design Techniques for Digital Systems Lab

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

FSM and Efficient Synthesizable FSM Design using Verilog

Sequential Logic Design

CSE140L: Components and Design

L5: Simple Sequential Circuits and Verilog

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

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

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

Digital Integrated Circuits

EEL 4783: HDL in Digital System Design

L5: Simple Sequential Circuits and Verilog

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

Synthesizable Verilog

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

EECS 270 Verilog Reference: Sequential Logic

Introduction. Why Use HDL? Simulation output. Explanation

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

Quick Introduction to SystemVerilog: Sequental Logic

Verilog Nonblocking Assignments with Delays - Myths & Mysteries

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

Lecture 15: System Modeling and Verilog

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

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto

Modeling Sequential Circuits in Verilog

L5: Simple Sequential Circuits and Verilog

ECE 2300 Digital Logic & Computer Organization. More Finite State Machines

Introduction to Verilog HDL

ECE331: Hardware Organization and Design

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill!

Verilog for Synthesis Ing. Pullini Antonio

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

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

Laboratory Exercise 3

ES611 FPGA Based System Design. Behavioral Model

Lecture #2: Verilog HDL

Department of Computer Science and Electrical Engineering. CMPE 415 Verilog Events Timing and Testbenches Prof. Ryan Robucci

Introduction to Verilog/System Verilog

Digital Design with FPGAs. By Neeraj Kulkarni

Nikhil Gupta. FPGA Challenge Takneek 2012

Announcements. Midterm 2 next Thursday, 6-7:30pm, 277 Cory Review session on Tuesday, 6-7:30pm, 277 Cory Homework 8 due next Tuesday Labs: project

Programmable Logic Devices Verilog VII CMPE 415

Introduction to Verilog

Introduction To HDL. Verilog HDL. Debdeep Mukhopadhyay Dept of CSE, IIT Madras 1

Verilog introduction. Embedded and Ambient Systems Lab

Introduction to Digital Design with Verilog HDL

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

Verilog HDL. Lecture #6. Madhu Mutyam Dept. of Computer Science and Engineering Indian Institute of Technology, Madras

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

Subject: Scheduling Region Questions and Problems of new SystemVerilog commands

Verilog Synthesis and FSMs. UCB EECS150 Fall 2010 Lab Lecture #3

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

ECE 4514 Digital Design II. Spring Lecture 13: Logic Synthesis

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

Verilog Behavioral Modeling

Verilog Execution Semantics

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb With material by Professor Moritz and Kundu UMass Amherst Fall 2016

Digital System Design Verilog-Part III. Amir Masoud Gharehbaghi

Writing Circuit Descriptions 8

Verilog Tutorial (Structure, Test)

EECS150 - Digital Design Lecture 6 - Logic Simulation

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

EN2911X: Reconfigurable Computing Lecture 01: Introduction

Verilog HDL. Gate-Level Modeling

L5: Simple Sequential Circuits and Verilog

Verilog Hardware Description Language ROOM: B405

Verilog Coding Guideline

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

Problem Set 3 Solutions

Sequential Logic. Reminder: Lab #2 due Thursday Fall 2016 Lecture 4

VLSI II E. Özgür ATES

Chapter 5: Tasks, Functions, and UDPs

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

EECS 270 Midterm Exam

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

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb UMass Amherst Fall 2017

Online Verilog Resources

Verilog for High Performance

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

Register Transfer Level in Verilog: Part I

EN2911X: Reconfigurable Computing Lecture 13: Design Flow: Physical Synthesis (5)

Modeling Synchronous Logic Circuits. Debdeep Mukhopadhyay IIT Madras

EEL 4783: HDL in Digital System Design

Transcription:

EN2911X: Lecture 06: Verilog (3) Prof. Sherief Reda Division of Engineering, Brown University Fall 09 http://scale.engin.brown.edu

Level sensitive latch (D-Latch) The Verilog implementation of a D-latch is an always block that makes a nonblocking assignment ( < = ) of d to q when the g input is nonzero. When g input is zero, then the always block does not make any assignment to q, causing the synthesis tool to infer a latch on the q output as the q output must retain its last known d value when g was nonzero Nonblocking assignments ( <= ) as opposed to blocking assignments ( = ) should be used in always blocks that are used to synthesize sequential logic; [from Thornton & Reese]

Edge-triggered storage element (D-FF) The @ symbol is used to specify an event control. Statements can be executed on changes in signal value or at a positive (posedge) or negative (negedge) transition of the signal. In general, edge-triggered storage elements are preferred to levelsensitive storage elements because of simpler timing requirements The 1-bit edge-triggered storage elements provided by FPGA vendors are DFFs because of their simplicity and speed. [Thornton & Reese]

DFF chains [Thornton & Reese] Each nonblocking assignment synthesizes to a single DFF whose input happens to be the output of another nonblocking assignment. The ordering of these nonblocking assignments within an always block does not matter

DFF with asynchronous/synchronous inputs [Thornton & Reese]

Blocking vs. non-blocking statements [Thornton & Reese] Zero-delay blocking assignments are so named because the assignment of the right-hand side (RHS) to the left- hand side (LHS) is completed without any intervening Verilog code allowed to execute, i.e., the assignment blocks the execution of the other Verilog code. For nonblocking assignments within an always block, all RHS expressions are evaluated, and are only assigned to the LHS targets after the always block completes.

Avoid combinational loops [Thornton & Reese]

Guidelines to avoid frustration Use blocking assignments ( = ) in always blocks that are meant to represent combinational logic. Use nonblocking assignments ( <= ) in always blocks that are meant to represent sequential logic. Do not mix blocking and nonblocking assignments in the same always block. If an always block contains a significant amount of combinational logic that requires intermediate wires (and thus, intermediate assignments), then place this logic in a separate always block. If an always block for combinational logic contains complicated logic pathways due to if-else branching or other logic constructs, then assign every output a default value at the beginning of the block. This ensures that all outputs are assigned a value regardless of the path taken through the logic, avoiding inferred latches on outputs. Do not make assignments to the same output from multiple always blocks [Thornton & Reese]

Loops in Verilog integer count; integer y=1; integer x=2; initial for (count = 0; count < 128; count = count + 1) begin x <= x + y; y <= x; end initial count = 0; while (count < 128) begin.. count = count +1; end initial count = 0; repeat(128) begin.. count = count +1; end Must contain a number or a signal value; only evaluated once at the beginning

D2 example: A 1 second blinking light module sec (input CLOCK_50, output reg [8:0] LEDG); integer count=0; initial LEDG[0]=1'b0; always @(posedge CLOCK_50) begin count=count+1; if(count == 50_000_000) begin count=0; if(ledg[0]) LEDG[0]=1'b0; else LEDG[0]=1'b1; end end endmodule

Tasks Tasks are declared with the keywords task and endtask. Tasks can have input, inout, and output arguments to pass values (different than in modules). Tasks can have local variables but cannot have wires. Tasks can only contain behavioral statements. Tasks do not contain always or initial statements but are called from always blocks, initial blocks, or other tasks and functions. Can operate directly on reg variables defined in the module module always begin BOP (AB_AND, AB_OR, AB_XOR, A, B); BOP (CD_AND, CD_OR, CD_XOR, C, D); end task BOP; output [15:0] ab_and, ab_or, ab_xor; input [15:0] a, b; begin ab_and = a & b; ab_or = a b; ab_xor = a ^ b; end endtask endmodule

Example: clock display on DE2 Last lecture we had a simple example of a 1 second blinking LED Let s generalize it to a clock display minutes seconds HEX3 HEX2 HEX1 HEX0

Task to display digits task digit2sev(input integer digit, output [6:0] disp); begin if (digit == 0) disp = 7'b1000000; else if (digit == 1) disp = 7'b1111001; else if (digit == 2) disp = 7'b0100100; else if (digit == 3) disp = 7'b0110000; else if (digit == 4) disp = 7'b0011001; else if (digit == 5) disp = 7'b0010010; else if (digit == 6) disp = 7'b0000011; else if (digit == 7) disp = 7'b1111000; else if (digit == 8) disp = 7'b0000000; else if (digit == 9) disp = 7'b0011000; end endtask

One way module clock(clock_50, HEX0, HEX1, HEX2, HEX3); output reg [6:0] HEX0, HEX1, HEX2, HEX3; input CLOCK_50; integer count=0; reg [3:0] d1=0, d2=0, d3=0, d4=0; always @(posedge CLOCK_50) begin count=count+1; if (count == 50_000_000) begin count=0; d1 = d1+1; if(d1 == 10) begin d1 = 0; d2 = d2+1; if(d2 == 6) begin d2 = 0; d3 = d3 + 1; if(d3 == 10) begin d3 = 0; d4 = d4 + 1; if(d4 == 6) d4 = 0; end end end digit2sev(d1, HEX0); digit2sev(d2, HEX1); digit2sev(d3, HEX2); digit2sev(d4, HEX3); end end task digit2sev; endtask endmodule

Resource utilization is 152 LEs

Second code module clock(clock_50, HEX0, HEX1, HEX2, HEX3); input CLOCK_50; output reg [6:0] HEX0, HEX1, HEX2, HEX3; integer count=0; reg [15:0] ticks=16'd0; reg [5:0] seconds=6'd0, minutes=6'd0; initial display_time(seconds, minutes); always @(posedge CLOCK_50) begin count = count+1; if (count == 50_000_000) begin count=0; ticks = ticks + 1; seconds = ticks % 60; minutes = ticks / 60; display_time (seconds, minutes); end end

task display_time(input [5:0] s, input [5:0] m); begin digit2sev(s%10, HEX0); digit2sev(s/10, HEX1); digit2sev(m%10, HEX2); digit2sev(m/10, HEX3); end HEX3 HEX2 HEX1 HEX0 endtask task digit2sev(input integer digit, output [6:0] disp); begin if (digit == 0) disp = 7'b1000000; else if (digit == 1) disp = 7'b1111001; else if (digit == 2) disp = 7'b0100100; else if(digit == 3) disp = 7'b0110000; else if(digit == 4) disp = 7'b0011001; else if(digit == 5) disp = 7'b0010010; else if(digit == 6) disp = 7'b0000011; else if(digit == 7) disp = 7'b1111000; else if(digit == 8) disp = 7'b0000000; else if(digit == 9) disp = 7'b0011000; end endtask endmodule

Resource utilization for 2nd code Circuit consumes 611 LEs (2% of the chip logic resources). You have to be careful! Changing ticks, seconds and minutes to integer increases area to become 2500 LEs (8% of the utilization)

Lab 3: BrainTuner for DE2! Time in seconds 1st number 2nd result number Two push buttons for right / wrong You are prompted with 20 random questions to A+ answer SP * The board should tell you instantly whether you are right or wrong, and at the end, the board should give you a final score and time at the end The questions should be challenging