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

Similar documents
Laboratory Exercise 3 Davide Rossi DEI University of Bologna AA

Finite-State Machine (FSM) Design

RealDigital. Problem Set #7 S1 S2 S3 Y Z X Y + Y Z X Z

ECE 551: Digital System *

EE 231 Fall EE 231 Homework 13 Due December 3, 2010

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

EECS150 - Digital Design Lecture 20 - Finite State Machines Revisited

Control in Digital Systems

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

Finite State Machines

CS/EE Homework 7 Solutions

Modeling Sequential Circuits in Verilog

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

Finite State Machines

Sequential Logic Implementation. Mealy vs. Moore Machines. Specifying Outputs for a Mealy Machine. Specifying Outputs for a Moore Machine

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

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

Parallel versus serial execution

(ii) Simplify and implement the following SOP function using NOR gates:

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

Digital Integrated Circuits

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

FSM and Efficient Synthesizable FSM Design using Verilog

Digital Integrated Circuits

Mealy and Moore examples

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

CSE 260 Introduction to Digital Logic and Computer Design. Exam 1. Your name 2/13/2014

RTL Design (Using ASM/SM Chart)

Sequential Logic Design

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

Writing Circuit Descriptions 8

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Instructor: Mohsen Imani. Slides from Tajana Simunic Rosing

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Finite State Machines

Quick Introduction to SystemVerilog: Sequental Logic

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

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

Chapter 5 Registers & Counters

v HDL Compiler for Verilog Reference Manual Examples

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

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

PDHonline Course G349. State Machines. Mark A. Strain, P.E. PDH Online PDH Center

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

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

EECS 270 Verilog Reference: Sequential Logic

EECS 151/251A: SRPING 2017 MIDTERM 1

EECS150, Fall 2004, Midterm 1, Prof. Culler. Problem 1 (15 points) 1.a. Circle the gate-level circuits that DO NOT implement a Boolean AND function.

Digital Design with FPGAs. By Neeraj Kulkarni

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

Homework deadline extended to next friday

Final Exam Review. b) Using only algebra, prove or disprove the following:

ECE 551 Digital System Design and Synthesis. Instructor: Kewal K. Saluja. Midterm Exam

FSM Components. FSM Description. HDL Coding Methods. Chapter 7: HDL Coding Techniques

Lectures 11 & 12: Synchronous Sequential Circuits Minimization

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

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING QUESTION BANK SUBJECT CODE & NAME: EC 1312 DIGITAL LOGIC CIRCUITS UNIT I

Problem Set 2 Solutions

Nikhil Gupta. FPGA Challenge Takneek 2012

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

Why Should I Learn This Language? VLSI HDL. Verilog-2

Last Lecture: Divide by 3 FSM

MCMASTER UNIVERSITY EMBEDDED SYSTEMS

Digital Design Using Verilog EE Final Examination

Two hours - online EXAM PAPER MUST NOT BE REMOVED FROM THE EXAM ROOM UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

ECEN 468 Advanced Logic Design

Topics. Midterm Finish Chapter 7

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

Using Programmable Logic and the PALCE22V10

Amrita Vishwa Vidyapeetham. EC429 VLSI System Design Answer Key

ARM 64-bit Register File

Abstraction of State Elements. Sequential Logic Implementation. Forms of Sequential Logic. Finite State Machine Representations

Question Total Possible Test Score Total 100

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Digital Design with SystemVerilog

Testbenches for Sequential Circuits... also, Components

Registers and finite state machines

Injntu.com Injntu.com Injntu.com R16

Verilog for High Performance

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

Designing Safe Verilog State Machines with Synplify

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

Modeling of Finite State Machines. Debdeep Mukhopadhyay

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

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

Verilog 1 - Fundamentals

CE1911 LECTURE FSM DESIGN PRACTICE DAY 2

Graduate Institute of Electronics Engineering, NTU Design of Datapath Controllers

Laboratory Exercise 7

Lecture 32: SystemVerilog

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

One and a half hours. Section A is COMPULSORY UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

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

Memories. Design of Digital Circuits 2017 Srdjan Capkun Onur Mutlu.

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING QUESTION BANK NAME OF THE SUBJECT: EE 2255 DIGITAL LOGIC CIRCUITS

EECS 373 Practice Midterm / Homework #3 Fall 2014

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

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

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

Transcription:

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 D Q Q K Q clk (a) Is this a Mealy machine or a Moore machine? The output deps on one of the present inputs (x) as well as the present state, so it is a Mealy machine. (b) Derive the state transition table for the circuit Call the output of the J-K flip-flop A and the output of the D flip-flop B. We need to find the J and K inputs to the J-K flip flop (J A, K A ). From these, we can find the next state of A. The next state of B will be the input to the D flip-flop. J A = Bx K A = x + B D B = B x + A B z = AB x (c) Draw a state diagram for the circuit. 1/0 A B x J A K A A B z 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 1 1 1 1 1 0 0 0 1/0 0/0 11 1/0 01 0/0 0/0 1/1 0/0 1

(d) Write a Verilog program to implement the functionality of the circuit. Be sure to reset the machine with all flip-flops at 0. We could implement a J-K flip-flop in a Verilog module, then use that flip-flop and the equations for J A and K A. Instead, I will tell the Verilog compiler implement the state transition table. module hw8_p1(input x, clk, output z); reg A,B; always @(posedge clk) if (~A & ~B & ~x) begin A <= 0; B <= 1; if (~A & ~B & x) begin A <= 0; B <= 0; if (~A & B & ~x) begin A <= 0; B <= 1; if (~A & B & x) begin A <= 1; B <= 1; if ( A & ~B & ~x) begin A <= 0; B <= 1; if ( A & ~B & x) begin A <= 0; B <= 0; if ( A & B & ~x) begin A <= 1; B <= 0; if ( A & B & x) begin A <= 0; B <= 0; assign z = A & ~B & x; module 2

2. Consider the following state transition table. It implements a twisted ring counter: (a) Draw a state diagram for the system. Present Next State State A B C A B C 0 0 0 1 0 0 1 0 0 1 1 0 1 1 0 1 1 1 1 1 1 0 1 1 0 1 1 0 0 1 0 0 1 0 0 0 0 1 1 011 1 111 (b) Write a Verilog program to implement the system. module hw8_p2(input clock, output reg A, B, C); always @( posedge clock) case ( {A,B,C} ) 3 b0: {A,B,C} <= 3 b1; 3 b1: {A,B,C} <= 3 b1; 3 b1: {A,B,C} <= 3 b111; 3 b111: {A,B,C} <= 3 b011; 3 b011: {A,B,C} <= 3 b1; 3 b1: {A,B,C} <= 3 b0; default: {A,B,C} <= 3 b0; case module 3

3. Design a synchronous sequential circuit to control the operation of an automatic coffee machine. A cup of coffee costs 15 and the machine has two input slots. In one slot, only coins can be inserted; in the other, only 5 coins. The machine will give change in 5 coins only, and only one such coin per transaction. (a) Draw a state diagram for the circuit. There are two inputs: a nickel deposited (n) or a dime deposited (d). I will assume you cannot put in a nickel and a dime at the same time. There are two outputs: dispense of cup of coffee (k) and give a nickel change (c). You could design this as a Mealy machine or a Moore machine. Here I design it as a Moore machine. There are 5 states: No money deposited, 5 deposited, deposited, 15 and 20. When 15 is deposited, the dispenser should dispense a cup of coffee. When 20 is deposited, the dispenser should dispense a cup of coffee and return 5 change. Input order: nickel dime Output order: coffee change S0 01 S5 xx 01 S S20 11 S15 I assume that another coin cannot be inserted betwen states S15 and S0, or between states S20 and S0. This is a reasonable assumption it will take at least several milliseconds before a person can deposit another coin and the coin can fall into the coin box, while the time between state S15 and S0 is one clock cycle, probably less than a microsecond. 4

(b) Assign states, and draw a state transition table. There are five states, so you need at least three flip-flops. To simplify the output logic, I make the following state assignments: State A B C n d A B C k c 0 0 0 0 0 0 0 0 0 0 S0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 1 x x x x x 0 0 1 0 0 0 0 1 0 0 S5 0 0 1 0 1 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 1 1 x x x x x 0 1 0 0 0 0 1 0 0 0 S 0 1 0 0 1 1 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 1 0 x x x x 1 0 0 0 0 0 0 0 1 0 S15 1 0 0 0 1 x x x x x 1 0 0 1 0 x x x x x 1 0 0 1 1 x x x x x 1 0 1 0 0 0 0 0 0 0 S20 1 0 1 0 1 x x x x x 1 0 1 1 0 x x x x x 1 0 1 1 1 x x x x x 5

(c) Write a Verilog program to implement the circuit. module hw8_p3(input clock, n, d, output k, c); reg [2:0] state; parameter S0 = 3 b0, S5 = 3 b1, S = 3 b0, S15 = 3 b1, S20 = 3 b1; always @( posedge clock ) case (state) S0: if (n) state <= S5; else if (d) state <= S; else state <= S0; S5: if (n) state <= S; else if (d) state <= S15; else state <= S5; S: if (n) state <= S15; else if (d) state <= S20; else state <= S; S15: state <= S0; S20: state <= S0; default: state <= S0; case assign k = ((state == S15) (state == S20))? 1 b1 : 1 b0; assign c = (state == S20)? 1 b1 : 1 b0; module 6

4. Here I will repeat Problem 3, but design the system as a Mealy machine. For a Mealy machine, you don t need the states S15 or S20. If you are in state S and someone deposits a nickel, the machine can dispense a cup of coffee and go back to state S0. Here is the state machine: / Input order: nickel dime Output order: coffee change S0 / 01/ / S5 01/ / 11/11 S / / 7

Here is a Verilog program: module hw8_p3(input clock, n, d, output reg k, c); reg [1:0] state; parameter S0 = 3 b0, S5 = 3 b1, S = 3 b0; always @( posedge clock ) case (state) S0: if (n) state <= S5; else if (d) state <= S; else state <= S0; S5: if (n) state <= S; else if (d) state <= S0; else state <= S5; S: if (n) state <= S0; else if (d) state <= S0; else state <= S; default: state <= S0; case always @( state, n, d) begin if ((state == S5) && (d)) k = 1; else if ((state == S) && (n)) k = 1; else if ((state == S) && (d)) k = 1; else k = 0; if ((state == S) && (d)) c = 1; else c = 0; module 8