Docsity

Project Report for Processor Design | CS 3220, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
GEORGIA INSTITUTE OF TECHNOLOGY
College of Computing
CS3220 | Processor Design
Spring 2001
CS3220 Issued: January 22, 2001
Project 1 Due: February 7, 2001
Purpose:
The purpose of this project is to gain additional practice with dig-
ital logic and nite state machines. You will design and implement
an I/O interface to permit communication between the Altera UP-
1 board and a host Sun computer. You will implement both the
hardware and software sides of the interface. The nal demonstra-
tion is to pass a byte from the board to the Sun and vice-versa.
Reading:
H&P Appendix B
Problems:
1. Problem description and suggested proto col
2. Sample implementation and warmup
3. Hardware state machine
4. Software state machine
To turn in:
1. Circuit schematics, etc.
2. Software source code
3. Demo
On-line copies of the microcode skeleton,
makectl
source, a sun-side executable and a
UP-1-side .jam le may be found on the course web page:
http://www.cc.gatech.edu/classes/AY2001/cs3220 spring/project1/
CS3220 Spring 2001 {1{ January 22, 2001
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Project Report for Processor Design | CS 3220 and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

GEORGIA INSTITUTE OF TECHNOLOGY

College of Computing

CS3220 | Pro cessor Design Spring 2001

CS3220 Issued: January 22, 2001 Pro ject 1 Due: February 7, 2001

Purp ose: The purp ose of this pro ject is to gain additional practice with dig- ital logic and nite state machines. You will design and implement an I/O interface to p ermit communication b etween the Altera UP- 1 b oard and a host Sun computer. You will implement b oth the hardware and software sides of the interface. The nal demonstra- tion is to pass a byte from the b oard to the Sun and vice-versa.

Reading: H&P Appendix B

Problems: 1. Problem description and suggested proto col

  1. Sample implementation and warmup
  2. Hardware state machine
  3. Software state machine

To turn in: 1. Circuit schematics, etc.

  1. Software source co de
  2. Demo

On-line copies of the micro co de skeleton, makectl source, a sun-side executable and a UP-1-side .jam le may b e found on the course web page: http://www.cc.gatech.edu /classe s/AY200 1/cs32 20 spring/project1/

Problem 1: Problem Description and Suggested Proto col

This section de nes the overall goal of the pro ject. The other three sections will esh out the pieces you have to build and provide suggestions. There is nothing to turn in for this problem.

Problem Statement

The goal of the pro ject is to build the hardware and software required to communicate information b etween the UP-1 b oard and an attached Sun host over a 4-wire link. The 4-wire link provides two unidirectional signals in each direction as follows:

-------> D_TO_UP1 ------> Sun -------> H_TO_UP1 ------> Altera UP- host <------- D_TO_SUN <------ board <------- H_TO_SUN <------

The signal names re ect their uses in the suggested proto col (b elow). D wires are for \data" and H wires are for \handshake" (timing).

The system you build should have the following b ehavior:

 When button PB1 on the UP-1 b oard is pressed, the state of the eight DIP switched attached to the 10K70 should b e sampled and passed to the Sun as a byte. The Sun should print out this byte as a hexadecimal numb er.  When button PB2 on the UP-1 b oard is pressed, the Sun should prompt for a byte, then pass the byte down to the UP-1 b oard where it is placed as two hexadecimal digits on the two 7-segment displays attached to the 10K70.

Suggested Proto col

Here's a proto col that I used. You don't have to use the same proto col but I highly recommend it b ecause if you use my proto col you'll b e able to use my solutions to help debug your implementation.

The proto col has two parts (A and B b elow). The rst part de nes how individual bits are transferred (the \four-phase handshake"). The second part de nes how bits are enco ded into multi-bit data bytes and commands.

A. The proto col transfers individual bits by using the uses the two H wires to p erform a four-phase handshake for every bit transferred. The UP-1 initiates every transfer. The four-phase handshake works like this, as if two p eople were shaking hands (a little out of sync).


H_TO_SUN: _______| |________________


D_TO_UP1: XXXXXXXXXXXX__________XXXXXXXXXXXXXXXXXXXX


H_TO_UP1: ______________| |_______

^ ^ ACK | ACKACK

B. The second part of the proto col is how bits are assembled into bytes and commands. I chose the following scheme:

 The UP1 controls all transfers and issues all commands.

There are three commands:

 NOP: A zero bit is a NOP command. The UP1 may send a NOP at any time. In fact I have my circuit send NOPs all the time when it's not doing something else.  OUTPUT: A data byte is transferred from the UP1 to the Sun as a 10-bit string, i.e. in 10 handshake cycles. The rst two bits are \1" and then \0" (the command). The remaining eight bits are the data byte, MSB (most-signi cant-bit) rst.  INPUT: A data byte is transferred from the Sun to the UP1 with 10 handshake cycles also. The rst two transfer a command (\1", \1") to the Sun. The remaining eight cycles transfer eight bits from the Sun to the UP1, MSB rst.

The reason for the NOP command is subtle but very useful: at the time the Sun and UP are connected, their resp ective state machines may b e out of sync, i.e. the UP1 is ab out to send a command and the Sun thinks it's in the middle of receiving data. Also, data errors in the link (very unlikely) or bugs in the state machines (highly likely while debugging) can cause the state machines to get out of sync. The NOP provides an easy way to get back into sync: if the UP1 sends 10 zeros, the Sun will de nitely b e back to waiting for the b eginning of a command.

Example

Here's an example sequence in which the UP1 sends 0x37 to the Sun and the Sun sends 0x to the UP1. Each character represents one handshaking cycle. The \x" characters represent unknown/don't care but in reality are probably zeros. Note the numerous NOPs b efore, b etween and after the OUTPUT and INPUT commands. Since the INPUT/OUTPUT command co des b egin with \1", it is easy to parse the string and see where the commands b egin.

D_TO_SUN: 0 0 0 0 0 1 0 0 0 1 1 0 1 1 1 0 0 0 1 1 x x x x x x x x 0 0 D_TO_UP1: x x x x x x x x x x x x x x x x x x x x 0 1 0 0 0 0 1 0 x x

Problem 2: Example Implementation and Warmup

This problem gives p ointers to binary versions of hardware- and software-side implemen- tations of the proto col describ ed in Problem 1 and suggests some warmup exercises using them. You are welcome to use the two pieces to debug your own implementations as well. There is nothing to turn in for this problem.

The hardware implementation is in the form of a prj.jam le and the software implemen- tation is in the form of Sun and Linux executables prj1.sun and prj1.linux, all on the course web site. http://www.cc.gatech.edu /classe s/AY200 1/cs32 20 spring/project1/

A: Load the prj1.jam le into your UP1 b oard, then start the prj1.sun executable. Check whether the b ehavior conforms to the sp eci cation in Problem 1. Note that this pro cedure thoroughly exercises the mo di cations made to the UP1 b oard this semester. If your b oard fails this test, see the instructor.

B: Try prj1.sun -v (the -v is for \verb ose" mo de). You'll see a printout of the four wires in the 4-wire interface scroll by. Verb ose mo de o ers a way to see what is going on if you use prj1.sun to debug your hardware.

PB1 -------> NOT -------> H_TO_SUN PB2 -------> NOT -------> D_TO_SUN H_TO_UP1 -------> NOT -------> MDP D_TO_UP1 -------> NOT -------> LDP

C: Make a trivial Altera design (ab ove) that uses PB1 and PB to drive (through inverters) H TO SUN and D TO SUN resp ectively, and uses H TO UP1 and D TO UP1 to drive (again through inverters) the MDP and LDP decimal p oints on the two 7-segment displays. I ac- tually extended my Homework 2 design with the wires ab ove, since I didn't use those pins in Homework 2. Load the design, run prj1.sun -v and step the through the proto col by hand using PB1 and PB2. Try uploading a byte and downloading a byte.

 Redhat 6.

Control Path


(from debounce) PB1 ----->| | ------> H_TO_SUN (from debounce) PB2 ----->| FSM | ------|- H_TO_UP1 ----->| | | |---> D_TO_SUN | | SR8-|/ | | | | | -------/ usesh | | ------> shift | | ------> ldsr clock ----->| | ------> ldled


Data Path


| | | | | SR | | FF | 8 | | 8 | | 8 switches -/->|D Q|-------/------->|D Q|----/---> LEDs (to 7-seg decode) D_TO_UP1 ---->|Din | | | shift ---->|shft| | | ldsr ---->|LD | ldled --->|LD | clock ---->|> | /-------->|> | | ------ | ------ --------------/

The datapath ab ove takes care of all the incoming data during INPUT (D TO UP1 no longer even needs to go to the FSM) and takes care of the outgoing data during an OUTPUT op eration. The D TO SUN signal comes from a MUX so that it can b e driven either by the top bit of the shift register (for data bits) or directly by the FSM (for control bits).

B: Try placing an LPM SHIFTREG comp onent in an Altera de- sign and setting the p orts/parameters to achieve the features needed ab ove. Note that you can turn o any pins that you don't need. Also, a subtle p oint (buried in the help page), the LPM SHIFTREG do esn't have a \shift" input, just an \enable" input. Asserting \en- able" alone causes a shift. To load, you must assert both enable and load.

C: Roughly how many states are required in the control FSM for the ab ove design? Can you think of ways to reduce the num- b er of control states? For instance, I used an external counter (LPM COUNTER) to count outgoing/incoming data bits in order to reduce the numb er of FSM states.

There is no obviously \right" answer to this design, by the way. Many p ossible answers are ne.

FSM Generator

I develop ed an FSM generator (\makectl") to go with the Altera to ols. The source co de is on the pro ject web page. This to ol takes a description of an FSM and generates a VHDL-based comp onent in the canonical Mo ore machine form: two ROMs plus a register holding the state.

The FSM generator is intended for controlling the micro co ded pro cessor in Pro ject 2 so it includes a couple of o dd features that are unneeded here. It was compiled and tested using GCC on Sparcs running Solaris. The assembler takes an input le (a .ctl le) in the format of the example b elow and writes a VHDL description of the FSM, complete with program, into a .vhd le plus two .mif les.

Usage: makectl reads .ctl writes .vhd, -inrom.mif and -outrom.mif

Here's a detailed example based on the second blo ck diagram ab ove.

FSM Details

The example on the previous page gives a sample state-transition table for the FSM. Note:

 The current state and inputs are on the left of the =>" mark; the next state and outputs are on the right of the mark.  The *" character is p ermitted on inputs. When there is more than one next state for a state (i.e. PB1 matters), then there there are subsequent lines for the state with the other p ossible next states (see state 0x09. Note that since the FSM is a Mo ore machine, only the next state eld is allowed to dep end on the inputs; the outputs may only dep end on the current state.  The \op:" input eld and the \jump" output bit are unused. The jump bit must b e set to zero and the op: eld may b e left blank.

Also, note for the makectl program particularly:

 The generator is column-oriented: it dep ends on having the various bits lined up exactly under the column header. If there is a mismatch, it will print the o ending line plus a \pattern" indicating what it exp ected to see.  The header lab els are required. The generator uses the lab els as p ort names in the VHDL output le.  Whitespace must b e SPACE characters { TAB characters are illegal. In emacs you can use the M-xuntabify command to remove TAB characters from a region in your .ctl le.

To use an FSM created by makectl in your circuit, do the following:

 Write your .ctl le, e.g. fsm.ctl, in your Altera working directory.  Run makectl fsm, which creates fsm.vhd plus some .mif les.  Go into the Altera to ol and op en the fsm.vhd le.  Select File->Create Default Symb ol, which will run the rst phase of the compiler and make a new symb ol named \fsm"  Op en the schematics le for your altera design. Place a new symb ol and when prompted for a symb ol name, enter \fsm". You should see a symb ol blo ck with the input and output names as sp eci ed in the fsm.ctl le.

Note that if you change the fsm.ctl le, you need to rerun makectl and then recompile your Altera design. You do not need to do the Create Default Symb ol op eration again unless you actually change the inputs and outputs in fsm.ctl.

D: Try compiling the sample fsm.ctl le (the sample ab ove is available on the web site) and instantiating it in the Altera to ols.

Finally:

E: Design your hardware circuit and test it. Turn in whatever is needed to do cument the design: schematics, .ctl le, etc.

Problem 4: Software State Machine

The software state machine is probably easier to design b ecause you are all exp ert pro- grammers. This section describ es the interface to the parallel p ort hardware.

The default language for this assignment is C. You're welcome to write in whatever lan- guage you want, but the supp ort co de is only provided in C.

The parallel p ort interface is encapsulated in two les on the web page, hackio.c and hackio.h. The .h le de nes three pro cedures and bitmasks for the I/O bits:

#define D_TO_SUN 0x #define H_TO_SUN 0x #define D_TO_UP1 0x #define H_TO_UP1 0x

void initbits(void); /* called exactly once / void writebits(int bits); / called w/x_TO_UP 1 bits / int readbits(void); / returns x_TO_SUN bits */

A: Write a program to serve as the interface to your b oard. The program should have more or less the same b ehavior as prj1.sun but do es not need to supp ort any debugging output (no -v ag). Turn in your source co de.

B: Finally, demonstrate your working UP1 b oard and interface co de to the instructor, either during oce hours or by app ointment.