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

Size: px
Start display at page:

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

Transcription

1 ECEN : Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University Homework #1 Solutions Upload your homework solution to ecampus as a single pdf file. Your homework solution should include a listing of any C code or Verilog code, along with any output obtained when the code is run. DO NOT include pictures of your code in your homework solution file, instead, copy the text of your C or Verilog code into your homework solution file. DO NOT upload a zip file. You will have only ONE attempt to upload your homework solution. In addition, your source code (any C code or Verilog code or testbenches) should be sent via to 449and749graders@gmail.com. Your title should state your NAME, SECTION NUMBER and HOMEWORK NUMBER. Name your files in a way that identifies the homework number and the question (e.g. hw1-q1b.v). For all the code that you write, please provide comments for full credit. 1. Write a C program that reads a character string from an input file. Your program performs Run Length Encoding on the input string (as shown below). The result is written to an output file. The input filename should be IN.txt and the output filename should be OUT.txt. Both these files contain exactly one line with no spaces. For example if the input file contains ppaaaarttt then output file should contain p2a4r1t3 Test your code on the following strings: (a) qqqyyyyhiiiqyi (b) Solution. #include <stdio.h> 1

2 2 Solutions to Homework #1 int main() { char str[100]; int count=1; int i; //read string from input file to str FILE * input; input = fopen("in.txt", "r"); fscanf(input,"%s",str); fclose(input); //write the run length encoded string to output file FILE * output; output = fopen("out.txt","w"); for(i=0;str[i];i++){ if(str[i]==str[i+1]){ count++; } return 0; } } else if (str[i]!=str[i+1]){ fprintf(output,"%c%d",str[i],count); count=1; } fclose(output);

3 3 Solutions to Homework #1 2. Consider an input clock signal CLK which operates at 20 MHz. Also consider a signal IN which is 4 bits wide, changing at every positive edge of CLK. Write Verilog code whose output is the signal OUT and the signal CLK OUT shown below. Your code effectively samples IN at the falling edge of CLK, and drives out every alternate value to the OUT signal. Write a testbench to simulate your code. Test your code for 16 clock cycles of the CLK signal, with the input IN = 0000 for the first clock cycle, 0001 for the second cycle, and so on. CLK IN CLK_OUT OUT XXXX Waveform for Question 2 Solution. //Verilog code module downsampler(clk_out, OUT, IN, reset, CLK); input CLK; input reset; input [3:0] IN; output CLK_OUT; output [3:0] OUT; reg[3:0] buff, OUT; reg CLK_OUT; //top entity //latch input data and generate CLK_OUT

4 4 Solutions to Homework #1 (posedge CLK) begin buff <= IN; CLK_OUT <=!CLK_OUT; //assign OUT at negative edge of CLK and CLK_OUT == 1b1 (negedge reset) begin if(!reset) CLK_OUT <= 1 b0; always@ (negedge CLK) begin if(clk_out == 1 b1) begin OUT <= buff; module //Testbench module downsampler_test(); wire CLK_OUT; wire[3:0] OUT; reg CLK; reg[3:0] IN; reg reset; //port mapping downsampler dut(.clk(clk),.reset(reset),.in(in),.clk_out(clk_out),.out(out)); //generate input clock of 20 MHz CLK=0; forever begin CLK = #25 CLK; $monitor("in = %d OUT = %d", IN, OUT); //inital the IN signal reset = 1 b0; IN = 4 b1111;

5 5 Solutions to Homework #1 CLK ) begin IN = IN + 4 b0001; module //simulate the input signal 3. Design an 8-function ALU that accepts 4-bit inputs a and b, a 3-bit input signal select, and produces a 5-bit output out. The ALU implements the following functions based on 3-bit input signal select select signal function b000 out = (a b) (bitwise OR operation) 3 b001 out = a+b 3 b010 out = a-b 3 b011 out = a/b 3 b100 out = a%b (remainder) 3 b101 out = a << 1 3 b110 out = (a b) (magnitude comparison) 3 b111 out = (a & b) (bitwise AND operation) You must simulate all these eight functions using a testbench. For each of these functions, test the design for 9 values in all (a = 3, 2, 1 and b = 1, 2, 3.) Solution. //Verilog code module ALU(out, A, B, select); input [3:0] A; input [3:0] B; output [4:0] out; input [2:0] select; //SELECT signal reg [4:0] out; // Arithmetic operations based on SELECT signal always@(a or B or select) begin case(select) 3 b000:

6 6 Solutions to Homework #1 out = (A B) ; 3 b001: out = A+B; 3 b010: out = A-B; 3 b011: out = A/B; 3 b100: out = A%B; 3 b101: out = A<<1; 3 b110: out = (A>=B); 3 b111: out = (A & B); default: out = 5 b11111; case module //Testbench module ALU_TEST; wire [4:0] out; reg [3:0] a; reg [3:0] b; reg [2:0] select; reg clk; ALU ALU_test(out,a,b,select); //port mapping clk = 1 b0; forever begin clk = #50 clk; a <= 4 b0000; b <= 4 b0000;

7 7 Solutions to Homework #1 select <= 3 b000; always@(posedge clk) begin //a varies from 1 to 3 a <= (a == 4 b0011)? 4 b0001 : (a + 4 b0001); //b varies from 1 to 3 but changes only when a is 3 b <= (a == 4 b0011)? ((b == 4 b0011)? 4 b0001 : (b + 4 b0001)) : b; // selecte varies from 0 to 7 but changes only when a is 3 and b is 3 select <= (b == 4 b0011 && a == 4 b0011)? (select + 3 b001) : select; module 4. Consider a 12 bit serial data string DAT, which arrives at 10 Mbps. Write Verilog code to count the maximum number of occurrences of 101 in DAT. Simulate the Verilog code using a testbench, using the following values of DAT: (a) (b) (c) Solution. //Verilog code timescale 1ns / 1ps module patterncounter( //top entity input clk, input IN, input reset, output[3:0] count, output[1:0] st ); reg[3:0] count; reg[1:0] nextstate; reg[1:0] state; reg[1:0] st; //to observe state transitions

8 8 Solutions to Homework #1 reg tick; //initialize states localparam a = 2 b00; localparam b = 2 b01; localparam c = 2 b10; always@ ( posedge clk or posedge reset) begin if(reset) begin state <= a; count <= 4 b0000; else if(clk) begin state <= nextstate; always@( IN or state ) begin //state machine st <= state; tick <= 1 b0; case(state) a: begin if(in) nextstate = b; else nextstate = a; b: begin if( IN) nextstate = c; else nextstate = b; c: begin if(in) begin nextstate = b; tick = 1 b1; else nextstate = a; default: begin state = a; case

9 9 Solutions to Homework #1 //count the number of occurrences of the pattern "000" in the input sequence tick) begin count = count+ 4 b0001; module //Testbench timescale 1ns / 1ps module patterncounter_test(); wire[3:0] count; wire[1:0] st; reg clk,in,reset; patterncounter DUT(.clk(clk),.IN(IN),.reset(reset),.count(count),.st(st)); clk = 1 b0; forever begin clk = #50 clk; reset = 1 b1; #50 reset = 1 b0; $monitor($time,"count = %d, State= %d",count,st); IN <= 1 b0; #100 IN <= 1 b1; #100 IN <= 1 b0; #100 IN <= 1 b1; #100 IN <= 1 b0;

10 10 Solutions to Homework #1 #100 IN <= 1 b1; #100 IN <= 1 b0; #100 IN <= 1 b0; #100 IN <= 1 b1; #100 IN <= 1 b1; #100 IN <= 1 b0; #100 IN <= 1 b1; module 5. Write Verilog code to implement a Finite State Machine (FSM) represented by the State Transition Table given below. In the State Transition Table, clk is the clock variable, indicates rising edge of the clk, a is an input, PS is the Present State, NS is the Next State and z is the output variable. clk PS a NS z S 1 0 S 3 0 S 1 1 S 2 1 S 2 0 S 3 1 S 2 1 S 4 0 S 3 0 S 4 0 S 3 1 S 1 1 S 4 0 S 4 1 S 4 1 S 1 1 Simulate the Verilog code using a testbench. In your testbench, consider you start at state S 1 and a is driven by the successive values of the 8 bit long string, , which arrives at 1 Mbps. The leftmost bit of the string is fed to the FSM first. Solution. Each edge in Fig 1 is labeled in the form a/z, where a is an input and z is the output as given in the question.

11 11 Solutions to Homework #1 1/1 S 2 0/0 S 1 1/0 0/1 S 3 1/1 0/0 1/1 S 4 0/1 Fig 1 : State Diagram representation of the State Transistion Table //Verilog Code module fsm( input clk, input a, output z, output[1:0] PS, input reset ); reg[1:0] PS; reg[1:0] NS; reg z; reg dz; // present state // next state // output //initialize states localparam S1 = 2 b00; localparam S2 = 2 b01;

12 12 Solutions to Homework #1 localparam S3 = 2 b10; localparam S4 = 2 b11; always@( posedge clk ) begin if(reset) begin PS <= S1; z <= 0; else begin PS <= NS; // updating present state z <= dz; // updating the output always@(a or PS) begin //state machine case(ps) S1: begin if(a) begin NS = S2; dz = 1; else begin NS = S3; dz = 0; S2: begin if(a) begin NS = S4; dz = 0; else begin NS = S3; dz = 1; S3: begin if(a) begin NS = S1; dz = 1; else begin NS = S4; dz = 0; S4: begin if(a) begin NS = S1; dz = 1; else begin NS = S4; dz = 1; default: begin NS = S1; dz = 0; case module

13 13 Solutions to Homework #1 //Testbench module fsm_tb(); wire z; wire[1:0] PS; reg clk, a, reset; fsm DUT(.clk(clk),.a(a),.reset(reset),.z(z),.PS(PS)); //clock signal clk = 1 b0; forever begin clk = #500 clk; //reset reset = 1 b1; #1000 reset = 1 b0; // input stream to a $monitor($time,"z = %d, PS = %d ",z, PS); #1000 a <= 1 b1; #1000 a <= 1 b1; #1000 a <= 1 b0; #1000 a <= 1 b0; #1000 a <= 1 b1; #1000 a <= 1 b0; #1000 a <= 1 b1; #1000 a <= 1 b1;

14 14 Solutions to Homework #1 module 6. [GRADUATE QUESTION] Consider a logic circuit with N gates with no structural feedback. I perform event driven timing simulation on it up to K seconds. The delays of all gates are unity, and the circuit inputs change exactly once at time 0 seconds. What is the maximum number of events that are generated in the timing simulation? Solution. Consider a two-level logic circuit with N gates as shown in Fig 2. Let there be N-1 gates in the first level, the output of which are connected to the gate in the second level. If I perform an event driven timing simulation on it up to K seconds (assuming K>0), then, the number of events generated in the timing simulation is O(N) since there are N gates in the two-level logic circuit. IN_1 1 IN_ n OUT IN_N 1 n 1 Fig 2: A two-level logic circuit

15 15 Solutions to Homework #1 Now consider a circuit given in Fig 3. The number inside a gate is its label. IN_1 IN_2 1 E1 IN_3 2 E1, E2 IN_4 3 E1, E2, E3 (Upto IN_N+1) Fig 3: Circuit for explaining events generated (Upto Nth gate) Let us assume N =3, (K>N) and then calculate the total number of events. (a) At time 0, the inputs of the circuit change. This change generates events at the outputs of all 3 gates which would be processed after delays of the respective gates. (b) Since the delay of each gate is 1, an event will be generated at the ouput of all 3 gates which will be processed at 1. Lets call this event E1. Similary an event generated that would be processed at time 2 would be E2 and so on. (c) At time 1, the E1s at the ouputs of all 3 gates will be processed in no specific order. After processing of E1 at the output of gate 1, it will generate another event to be processed at time 2 at the ouput of gate 2 which is E2. Similarly, processing of E1 at the output of gate 2 will generate E2 at the ouput of gate 3. And processing E1 at the output of gate 3 will not generate any events since it is not connected to the input of any other gates. (d) At time 2, the E2s will be processed. After processing event E2 at the output of gate 2, it will generate an event E3 at the output of gate 3. (e) So when K>N, 3 events (E1) were generated at time 0, 2 events (E2) were generated at time 1, 1 event (E3) was generated at time 2. Total Number of events is 6. (f) Generalising, for K>N, the total number of events generated would be N (N + 1)/2. Similarly, for circuit Fig 3, if K<N, N events (E1) will be generated at time 0, N-1 events (E2) at time 1, and so on. Finally, at time K, N-K events would be generated. So, the total number of events would be (N K) (N K + 1)/2. Concluding, T otal Number of events = max(o(n), N (N + 1)/2, (N K) (N K + 1)/2)

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

ECEN : Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University. Homework #2 Solutions ECEN 449 749: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University Homework #2 Solutions Upload your homework solution to ecampus as a single file. Your homework

More information

Problem Set 2 Solutions

Problem Set 2 Solutions Problem Set 2 Solutions ECE 551: Digital System Design and Synthesis Fall 2001 1. A tabular description and a known good behavioral specification is given for a priority encoder. x indicates don t care

More information

Lab 7 (All Sections) Prelab: Introduction to Verilog

Lab 7 (All Sections) Prelab: Introduction to Verilog Lab 7 (All Sections) Prelab: Introduction to Verilog Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work 1 Objective The

More information

Problem Set 3 Solutions

Problem Set 3 Solutions Problem Set 3 Solutions ECE 551: Digital System Design and Synthesis Fall 2001 Final Version 1) For each of the following always behaviors: a) Does the given always behavior need a default statement as

More information

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

In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and shift registers, which is most useful in conversion between

More information

Chap 6 Introduction to HDL (d)

Chap 6 Introduction to HDL (d) Design with Verilog Chap 6 Introduction to HDL (d) Credit to: MD Rizal Othman Faculty of Electrical & Electronics Engineering Universiti Malaysia Pahang Ext: 6036 VERILOG HDL Basic Unit A module Module

More information

Introduction To Verilog Design. Chun-Hung Chou

Introduction To Verilog Design. Chun-Hung Chou Introduction To Verilog Design Chun-Hung Chou 1 Outline Typical Design Flow Design Method Lexical Convention Data Type Data Assignment Event Control Conditional Description Register Description Synthesizable

More information

Verilog Coding Guideline

Verilog Coding Guideline Verilog Coding Guideline Digital Circuit Lab TA: Po-Chen Wu Outline Introduction to Verilog HDL Verilog Syntax Combinational and Sequential Logics Module Hierarchy Write Your Design Finite State Machine

More information

Lab 7 (All Sections) Prelab: Verilog Review and ALU Datapath and Control

Lab 7 (All Sections) Prelab: Verilog Review and ALU Datapath and Control Lab 7 (All Sections) Prelab: Verilog Review and ALU Datapath and Control Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic

More information

ECE 551: Digital System *

ECE 551: Digital System * ECE 551: Digital System * Design & Synthesis Lecture Set 5 5.1: Verilog Behavioral Model for Finite State Machines (FSMs) 5.2: Verilog Simulation I/O and 2001 Standard (In Separate File) 3/4/2003 1 Explicit

More information

Lab 7 (Sections 300, 301 and 302) Prelab: Introduction to Verilog

Lab 7 (Sections 300, 301 and 302) Prelab: Introduction to Verilog Lab 7 (Sections 300, 301 and 302) Prelab: Introduction to Verilog Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work

More information

One and a half hours. Section A is COMPULSORY

One and a half hours. Section A is COMPULSORY One and a half hours Section A is COMPULSORY An additional answersheet is provided for Question 4. Please remember to complete the additional answersheet with your University ID number and attach it to

More information

Digital design laboratory 5

Digital design laboratory 5 Digital design laboratory 5 Preparations Launch the ISE Design Suite Create new project: File -> New Project Preparations Name: DigLab5 Location: D drive! D:\DigLab5 Working directory: The same as Location

More information

Hardware Description Language (HDL)

Hardware Description Language (HDL) Hardware Description Language (HDL) What is the need for Hardware Description Language? Model, Represent, And Simulate Digital Hardware Hardware Concurrency Parallel Activity Flow Semantics for Signal

More information

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

ECE 2300 Digital Logic & Computer Organization. More Verilog Finite State Machines ECE 2300 Digital Logic & Computer Organization Spring 2017 More Verilog Finite State Machines Lecture 8: 1 Announcements 1 st batch of (raw) quiz scores released on CMS Solutions to HW 1-3 released on

More information

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

CSE 591: Advanced Hardware Design and Verification (2012 Spring) LAB #0 Lab 0: Tutorial on Xilinx Project Navigator & ALDEC s Active-HDL Simulator CSE 591: Advanced Hardware Design and Verification Assigned: 01/05/2011 Due: 01/19/2011 Table of Contents 1 Overview... 2 1.1

More information

Quick Introduction to SystemVerilog: Sequental Logic

Quick Introduction to SystemVerilog: Sequental Logic ! Quick Introduction to SystemVerilog: Sequental Logic Lecture L3 8-545 Advanced Digital Design ECE Department Many elements Don Thomas, 24, used with permission with credit to G. Larson Today Quick synopsis

More information

Memory Controller. System Integration Issues. Encoding numbers 1GB RAM FSM. Communicating FSMs Clocking, theory and practice. Combinational Logic

Memory Controller. System Integration Issues. Encoding numbers 1GB RAM FSM. Communicating FSMs Clocking, theory and practice. Combinational Logic Memory Controller System Integration Issues Communicating FSMs Clocking, theory and practice Encoding numbers 0 1 0 4 2 3 1 2 1GB RAM FSM Clock D Current Combinational Logic Next Input Output always @(posedge

More information

Modeling of Finite State Machines. Debdeep Mukhopadhyay

Modeling of Finite State Machines. Debdeep Mukhopadhyay Modeling of Finite State Machines Debdeep Mukhopadhyay Definition 5 Tuple: (Q,Σ,δ,q 0,F) Q: Finite set of states Σ: Finite set of alphabets δ: Transition function QχΣ Q q 0 is the start state F is a set

More information

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007 EE178 Lecture Verilog FSM Examples Eric Crabill SJSU / Xilinx Fall 2007 In Real-time Object-oriented Modeling, Bran Selic and Garth Gullekson view a state machine as: A set of input events A set of output

More information

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

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes) Last (family) name: Answer Key First (given) name: Student I.D. #: Department of Electrical and Computer Engineering University of Wisconsin - Madison ECE 551 Digital System Design and Synthesis Midterm

More information

DIGITAL SYSTEM DESIGN

DIGITAL SYSTEM DESIGN DIGITAL SYSTEM DESIGN Prepared By: Engr. Yousaf Hameed Lab Engineer BASIC ELECTRICAL & DIGITAL SYSTEMS LAB DEPARTMENT OF ELECTRICAL ENGINEERING Digital System Design 1 Name: Registration No: Roll No: Semester:

More information

A short introduction to SystemVerilog. For those who know VHDL We aim for synthesis

A short introduction to SystemVerilog. For those who know VHDL We aim for synthesis A short introduction to SystemVerilog For those who know VHDL We aim for synthesis 1 Verilog & SystemVerilog 1984 Verilog invented, C-like syntax First standard Verilog 95 Extra features Verilog 2001 A

More information

Design of Sequential Logic: Flip flops, counter, state machine, stacks

Design of Sequential Logic: Flip flops, counter, state machine, stacks Design of Sequential Logic: Flip flops, counter, state machine, stacks 1 Today s goal Learn how to use always and if statements to design flip flops. Learn how to design sequential logic such as counters,

More information

ECE UMass, Amherst. Verilog tutorial

ECE UMass, Amherst. Verilog tutorial ECE 232 - UMass, Amherst Verilog tutorial 1. In this tutorial, we are going to design and implement a 2-bit comparator in Verilog and simulate it using the service provided on www.edaplayground.com. In

More information

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE 6.111 Introductory Digital Systems Laboratory Fall 2017 Lecture PSet #6 of

More information

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

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

More information

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

ENSC E-123: HW D3: Counter Applications; Counter in Verilog HW D3; Counter Applications 1 ENSC E-123: HW D3: Counter Applications; Counter in Verilog REV 0 1 ; February 12, 2015 Contents 1 Counter Applications: Sync vs Async Function (5 points) 2 1.1 Crummy: asyncclear(2points).................

More information

LSN 1 Digital Design Flow for PLDs

LSN 1 Digital Design Flow for PLDs LSN 1 Digital Design Flow for PLDs ECT357 Microprocessors I Department of Engineering Technology LSN 1 Programmable Logic Devices Functionless devices in base form Require programming to operate The logic

More information

Introduction. Why Use HDL? Simulation output. Explanation

Introduction. Why Use HDL? Simulation output. Explanation Introduction Verilog HDL is a Hardware Description Language (HDL) HDL is a language used to describe a digital system, for example, a computer or a component of a computer. Most popular HDLs are VHDL and

More information

Modeling Sequential Circuits in Verilog

Modeling Sequential Circuits in Verilog Modeling Sequential Circuits in Verilog COE 202 Digital Logic Design Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals Presentation Outline Modeling Latches and Flip-Flops Blocking versus

More information

TSEA44: Computer hardware a system on a chip

TSEA44: Computer hardware a system on a chip TSEA44: Computer hardware a system on a chip Lecture 2: A short introduction to SystemVerilog (System)Verilog 2016-11-02 2 Assume background knowledge of VHDL and logic design Focus on coding for synthesis

More information

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University Digital Circuit Design and Language Datapath Design Chang, Ik Joon Kyunghee University Typical Synchronous Design + Control Section : Finite State Machine + Data Section: Adder, Multiplier, Shift Register

More information

PROJECT REPORT - UART

PROJECT REPORT - UART Tanvi Shama 200601196 Akshay Soni 200601148 DAIICT PROJECT REPORT - UART Digital System Architecture 2 Project Report - UART S.No Topic Page No. 1. PROJECT STATEMENT 3 2. FUNCTIONAL SPECIFICATIONS INTRODUCTION

More information

Digital Integrated Circuits

Digital Integrated Circuits Digital Integrated Circuits Lecture 4 Jaeyong Chung System-on-Chips (SoC) Laboratory Incheon National University BCD TO EXCESS-3 CODE CONVERTER 0100 0101 +0011 +0011 0111 1000 LSB received first Chung

More information

Intro to HW Design & Externs for P4àNetFPGA. CS344 Lecture 5

Intro to HW Design & Externs for P4àNetFPGA. CS344 Lecture 5 Intro to HW Design & Externs for P4àNetFPGA CS344 Lecture 5 Announcements Updated deliverable description for next Tuesday Implement most of the required functionality Make sure baseline tests are passing

More information

A short introduction to SystemVerilog. For those who know VHDL We aim for synthesis

A short introduction to SystemVerilog. For those who know VHDL We aim for synthesis A short introduction to SystemVerilog For those who know VHDL We aim for synthesis 1 Verilog & SystemVerilog 1984 Verilog invented, C-like syntax First standard Verilog 95 Extra features Verilog 2001 A

More information

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited April 2, 2009 John Wawrzynek Spring 2009 EECS150 - Lec20-fsm Page 1 Finite State Machines (FSMs) FSM circuits are a type of sequential

More information

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

EE 231 Fall EE 231 Homework 8 Due October 20, 2010 EE 231 Homework 8 Due October 20, 20 1. Consider the circuit below. It has three inputs (x and clock), and one output (z). At reset, the circuit starts with the outputs of all flip-flops at 0. x z J Q

More information

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

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 I hope you have completed Part 1 of the Experiment. This lecture leads you to Part 2 of the experiment and hopefully helps you with your progress to Part 2. It covers a number of topics: 1. How do we specify

More information

Computer Architecture (TT 2012)

Computer Architecture (TT 2012) Computer Architecture (TT 2012) The Register Transfer Level Daniel Kroening Oxford University, Computer Science Department Version 1.0, 2011 Outline Reminders Gates Implementations of Gates Latches, Flip-flops

More information

L11: Major/Minor FSMs

L11: Major/Minor FSMs L11: Major/Minor FSMs Acknowledgements: Materials in this lecture are courtesy of the following sources and are used with permission. Rex Min 1 Quiz Quiz will be Closed Book Tuesday, March 21, 2006, 7:30pm-9:30pm

More information

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

CSCB58 - Lab 3. Prelab /3 Part I (in-lab) /2 Part II (in-lab) /2 TOTAL /8 CSCB58 - Lab 3 Latches, Flip-flops, and Registers Learning Objectives The purpose of this exercise is to investigate the fundamental synchronous logic elements: latches, flip-flops, and registers. Prelab

More information

Lecture 15: System Modeling and Verilog

Lecture 15: System Modeling and Verilog Lecture 15: System Modeling and Verilog Slides courtesy of Deming Chen Intro. VLSI System Design Outline Outline Modeling Digital Systems Introduction to Verilog HDL Use of Verilog HDL in Synthesis Reading

More information

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

Lecture 3. Behavioral Modeling Sequential Circuits. Registers Counters Finite State Machines Lecture 3 Behavioral Modeling Sequential Circuits Registers Counters Finite State Machines Behavioral Modeling Behavioral Modeling Behavioral descriptions use the keyword always, followed by optional event

More information

Mealy and Moore examples

Mealy and Moore examples CSE 37 Spring 26 Introduction to igital esign ecture 2: uential ogic Technologies ast ecture Moore and Mealy Machines Today uential logic technologies Ving machine: Moore to synch. Mealy OPEN = creates

More information

ECE 353 Lab 3 (Verilog Design Approach)

ECE 353 Lab 3 (Verilog Design Approach) ECE 353 Lab 3 (Verilog Design Approach) Prof Daniel Holcomb Recall What You Will Do Design and implement a serial MIDI receiver Hardware in an Altera Complex Programmable Logic Device (CPLD) MAX 7000S

More information

RTL Design (Using ASM/SM Chart)

RTL Design (Using ASM/SM Chart) Digital Circuit Design and Language RTL Design (Using ASM/SM Chart) Chang, Ik Joon Kyunghee University Process of Logic Simulation and Synthesis Design Entry HDL Description Logic Simulation Functional

More information

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

ECE 2300 Digital Logic & Computer Organization. More Verilog Finite State Machines ECE 2300 Digital Logic & Computer Organization Spring 2018 More Verilog Finite Machines Lecture 8: 1 Prelim 1, Thursday 3/1, 1:25pm, 75 mins Arrive early by 1:20pm Review sessions Announcements Monday

More information

Lecture 32: SystemVerilog

Lecture 32: SystemVerilog Lecture 32: SystemVerilog Outline SystemVerilog module adder(input logic [31:0] a, input logic [31:0] b, output logic [31:0] y); assign y = a + b; Note that the inputs and outputs are 32-bit busses. 17:

More information

In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design

In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design 1 In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design a fininte state machine in order to produce the desired

More information

In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design

In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design In the previous lecture, we examined how to analyse a FSM using state table, state diagram and waveforms. In this lecture we will learn how to design a fininte state machine in order to produce the desired

More information

C A R L E T O N U N I V E R S I T Y. FINAL EXAMINATION April Duration: 3 Hours No. of Students: 108

C A R L E T O N U N I V E R S I T Y. FINAL EXAMINATION April Duration: 3 Hours No. of Students: 108 C A R L E T O N U N I V E R S I T Y FINAL EXAMINATION April 2011 Duration: 3 Hours No. of Students: 108 Department Name & Course Number: ELEC 3500 Digital Electronics Course Instructor(s): Ralph Mason

More information

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

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1 FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1 Anurag Dwivedi Digital Design : Bottom Up Approach Basic Block - Gates Digital Design : Bottom Up Approach Gates -> Flip Flops Digital

More information

Synthesizable Verilog

Synthesizable Verilog Synthesizable Verilog Courtesy of Dr. Edwards@Columbia, and Dr. Franzon@NCSU http://csce.uark.edu +1 (479) 575-6043 yrpeng@uark.edu Design Methodology Structure and Function (Behavior) of a Design HDL

More information

EECS 151/251A: SRPING 2017 MIDTERM 1

EECS 151/251A: SRPING 2017 MIDTERM 1 University of California College of Engineering Department of Electrical Engineering and Computer Sciences E. Alon Thursday, Mar 2 nd, 2017 7:00-8:30pm EECS 151/251A: SRPING 2017 MIDTERM 1 NAME Last First

More information

Intro to Digital Logic, Lab 5 Sequential Logic. Lab Objectives. Assigned Task Mapping sequential logic to the FPGA

Intro to Digital Logic, Lab 5 Sequential Logic. Lab Objectives. Assigned Task Mapping sequential logic to the FPGA Intro to Digital Logic, Lab 5 Sequential Logic Lab Objectives Now that we have mastered combinational logic, it is time to figure out sequential circuits. In this lab you will download a premade design

More information

Using ModelSim to Simulate Logic Circuits for Altera FPGA Devices

Using ModelSim to Simulate Logic Circuits for Altera FPGA Devices Using ModelSim to Simulate Logic Circuits for Altera FPGA Devices This tutorial is a basic introduction to ModelSim, a Mentor Graphics simulation tool for logic circuits. We show how to perform functional

More information

A Brief Introduction to Verilog Hardware Definition Language (HDL)

A Brief Introduction to Verilog Hardware Definition Language (HDL) www.realdigital.org A Brief Introduction to Verilog Hardware Definition Language (HDL) Forward Verilog is a Hardware Description language (HDL) that is used to define the structure and/or behavior of digital

More information

Digital Design with SystemVerilog

Digital Design with SystemVerilog Digital Design with SystemVerilog Prof. Stephen A. Edwards Columbia University Spring 25 Synchronous Digital Design Combinational Logic Sequential Logic Summary of Modeling Styles Testbenches Why HDLs?

More information

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

EECS150 - Digital Design Lecture 7 - Computer Aided Design (CAD) - Part II (Logic Simulation) Finite State Machine Review EECS150 - Digital Design Lecture 7 - Computer Aided Design (CAD) - Part II (Logic Simulation) Feb 9, 2010 John Wawrzynek Spring 2010 EECS150 - Lec7-CAD2 Page 1 Finite State Machine Review State Transition

More information

1. Prove that if you have tri-state buffers and inverters, you can build any combinational logic circuit. [4]

1. Prove that if you have tri-state buffers and inverters, you can build any combinational logic circuit. [4] HW 3 Answer Key 1. Prove that if you have tri-state buffers and inverters, you can build any combinational logic circuit. [4] You can build a NAND gate from tri-state buffers and inverters and thus you

More information

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

N-input EX-NOR gate. N-output inverter. N-input NOR gate Hardware Description Language HDL Introduction HDL is a hardware description language used to design and document electronic systems. HDL allows designers to design at various levels of abstraction. It

More information

Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm. Lecture 3

Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm. Lecture 3 Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm Lecture 3 Lecture 3 Topics Covered: Chapter 4 Discuss Sequential logic Verilog Coding Introduce Sequential coding Further review of Combinational Verilog

More information

Designing Safe Verilog State Machines with Synplify

Designing Safe Verilog State Machines with Synplify Designing Safe Verilog State Machines with Synplify Introduction One of the strengths of Synplify is the Finite State Machine compiler. This is a powerful feature that not only has the ability to automatically

More information

CHAPTER Pearson Education, Inc. S_n. R_n. Q_n. 0 ps 20 ns 40 ns 60 ns 80 ns. C S R Q Q_n. 0 ps 50 ns 100 ns 150 ns 200 ns

CHAPTER Pearson Education, Inc. S_n. R_n. Q_n. 0 ps 20 ns 40 ns 60 ns 80 ns. C S R Q Q_n. 0 ps 50 ns 100 ns 150 ns 200 ns HAPTER 5 28 Pearson Education, Inc. 5-. S_n R_n Q Q_n 5-2. S R Q Q_n ps 2 ns 4 ns 6 ns 8 ns ps 5 ns ns 5 ns 2 ns 5-3. Q Q_n ps 5 ns ns 5 ns 5-4. 63 5-5. Unknown 5-6. A Y A B Z B Present state Inputs Next

More information

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

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified. 1 In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified. I will also introduce the idea of a testbench as part of a design specification.

More information

Outline. EECS Components and Design Techniques for Digital Systems. Lec 11 Putting it all together Where are we now?

Outline. EECS Components and Design Techniques for Digital Systems. Lec 11 Putting it all together Where are we now? Outline EECS 5 - Components and Design Techniques for Digital Systems Lec Putting it all together -5-4 David Culler Electrical Engineering and Computer Sciences University of California Berkeley Top-to-bottom

More information

Digital Integrated Circuits

Digital Integrated Circuits Digital Integrated Circuits Lecture 5 Jaeyong Chung System-on-Chips (SoC) Laboratory Incheon National University MULTIPLE initial/always In C (single-threaded), a single statement is being executed at

More information

HOW TO SYNTHESIZE VERILOG CODE USING RTL COMPILER

HOW TO SYNTHESIZE VERILOG CODE USING RTL COMPILER HOW TO SYNTHESIZE VERILOG CODE USING RTL COMPILER This tutorial explains how to synthesize a verilog code using RTL Compiler. In order to do so, let s consider the verilog codes below. CNT_16 Module: 16

More information

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

Graduate Institute of Electronics Engineering, NTU. Lecturer: Chihhao Chao Date: Design of Datapath Controllers and Sequential Logic Lecturer: Date: 2009.03.18 ACCESS IC LAB Sequential Circuit Model & Timing Parameters ACCESS IC LAB Combinational Logic Review Combinational logic circuits

More information

EECS150 - Digital Design Lecture 6 - Logic Simulation

EECS150 - Digital Design Lecture 6 - Logic Simulation EECS150 - Digital Design Lecture 6 - Logic Simulation Sep. 17, 013 Prof. Ronald Fearing Electrical Engineering and Computer Sciences University of California, Berkeley (slides courtesy of Prof. John Wawrzynek)

More information

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

ECE 2300 Digital Logic & Computer Organization. More Finite State Machines ECE 2300 Digital Logic & Computer Organization Spring 2018 More Finite State Machines Lecture 9: 1 Announcements Prelab 3(B) due tomorrow Lab 4 to be released tonight You re not required to change partner(s)

More information

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis Jan 31, 2012 John Wawrzynek Spring 2012 EECS150 - Lec05-verilog_synth Page 1 Outline Quick review of essentials of state elements Finite State

More information

Finite-State Machine (FSM) Design

Finite-State Machine (FSM) Design 1 Finite-State Machine (FSM) Design FSMs, an important category of sequential circuits, are used frequently in designing digital systems. From the daily used electronic machines to the complex digital

More information

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

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory Problem Set Issued: March 2, 2007 Problem Set Due: March 14, 2007 Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.111 Introductory Digital Systems Laboratory

More information

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences Introductory Digital Systems Lab (6.111) uiz - Spring 2004 Prof. Anantha Chandrakasan Student Name: Problem

More information

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

CSE 140L Final Exam. Prof. Tajana Simunic Rosing. Spring 2008 CSE 140L Final Exam Prof. Tajana Simunic Rosing Spring 2008 Do not start the exam until you are told to. Turn off any cell phones or pagers. Write your name and PID at the top of every page. Do not separate

More information

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

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog ECE 2300 Digital Logic & Computer Organization Spring 2018 More Sequential Logic Verilog Lecture 7: 1 Announcements HW3 will be posted tonight Prelim 1 Thursday March 1, in class Coverage: Lectures 1~7

More information

Verilog introduction. Embedded and Ambient Systems Lab

Verilog introduction. Embedded and Ambient Systems Lab Verilog introduction Embedded and Ambient Systems Lab Purpose of HDL languages Modeling hardware behavior Large part of these languages can only be used for simulation, not for hardware generation (synthesis)

More information

EECS 270 Verilog Reference: Sequential Logic

EECS 270 Verilog Reference: Sequential Logic 1 Introduction EECS 270 Verilog Reference: Sequential Logic In the first few EECS 270 labs, your designs were based solely on combinational logic, which is logic that deps only on its current inputs. However,

More information

Verilog HDL. Gate-Level Modeling

Verilog HDL. Gate-Level Modeling Verilog HDL Verilog is a concurrent programming language unlike C, which is sequential in nature. block - executes once at time 0. If there is more then one block, each execute concurrently always block

More information

Introduction to Verilog and ModelSim. (Part 6 State Machines)

Introduction to Verilog and ModelSim. (Part 6 State Machines) Introduction to Verilog and ModelSim (Part 6 State Machines) State Machine Actually, a Finite State Machine (FSM) mathematical model of computation abstract machine with finite states can only be in ONE

More information

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

Student Name: Student ID: CSE 591: Advanced Hardware Design Professor: Kyle Gilsdorf SE 59: dvanced Hardware Design Professor: Kyle Gilsdorf (Kyle.Gilsdorf@asu.edu) What: Mid-Term Exam (For Spring 22) Details: Please answer the following questions to the best of your ability. If you need

More information

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

Spring 2017 EE 3613: Computer Organization Chapter 5: Processor: Datapath & Control - 2 Verilog Tutorial Spring 2017 EE 3613: Computer Organization Chapter 5: Processor: Datapath & Control - 2 Verilog Tutorial Avinash Kodi Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio

More information

Logic Verification 13-1

Logic Verification 13-1 Logic Verification 13-1 Verification The goal of verification To ensure 100% correct in functionality and timing Spend 50 ~ 70% of time to verify a design Functional verification Simulation Formal proof

More information

Chapter 4 :: Topics. Introduction. SystemVerilog. Hardware description language (HDL): allows designer to specify logic function only.

Chapter 4 :: Topics. Introduction. SystemVerilog. Hardware description language (HDL): allows designer to specify logic function only. Chapter 4 :: Hardware Description Languages Digital Design and Computer Architecture David Money Harris and Sarah L. Harris Chapter 4 :: Topics Introduction Combinational Logic Structural Modeling Sequential

More information

VLSI II E. Özgür ATES

VLSI II E. Özgür ATES VERILOG TUTORIAL VLSI II E. Özgür ATES Outline Introduction Language elements Gate-level modeling Data-flow modeling Behavioral modeling Modeling examples Simulation and test bench Hardware Description

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 19: Verilog and Processor Performance Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Verilog Basics Hardware description language

More information

Finite State Machines

Finite State Machines Lab Workbook Introduction (FSM) are sequential circuit used in many digital systems to control the behavior of systems and dataflow paths. Examples of FSM include control units and sequencers. This lab

More information

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation A Verilog Primer An Overview of Verilog for Digital Design and Simulation John Wright Vighnesh Iyer Department of Electrical Engineering and Computer Sciences College of Engineering, University of California,

More information

ESE 150 Lab 07: Digital Logic

ESE 150 Lab 07: Digital Logic LAB 07 In this lab we will do the following: 1. Investigate basic logic operations (AND, OR, INV, XOR) 2. Implement an ADDER on an FPGA 3. Implement a simple Finite- State Machine on an FPGA Background:

More information

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

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis Synthesis of Language Constructs 1 Nets Nets declared to be input or output ports are retained Internal nets may be eliminated due to logic optimization User may force a net to exist trireg, tri0, tri1

More information

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

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto Recommed Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto DISCLAIMER: The information contained in this document does NOT contain

More information

Introduction to Verilog and ModelSim. (Part 5 Sequential Logic)

Introduction to Verilog and ModelSim. (Part 5 Sequential Logic) Introduction to Verilog and ModelSim (Part 5 Sequential Logic) Sequential Logic It implements storage capabilities of the system Data latch structure Requires clock/gate/latch signal input Latch (level

More information

Amrita Vishwa Vidyapeetham. EC429 VLSI System Design Answer Key

Amrita Vishwa Vidyapeetham. EC429 VLSI System Design Answer Key Time: Two Hours Amrita Vishwa Vidyapeetham B.Tech Second Assessment March 2013 Eighth Semester Electrical and Electronics Engineering EC429 VLSI System Design Answer Key Answer all Questions Roll No: Maximum:

More information

Digital Design (VIMIAA01) Introduction to the Verilog HDL

Digital Design (VIMIAA01) Introduction to the Verilog HDL BUDAPEST UNIVERSITY OF TECHNOLOGY AND ECONOMICS FACULTY OF ELECTRICAL ENGINEERING AND INFORMATICS DEPARTMENT OF MEASUREMENT AND INFORMATION SYSTEMS Digital Design (VIMIAA01) Introduction to the Verilog

More information

Sequential Logic Design

Sequential Logic Design Sequential Logic Design Design of Digital Circuits 2017 Srdjan Capkun Onur Mutlu (Guest starring: Frank K. Gürkaynak and Aanjhan Ranganathan) http://www.syssec.ethz.ch/education/digitaltechnik_17 Adapted

More information

Verilog Overview. Verilog Overview. Simple Example. Simple Example. Simple Example. Simple Example

Verilog Overview. Verilog Overview. Simple Example. Simple Example. Simple Example. Simple Example Verilog Overview Prof. MacDonald Verilog Overview C-Like Language used to describe hardware VHDL is main competitor VHDL is more rigorous and typed VHDL takes longer to write VHDL is used by 5% of USA

More information