Lab Assignment 5 I. THE 4-BIT CPU AND CONTROL

Similar documents
Sequential Logic Design CS 64: Computer Organization and Design Logic Lecture #14

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

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Microprocessor Design

Ryerson University Department of Electrical and Computer Engineering COE/BME 328 Digital Systems

More Digital Circuits

LAB 3 Verilog for Combinational Circuits

ENGG2410: Digital Design Lab 5: Modular Designs and Hierarchy Using VHDL

You will be first asked to demonstrate regular operation with default values. You will be asked to reprogram your time values and continue operation

Logic Design ( Part 3) Sequential Logic- Finite State Machines (Chapter 3)

LAB 3 Verilog for Combinatorial Circuits

CSC258: Computer Organization. Combinational Logic

Laboratory Exercise 7

COMP sequential logic 1 Jan. 25, 2016

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

CHAPTER 4: Logic Circuits

Faculty of Electrical & Electronics Engineering BEE3233 Electronics System Design. Laboratory 3: Finite State Machine (FSM)

CS 261 Fall Mike Lam, Professor. Sequential Circuits

Physics 323. Experiment # 10 - Digital Circuits

CHAPTER1: Digital Logic Circuits

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

Advanced Digital Logic Design EECS 303

CHAPTER 4: Logic Circuits

Sequential Circuits. Output depends only and immediately on the inputs Have no memory (dependence on past values of the inputs)

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

Synchronous Sequential Logic

Programmable Logic Design Techniques II

EECS150 - Digital Design Lecture 15 Finite State Machines. Announcements

CS3350B Computer Architecture Winter 2015

Lab #10 Hexadecimal-to-Seven-Segment Decoder, 4-bit Adder-Subtractor and Shift Register. Fall 2017

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

CPSC 121: Models of Computation Lab #5: Flip-Flops and Frequency Division

Figure 30.1a Timing diagram of the divide by 60 minutes/seconds counter

Digital Electronics II 2016 Imperial College London Page 1 of 8

University of Pennsylvania Department of Electrical and Systems Engineering. Digital Design Laboratory. Lab8 Calculator

Registers and Counters

Chapter Contents. Appendix A: Digital Logic. Some Definitions

ELCT201: DIGITAL LOGIC DESIGN

ECE 263 Digital Systems, Fall 2015

Lab #12: 4-Bit Arithmetic Logic Unit (ALU)

CPSC 121: Models of Computation Lab #5: Flip-Flops and Frequency Division

University of Victoria. Department of Electrical and Computer Engineering. CENG 290 Digital Design I Lab Manual

TSIU03, SYSTEM DESIGN. How to Describe a HW Circuit

CS61C : Machine Structures

CS 110 Computer Architecture. Finite State Machines, Functional Units. Instructor: Sören Schwertfeger.

ECSE-323 Digital System Design. Datapath/Controller Lecture #1

First Name Last Name November 10, 2009 CS-343 Exam 2

ENGN3213 Digital Systems and Microprocessors Sequential Circuits

CS61C : Machine Structures

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

Inside Digital Design Accompany Lab Manual

Go BEARS~ What are Machine Structures? Lecture #15 Intro to Synchronous Digital Systems, State Elements I C

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

California State University, Bakersfield Computer & Electrical Engineering & Computer Science ECE 3220: Digital Design with VHDL Laboratory 7

EECS150 - Digital Design Lecture 3 Synchronous Digital Systems Review. Announcements

Side Street. Traffic Sensor. Main Street. Walk Button. Traffic Lights

Logic Design II (17.342) Spring Lecture Outline

Chapter 4. Logic Design

Experiment # 12. Traffic Light Controller

Chapter 4: One-Shots, Counters, and Clocks

COMP2611: Computer Organization Building Sequential Logics with Logisim

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Tajana Simunic Rosing. Source: Vahid, Katz

ENGG 1203 Tutorial. D Flip Flop. D Flip Flop. Q changes when CLK is in Rising edge PGT NGT

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

VARIABLE FREQUENCY CLOCKING HARDWARE

6.3 Sequential Circuits (plus a few Combinational)

Step 1 - shaft decoder to generate clockwise/anticlockwise signals

EECS 578 SVA mini-project Assigned: 10/08/15 Due: 10/27/15

T 2 : WR = 0, AD 7 -AD 0 (μp Internal Reg.) T 3 : WR = 1,, M(AB) AD 7 -AD 0 or BDB

Sequential Logic. Introduction to Computer Yung-Yu Chuang

EECS 3201: Digital Logic Design Lecture 9. Ihab Amer, PhD, SMIEEE, P.Eng.

Chapter 2. Digital Circuits

Electrical and Telecommunications Engineering Technology_TCET3122/TC520. NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

Design and implementation (in VHDL) of a VGA Display and Light Sensor to run on the Nexys4DDR board Report and Signoff due Week 6 (October 4)

COMP12111: Fundamentals of Computer Engineering

LAB #4 SEQUENTIAL LOGIC CIRCUIT

L14: Quiz Information and Final Project Kickoff. L14: Spring 2004 Introductory Digital Systems Laboratory

CS61C : Machine Structures


Switching Circuits & Logic Design, Fall Final Examination (1/13/2012, 3:30pm~5:20pm)

Computer Systems Architecture

Registers and Counters

Individual Project Report

Task 4_B. Decoder for DCF-77 Radio Clock Receiver

cs281: Introduction to Computer Systems Lab07 - Sequential Circuits II: Ant Brain

CprE 281: Digital Logic

IS1500 (not part of IS1200) Logic Design Lab (LD-Lab)

Laboratory Exercise 7

COE328 Course Outline. Fall 2007

Contents Circuits... 1

More on Flip-Flops Digital Design and Computer Architecture: ARM Edition 2015 Chapter 3 <98> 98

Sequential Logic. E&CE 223 Digital Circuits and Systems (A. Kennings) Page 1

CS/ECE 250: Computer Architecture. Basics of Logic Design: ALU, Storage, Tristate. Benjamin Lee

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Traffic Light Controller

Ryerson University Department of Electrical and Computer Engineering EES508 Digital Systems

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS 150 Spring 2000

The word digital implies information in computers is represented by variables that take a limited number of discrete values.

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Transcription:

Lab Assignment 5 ECE/CS 3700 Spring 2013 Assigned Thursday (April 11) onwards, circuit demo due during the week 4/22-4/26, final report due by Friday 4/26. Hand it to your TAs or drop it in the HW locker by 5pm 4/26. 1 Now that you have become familiar with both combinational and sequential logic design (adders, counters, latches, FFs, etc.) it is time to put these pieces together and build some large systems. So, in this lab you have an option of designing any one (not both) of the following two designs: Project 1: Verilog Design, Simulation, Synthesis, Implementation and Testing of a 4-bit CPU and control. Project 2: Verilog Design, Simulation, Synthesis Implementation and Testing of a music/tone generator. Of the above two projects, you may choose the one that suits your interests. In my view, the CPU design project is more suitable for those students who have taken EE/CS 3810. However, that does not mean that those students who have not taken 3810 should avoid this project. Both projects require the implementation of a state-machine and interfacing it with other components. So, the choice is yours. Described below is the design description for each of the projects. I. THE 4-BIT CPU AND CONTROL You will be designing a circuit very similar to the one shown in Fig. 7.73 in the textbook. Take a look at the figure and maybe you should also go through Sections 7.14.1 and 7.14.2. Your CPU will have the following: An Arithmetic and Logic Unit (ALU) that takes 2 4-bit numbers as inputs and produces an output (4-bit for logical ops, 5 bits for add, but you may choose to ignore the carry bit). The operations that the ALU performs are ADD and the following bit-wise logical ops: OR, XOR, NOT. There are three 4-bit registers R 1, R 2 and R out connected to a 4-bit bus via tri-state buffers. I m asking you to design a small finite-state-machine (FSM) that hard-codes a few instructions, executes them, and then comes to a halt. The execution can be re-started when reset is pressed. This FSM is essentially a circuit that controls/assigns the signals to: i) the register- and tribuf-enable signals that transfer data between registers via the bus; and ii) select the required ALU operation. This FSM/CPU control (and the program to be hard-coded) is described in the next section. (Note: In a general purpose computer, the bus is connected to a memory that holds a program. The CPU control then has the responsibility to fetch/decode/execute the instructions - usually done by enabling/disabling the buffers and registers, just as required above. The FPGA board does have an SDRAM where you can store a large program. However this requires an interface via a memory controller and the subsequent design and synthesis would require a lot more time and effort than a 2-week lab project. It would, in fact, turn out to be a

2 mini-3710 project. So, I m asking you to just hard-code a program in an FSM, and implement the required CPU control. This way, you will get a fair idea of why CPU control is a state machine and how does it work!) The Bus is also connected to a 4-bit external input (say, a DIP switch on your board?) to read data that the FSM would then process. Note the tri-state buffer to isolate the switch. A block diagram of the design is shown in Fig. 1. The entire system is synchronized w.r.t. a common clock. The block-diagram is just a reference, you may (or may not) require to add/delete a few signals. You have enough flexibility to implement your design. Just make sure to implement: i) a global reset as an external combinational input connected to a push-button switch on the FPGA board; ii) connect a 7-segment display to R out to view the result; and iii) 4 push-button or dip-switches to read external data as input. The FSM for CPU control CPU Control, controlling all the signals: R_enable, Buffer enables, ALU cntl. etc. The entire system is synched. w.r.t. the same clock bufs en Connect to 4 switches {S3, S2, S1, S0} External Data input 4 bit Bus regs en Tri bufs Buf enable 4 bit tri bufs R1 enable R1 R2 ALU cntl 4 bit A L U R out Fig. 1. Block Diagram of the 4-bit CPU+Control A. FSM: CPU control + Hardcoded Program Your design will interface the CPU with a control FSM that has the following specifications: At Reset, it goes to State-0 (S 0 ). Here, it tri-states all bufs, and resets all registers to 4 b0000. When reset is de-activated, the machine transitions to a next state (from S i to S i+1 ) at every positive-edge of the clock. In State-1 (S 1 ), the machine reads the data on the external switch and loads it in register R 1. In other words, the first instruction being executed is LOAD R 1 EXTERNAL DATA. How would you do this? Well, open the respective buffers to put the data on the bus; enable R 1 so that at the next positive edge of the clock, R 1 loads the data corresponding to the external switch connections.

3 In S 2, load an integer-value 3 in R 2. This is akin to a load-immediate instruction: LDI R2 4 B0011. In S 3, ADD R 1 + R 2 and store the result in R out. For this, you will have to give a signal to the ALU that it has to perform the add operation on the data available at its inputs, and you have to enable R out so it will store the result at the next posedge clk. Instruction: (R out R 1 + R 2 ). In S 4, transfer the data from R out to R 2 : Mov R 2 R out. In S 5, R out R 1 R 2, (bit-wise OR). In S 6, Mov R 1 R out. In S 7, R out NOT(R 1 ), (bit-wise complement). In S 8, Mov R 1 R out. In S 9, R out R 1 R 2, (bit-wise XOR). When you get to S 9, you display the result on the 7-segment and stay in this state until the reset is pressed - in which case re-start the process from S 0. Hints: One can test your program by adjusting the external-dip switches to different 4-bit values and re-starting the program. For example, what is the value of R out (7-segment display) in the terminal state, when R 1 = 4 b1001 in the initial state? Study tri-state buffers. Recall, bufif0 and bufif1 library modules that I showed in class? If you don t, try google! Should the bus variable be declared as a wire? Or as something else? Check Section 7.14. Try to implement each element of the CPU as a separate module. Your top-level hierarchy would then interconnect all these modules via wires/tri-state buffers. The Assignment: Verilog Design + Simulation + Synthesis + Mapping + Demo + Project report = the usual. II. THE MUSIC/TONE GENERATOR If we generate a square/sine-wave of some frequency (between 20Hz to 20KHz) and connect it to a speaker, you ll hear a tone. Musical notes (A, B, C, C #, etc.) can be generated by designing a clock corresponding to that frequency. If I give you a document that lists the frequency of all musical notes, then you ve designed a rudimentary tone-generator. Of course, the quality of the sound depends upon amplification, filtering, signal processing, etc., but for this project the main idea behind such a circuit is generating clocks at different frequencies. Select different clocks at different time intervals, and what you ll hear is going to be music to your ears. So how is this different from the stop-watch? Well, the assignment is described below; refer to Fig. 2 too. Your design will operate as follows: Using the push-button switches S0, S1, S2 you can play each of the 7 notes (as in a trumpet?). We will generate only major notes. When S3 is 0, your design should play the notes corresponding to the switches (S0, S1, S2) pressed. When S3 = 1, you ll ignore S0, S1, S2 and play a pre-recorded song. The pre-recorded song is an FSM design. First, let us consider the case when S3 = 0 - in which case S0, S1, S2 act like your keyboard.

4 External Clk S0 S1 S2 FPGA running your FSM Music Generator Output S3 Fig. 2. Block Diagram of the Music/Tone Generator When none of the switches are pressed, you will not play any note. When you press S0, you ll play note A. When you press S1, you can play B. When you press all three switches together you ll play the last note G. Therefore, by pressing a combination of these switches, you can create music (or noise, depending on your tastes). When S3 = 1, you ll play a tune called Habanera from Carmen, an opera by Bizet. The composition (the notes, the frequency, and the duration of each note) is available as another document on the class web-page. Using the table, you ll build a state-machine that generates a clock at a particular frequency, for a particular duration (corresponding to the note being played). Looks kind of tedious at first glance, but the design consists of a bunch of counters selected by a selector FSM! A midi file corresponding to the tune is also uploaded on the class webpage so you can hear the tune. Design your machine such that it keeps on repeating the tune - i.e., keeps on looping through (when S3 = 1). The moment S3 = 0, the machine should get into the input polling mode. You can implement S3 using a DIP switch, and S0, S1, S2 using the push-button switches. Speakers are available on the desks in the lab for testing and demo. For the Note to Frequency translation, refer to the site: http://www.phy.mtu.edu/ suits/notefreqs.html The Assignment: Verilog Design + Simulation + Synthesis + Mapping + Demo + Project report = the usual. A. Lab Report Submissions + Deadlines As usual, you will be expected to document your labs in a professional manner. Show your design as a blockdiagram/schematic. State any assumptions, highlight important features, elaborate on any optimizations that you may have performed. Describe the testing/troubleshooting strategy. Deadlines: This is a bit tricky. Classes end on Wed, 5/24. But you will need two weeks to complete this project. So, let us keep the regular lab session times during the last week until Friday 4/26 for the final demo. I will ask

5 the TAs to be available during their regular lab and TA hours for the last week. Since 25th is the reading day, you won t have any conflicts with classes. This way, we can accommodate the entire class. I ll be a nice guy and give you the opportunity to submit the final report by Friday 4/26. Have fun!