Problem Set 3 ECE 551: Digital System Design and Synthesis Spring 2003

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

Problem Set 3 Solutions

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Verilog Coding Guideline

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 3: Verilog Bread and Butter

ECE 551: Digital System *

Digital Design using HDLs EE 4755 Midterm Examination

Digital Design with FPGAs. By Neeraj Kulkarni

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

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

Nikhil Gupta. FPGA Challenge Takneek 2012

Digital System Design Verilog-Part III. Amir Masoud Gharehbaghi

Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE. Sistemi Embedded 1 A.A Exam date: September 5 th, 2017

ECE 353 Lab 3 (Verilog Design Approach)

Problem Set 2 Solutions

Lecture 15: System Modeling and Verilog

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

Outline. EECS150 - Digital Design Lecture 5 - Verilog 2. Structural Model: 2-to1 mux. Structural Model - XOR. Verilog Basics Lots of Examples

Digital Design Using Verilog EE Final Examination

Chap 6 Introduction to HDL (d)

6.1 Combinational Circuits. George Boole ( ) Claude Shannon ( )

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

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

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

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

Synthesizable Verilog

Verilog HDL Introduction

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

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

ECEN 468 Advanced Digital System Design

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

Digital Design with SystemVerilog

Department of Computer Science and Electrical Engineering. CMPE 415 Synthesis. Prof. Ryan Robucci

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

Hardware Description Language (HDL)

ECE UMass, Amherst. Verilog tutorial

ENSC E-123: HW D3: Counter Applications; Counter in Verilog

Homework deadline extended to next friday

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

Digital Integrated Circuits

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

Introduction to Verilog/System Verilog

Design Using Verilog

Modeling Sequential Circuits in Verilog

8-1. Fig. 8-1 ASM Chart Elements 2001 Prentice Hall, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 2e, Updated.

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

ECEN 468 Advanced Digital System Design

Lecture 32: SystemVerilog

Introduction to Verilog HDL. Verilog 1

First Name: Last Name: PID: CSE 140L Exam. Prof. Tajana Simunic Rosing. Winter 2010

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

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

CSE 140L Final Exam. Prof. Tajana Simunic Rosing. Spring 2008

Verilog 1 - Fundamentals

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

Introduction to HDL Synthesis. Prof. Chien-Nan Liu TEL: ext: Synthesis overview RTL synthesis

EECS150 - Digital Design Lecture 7 - Computer Aided Design (CAD) - Part II (Logic Simulation) Finite State Machine Review

Don t expect to be able to write and debug your code during the lab session.

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

VHDL: RTL Synthesis Basics. 1 of 59

VERILOG: FLIP-FLOPS AND REGISTERS

ECEN : Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University. Homework #1 Solutions

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

// Main testbench module. module testbench;

Lab #1: Introduction to Design Methodology with FPGAs part 1 (80 pts)

EECS 151/251A: SRPING 2017 MIDTERM 1

CSE 140L Final Exam. Prof. Tajana Simunic Rosing. Spring 2008

EECS150 - Digital Design Lecture 8 - Hardware Description Languages

What is Verilog HDL? Lecture 1: Verilog HDL Introduction. Basic Design Methodology. What is VHDL? Requirements

Image Courtesy CS250 Section 2. Yunsup Lee 9/4/09

Lecture 7: Structural RTL Design. Housekeeping

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill!

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

TSEA44: Computer hardware a system on a chip

FPGA Design Challenge Techkriti Digital Logic Design using Verilog Part 2 By Neeraj Kulkarni

CPU_EU. 256x16 Memory

8-1. Fig. 8-1 ASM Chart Elements 2001 Prentice Hall, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 2e, Updated.

Chapter 4. The Processor

Lab 2 Designing with Verilog

Quick Introduction to SystemVerilog: Sequental Logic

ECEN 468 Advanced Logic Design

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

Register Transfer Level Design. Topics. Register Transfer Level Notation. Chapter 8 Steve Oldridge Dr. Sidney Fels. A Circuit is described as:

SystemVerilog HDL - a programming language

Control in Digital Systems

Processor (I) - datapath & control. Hwansoo Han

A Brief Introduction to Verilog Hardware Definition Language (HDL)

Changes in timetable (changes in GREEN)

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

Verilog for Synthesis Ing. Pullini Antonio

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

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

Computer Architecture (TT 2012)

Hardware Modeling. VHDL Architectures. Vienna University of Technology Department of Computer Engineering ECS Group

Introduction To Verilog Design. Chun-Hung Chou

A Tutorial Introduction 1

General FSM design procedure

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

Transcription:

Problem Set 3 ECE 551: Digital System Design and Synthesis Spring 2003 1. Blocking/Non-blocking Assignments (25 pts) PART A. module P1(w,p,r,x,y,q,z,a,b,c,d,e); //Lines before always not required. input a,b,c,d,e ; output w,p,r,x,y,z,q ; reg w,p,r,x,y,z,q ; always@(a,b,c,d,e) //you only need to put p, r, and q here if //these values change elsewhere and you want to reflect //that change in your always block. w = (~a & d) (b & d) (~c & d) (a & ~e) ; p = (c & e) (d & e); r = (~a & p) ; y = (a & c) (a & d) (b & c) (b & d) e ; q = a b ; z = (~q & c) (q & ~c) (q & c) ; module PART B. With the use of the non-blocking statements the previous values of the variables will be used and not the updated ones during the execution of always statement. This is for the fact that the scheduling of evaluation and the assignment of the blocking and non-blocking statements differ. In the present case, the evaluation of the statements: r = (~a & p); z = (~q & c) (q & ~c) (q & c); are affected if you change the statement from blocking to non-blocking. Here the values of p, r, and q will not be the updated values, but the previously calculated values. PART C. Design modifications required to match the part A results while using non-blocking statements. We do it by introducing the depent variables of p, r and q in the sensitivity list. module P1b(w,p,r,x,y,q,z,a,b,c,d,e); input a,b,c,d,e ; output w,p,r,x,y,z,q ; reg w,p,r,x,y,z,q ; always@(a,b,c,d,e,p,r,q)/* Note the presence of p,r, and q in the sensitivity list.*/ w <= (~a & d) (b & d) (~c & d) (a & ~e) ; p <= (c & e) (d & e); r <= (~a & p) ; y <= (a & c) (a & d) (b & c) (b & d) e ; q <= a b ; z <= (~q & c) (q & ~c) (q & c) ; module 1

As the result of the presence of p, r and q in the sensitivity list, the always statement will be executed once again after the values of p, r and q get updated by execution of the always block the first time. This will provide the correct functionality. An Alternate Solution: module P1b(w,x,y, z,a,b,c,d,e); input a,b,c,d,e ; output w,x,y,z,; reg w,p,r,x,y,z,q ; input clk ; always@(a,b,c,d,e) w <= (~a & d) (b & d) (~c & d) (a & ~e) ; p <= (c & e) (d & e); #1; r <= (~a & p) ; #1 ; y <= (a & c) (a & d) (b & c) (b & d) e ; q <= a b ; #1 ; z <= (~q & c) (q & ~c) (q & c) ; module The use of delays is an acceptable answer if the time delay for 3 time units is acceptable. However this is not a good solution, considering the fact that the functionality can be replicated without use of delays. Also delays are not synthesized, so the would not yield a good synthesis result. 2. Scheduling Semantics (20 pts) a)timestep T ---------------------------------------------- //Verilog Code reg[15:0] A, B, C, D, E, F, V, W, X,Y, Z; wire clk; always@(posedge clk) start here 1 X <= A*B; 2 Y = X + C; 3 Z <= Y*D; 4 W = Z + E; 5 V <= W*F; 2

b)timestep T ---------------------------------------------- //Verilog Code reg[15:0] A, B, C, D, E, F, V, W, X,Y, Z; wire clk; always@(posedge clk) start here 1 X <= A*B; 2 #1 Y = X + C; 3 Z <= Y*D; 4 #1 W = Z + E; 5 V <= W*F; Timestep T + 1 -------------------------------------------- Timestep T + 2 -------------------------------------------- ----------------------------------------------------------- c)timestep T ---------------------------------------------- //Verilog Code reg[15:0] A, B, C, D, E, F, V, W, X,Y, Z; wire clk; always@(posedge clk) start here 3

1 X <= A*B; 2 Y = #1 X + C; 3 Z <= Y*D; 4 W = #1 Z + E; 5 V <= W*F; Timestep T + 1 -------------------------------------------- Timestep T + 2 -------------------------------------------- ----------------------------------------------------------- d) For each of the three code segments, indicate below whether they implement the computation as specified on page 1 and explain your answer. a) NO In this case the value of x will be the previous value and not the present updated one. So the calculations will be done wrongly on previous data. b) YES In this case, due to the inter-assignment delays present, the evaluation of x and z is done before they are used in the subsequent statements. As a result you get the correct updated values for calculations, hence, the right results. c) NO The use of intra-assignment delays does not delay the evaluation of the RHS in the blocking statements. As a result, the old values for the x and z are used. Hence, the calculations are in error. e) Synthesis ignores all delays. Which of the above three cases, after synthesis, implement the correct computation? a b c Explain your answer. When the delays are removed, all the three code segments act as in part a. Thus, none of them give the correct computation. 4

3. Operators and Behavioral Verilog (25 pts) We will use hierarchy and modularize the problem. Step 1. Describe the module for a register. Step 2. Describe the module for ALU. Step 3. Describe the module for the datapath with these instantiated. Step 4. Instantiate the datapath in a testbench and test it. Step 1:. Register module register(out,in,clk,reset); input clk,reset; input [15:0] in ; output [15:0] out ; reg [15:0] out; always@(posedge clk or posedge reset) if (reset == 1'b1)//positive reset out <= 15'b0; else out <= in ; module Step 2: ALU module ALU(out,in1,in2,op); input [15:0] in1,in2 ; input [2:0] op ; output [15:0] out ; reg [15:0] out ; always@(in1,in2,op) case(op) 3'b000 : out = in2 ; 3'b001 : out = in1 + 1'b1 ; 3'b010 : out = in1 + in2 ; 3'b011 : out = in1 - in2 ; 3'b100 : out = in1 & in2 ; 3'b101 : out = in1 in2 ; 3'b110 : out = in1 ^ in2 ; 3'b111 : out = ~ in1 ; default : out = in2 ; //Could be a variety of other entries case module Step 3: Datapath module datapath(in,out,clk,reset,opcode); input [15:0] in; output [15:0] out ; input clk,reset; input [2:0] opcode; 5

wire [15:0] fromr,fromacc,fromalu ; register R(fromR,in,clk,reset); ALU A1(fromALU,fromAcc,fromR,opcode); register ACC(fromAcc,fromALU,clk,reset); assign out = fromacc ; module Step 4. Testbench module testalu ; reg [2:0] opcode; reg reset,clk; reg [15:0] in; wire [15:0] out ; datapath X1(in,out,clk,reset,opcode); initial reset = 1'b1 ; clk = 1'b0; opcode = 3'b0; in = 16'b0 ; #5 in = 16'hA5_3F ; opcode = 3'b0 ; reset = 1'b0; //Move 16'hA5_3F ; #10 in = 16'h00_FF ; opcode = 3'b110 ; // XOR 16'h00_FF; #10 in = 16'h12_34 ; opcode = 3'b010 ; //ADD 16'h12_34 ; #10 opcode = 3'b111 ; //NOT ; #10 opcode = 3'b001 ; //increment ; #10 in = 16'hE4_C6 ; opcode = 3'b100 ; //AND 16'hE4_C6 ; #10 in = 16'h7B_8D ; opcode = 3'b011 ; //SUB 16'h7B_8D ; #10 in = 16'h9A_A9 ; opcode = 3'b101 ; //OR 16'h9A_A9 ; #10 $stop ; always # 5 clk = ~clk; module The output presented as a list: ns /testalu/opcode /testalu/out /testalu/reset /testalu/clk /testalu/in 0 000 1 0 0000 0000 5 000 0 1 a53f 0000 10 000 0 0 a53f 0000 15 110 0 1 00ff a53f 20 110 0 0 00ff a53f 25 010 0 1 1234 a5c0 30 010 0 0 1234 a5c0 35 111 0 1 1234 b7f4 40 111 0 0 1234 b7f4 45 001 0 1 1234 480b 6

50 001 0 0 1234 480b 55 100 0 1 e4c6 480c 60 100 0 0 e4c6 480c 65 011 0 1 7b8d 4004 70 011 0 0 7b8d 4004 75 101 0 1 9aa9 c477 80 101 0 0 9aa9 c477 Only list above required. The answers have been checked manually to verify the outputs, and they are correct. 7