EE260 Lab 8
Electronic Racquetball

1. Objective

The objective of this lab experiment is to design and implement a project of moderately significant size. The project is described in the next section. We will take a modular approach in this design, and an incremental approach to implementation. The overall description of the game and major block diagram are given in the next section. Each of the modules is further divided into submodules, and the implementation discussed in the following sections.

This lab will give you the opportunity to design and implement using several different techniques using SSI and MSI parts, as we will be discussing in class.


2. Description of the game

The game consists of the following: two push buttons (that function as rackets) and a display of six LEDs in a row (that shows the position of the ball on the Court). There are two additional LEDs which indicate the player who's turn it is to hit the ball. The following figure illustrates what the game looks like.
LED A (resp., LED B) is ON when it's player A's (resp., B's) turn to hit the ball. LEDs 1 through 6 give the position of the ball in the court. (Note that this is a very narrow court.) LED 6 corresponds to the wall at the end of the court . LED 1 is where the players are. If LEDs 1 through 6 are OFF then the ball is out of play, and so one of the players must serve. The player with its LED ON serves by pushing his/her button. (For example, if LED A is ON then it's Player A's turn to serve.) The ball commences down the court starting at LED 1. It bounces off the wall, and then returns back to LED 1. If the other player hits the button (i.e., "swings" his/her racket) when LED 1 is ON then the ball goes back down the court again (i.e., LED 2 goes ON and so forth). Otherwise, the player "misses" and the game is over (i.e, the ball is out of play). The player that wins the game gets to serve in the next game. The circuit is organized into three parts: Court Display, Racket Module, and Controller. These will be described in subsequent sections.
You will design three racketball games. The first is a simplified version of the above game with only a single player which will get the Court Display and Racket Modules implemented. The second is the full two player game described above, and is called Racketball 1. For this game, the ball moves with each clock period, so that the ball speed is constant. The third, called Racketball 2, is modified from the first. For this game, the ball has two speeds, depending on when a player swings his/her racket.

3. What You Turn In

This is a four week assignment It will be counted three times more than the previous labs, which were worth 10 points each. So this lab is worth 40 points. Do the tasks and answer the questions in the following sections. Each lab group should turn in the You must also demonstrate to the TA protoboard versions of the single player game, Racketball 1, and Racketball 2. You may only use parts from your Lab parts kit.

To be able to complete this entire project in the time alotted, here are a set of milestones to strive for. There is an extra week in the schedule to allow for schedule slips, but do not let the schedule slip too far, or you will not be able to finish.

Week 1: Racquetball 0.
Design and build the Racket Module and the Court Display (these may take a little longer than a week).
Week 2: Design and build Racketball 1.
Week 3: Design and build Racketball 2.
Week 4: Complete any unfinished tasks and questions and work on the report.

4. Racquetball 0 - Solitare

The first implementation of the racquetball game is a single player game for which you will build several of the major modules for the final game. The following are descriptions of the Racket Module and Court Display.

Description of Racket Module:

The racket module is shown below
The module has an output "Sw" (for "Swing") and an input "Pl" (for "Player"). The controller can choose the Player it wishes to observe by setting "Pl". If Pl = 0 then the controller chooses to observe Player A, and if Pl = 1 then the controller chooses to observe Player B. The output "Sw" equals 1 if the player chosen has just pushed his/her button (i.e, "swung" his/her racket). Otherwise, "Sw" equals 0.

The Racket Module is actually composed of submodules as shown below.

Note that a circuit called a 2:1 multiplexer (also written as 2-to-1 multiplexer, or 2:1 mux, or 2:1 selector) is used. A 2:1 multiplexer is a combinational circuit.  It has a single output Y, a single "Select" input, and two data inputs A and B.  Y is either connected to A or B, and this is determined by the "Select" input.  In particular, if Select = 0 then Y = A.  If Select = 1 then Y = B.

The multiplexer is to be implemented using the 74157, which is actually a collection of four 2:1 multiplexers with a common Select input. The first multiplexer has inputs (1A,1B) and output 1Y; the second multiplexer has inputs (2A,2B) and output 2Y; the third multiplexer has inputs (3A,3B) and output 3Y; and the fourth multiplexer has inputs (4A, 4B) and output 4Y. See the Select IC Datasheets for a pin description of the 74157.

The 74157 also has an additional "Strobe" input (or "enable G" input). If the Strobe = H then all outputs (1Y, 2Y, 3Y, 4Y) are L which basically deactivates the multiplexers. If the Strobe = L then the multiplexers are active and perform as follows. If Select = L then 1Y = 1A, 2Y = 2A, 3Y = 3A, and 4Y = 4A. If Select = H then 1Y = 1B, 2Y = 2B, 3Y = 3B, and 4Y = 4B.

The button submodules are connected to the button switches, which are single pole single throw (SPST) switches. The submodule outputs are "SwA" and "SwB" for players A and B, respectively. They indicate when a player has "swung" his/her racket. A player "swings" by pushing the button. Note that if the player keeps the button down then that shouldn't correspond to the player continuously "swinging."

The output of a button submodule should have the following timing diagram.

Note that as soon as the switch is depressed (pushed down), the output of the button submodule goes to "1," and then goes to zero after the next upward clock transition. In this way, after the racket is swung, the output is "0."

The button submodule for Player A is organized as follows (the submodule for Player B is identical).

The D flip flop on the left (attached to the SPST switch) is a 7474 device. Actually there are two D flip flops on a 7474 chip. But the D flip flops are different from the ones in a 74175. These flip flops have additional "clear" (CLR) and "preset" (PR) inputs. If the clear is asserted (by a L input) then the output Q goes to 0 immediately, i.e., it's not synchronized with the clock. Similarly, if the preset is asserted then the output Q goes to 1 immediately. These inputs are called "asynchronous" because the output immediately reacts to them.

The way the 7474 D flip flop is set up, when the switch is pressed down, the "clear" input is asserted and the output Q immediately goes to 0. Note that Q will change back to 1 at the next clock transition, because the input D is permanently set to 1.

To complete the design for the button submodule, you must design Module P, which requires at most one D flip flop. For Module P, use a flip flop on a 74175 device.

Task 1.

Draw the ASM chart for Module P. Note that its input is Q (from the '74 D flip flop) and that its output is SwA. Module P should have two states: "Button was not pressed"and "Button was pressed."

Task 2.

Construct the Racket Module in Logicworks. Note that it's composed of two button submodules and a 2:1 multiplexer. Use the 74157 device for the multiplexer. Get a print out of your working Logicworks circuit.

Task 3.

Your group should build a working Racket Module circuit on a protoboard. Make sure to convert the circuit diagram into a schematic diagram by including the device numbers and pin numbers for each device.

Description of the Court Display.

The following is a block diagram of the Court Display (the clock input is implied, and not shown in the diagram).
Note that there are six outputs (L1, L2,..., L6) that are connected to LED 1, LED 2,..., LED 6, respectively. Note that they have the negative logic convention. There are two more outputs: Game and HZone. Game = 1 if and only if the ball is in play (i.e., one of the LEDs is ON). HZone = 1 if and only if the ball is returning and is at LED 1. Thus, HZone = 1 means that a player can Hit the ball. There are two inputs: Run and SwC. SwC = 1 means that a player is swinging his/her racket. If the ball is out of play then SwC = 1 will mean that a serve is taking place. Run = 1 will advance the ball in the court display. If Run = 0 then the ball will hold its position. For Racketball I, the input Run should be set to 1. However, for Racketball II, where ball speeds may change, we'll have Run equal 0 and 1 to control the speed.

The display should have the following states:

State	Interpretation
S0 Ball is at LED 1 and is proceeding in the direction of the Wall
S1 Ball is at LED 2 " " " " "
S2 Ball is at LED 3 " " " " "
S3 Ball is at LED 4 " " " " "
S4 Ball is at LED 5 " " " " "
S5 Ball is at LED 6 and bounces off the wall
S7 Ball is at LED 5 and is proceeding toward the players
S8 Ball is at LED 4 " " " " "
S9 Ball is at LED 3 " " " " "
S10 Ball is at LED 2 " " " " "
S11 Ball is at LED 1 and is proceeding past the players and is about to go off the court
S12 Ball is out of play

Question 1:

In what state will HZone = 1?

Question 2:

In what state will Game = 0?

Question 3:

Suppose the circuit is in state S12 (ball not in play). What do the inputs have to be before the circuit transitions to S0 (which corresponds to "game commences")?

Question 4:

Suppose the circuit is in state S11 (i.e., ball is at LED 1 and is proceeding past players). For what inputs will the circuit hold its state? For what inputs will the circuit transition to S12 (ball out of play)? For what inputs will the circuit transition to S1 (ball proceeds down the court)?

Task 4:

Draw the ASM chart for the Court Display circuit.

To design the Court Display, you will use the following parts: 74163 (synchronous 4-bit up counter), 2732, and the 74138 (3:8 decoder/demultiplexer), which is described below. The parts are connected as follows (Note that this is an old figure so the 2716 should be 2732).




The following is a brief description of the 74163 4-bit up counter , a generic 3-to-8 decoder, and the 74138 3-to-8 decoder. Recall that the 74163 is a 4-bit synchronous up counter. The fact that it's synchronous means that its state changes only at clock transitions. If its Clear input is 1 then its count (QD,QC,QB,QA) is cleared. If ENP and ENT are both 1 then the count is incremented by one (i.e., it counts). If the Load is 1 then the value at (D,C,B,A) is loaded into the counter. The 74163 is used as the state register.

A generic 3-to-8 decoder (or 3-to-8 demultiplexer or demux, or sometimes written as 3:8 demultiplexer or decoder, etc) has a single "data" input G1 (which is sometimes called the "enable" input), three select inputs (C,B,A), and eight outputs (Y0, Y1,..., Y7).

The select input value is a 3-bit number that determines which output that G1 will be connected to. For example, suppose (C,B,A) = (0,1,1). Since 011 corresponds to the value 3, the output Y3 is connected to G1. As another example, suppose (C,B,A) = (1,0,1). Then Y5 = G1. If an output is not selected then its value is 0. The following is the truth table of a 3-to-8 decoder.
	Inputs				  Outputs
Enable Select
G1 C B A Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
0 X X X 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 0 0 0 0
1 0 0 1 0 1 0 0 0 0 0 0
1 0 1 0 0 0 1 0 0 0 0 0
1 0 1 1 0 0 0 1 0 0 0 0
1 1 0 0 0 0 0 0 1 0 0 0
1 1 0 1 0 0 0 0 0 1 0 0
1 1 1 0 0 0 0 0 0 0 1 0
1 1 1 1 0 0 0 0 0 0 0 1

The 74138 3-to-8 decoder will be used to drive the six LEDs (i.e., LED 1, LED 2,... LED 6). It has the inputs A, B, C, G1, G2A, and G2B, and the outputs Y0, Y1, ..., Y7.  The '138 has two additional inputs: G2A and G2B. Both must be L for the decoder to work. Assuming both G2A and G2B are L, the following is the voltage table of the 74138.

	Inputs				  Outputs
Enable Select
G1 C B A Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
L X X X H H H H H H H H
H L L L L H H H H H H H
H L L H H L H H H H H H
H L H L H H L H H H H H
H L H H H H H L H H H H
H H L L H H H H L H H H
H H L H H H H H H L H H
H H H L H H H H H H L H
H H H H H H H H H H H L
It is a 3:8 decoder assuming positive logic at inputs and negative logic at outputs.

For the Court Display circuit, let d2, d1, d0 (from the 2716) be connected to C, B, A of the '138. The outputs Y1, Y2, ..., Y6 of the '138 correspond to L1, L2,..., L6, respectively. Hence, the outputs L1, L2,...., L6 have the negative logic convention. You should also have G1 = H, and G2A = L and G2B = L.

Question 5:

If the circuit is in state S0, what should the value of (d2,d1,d0) be?

Question 6:

If the circuit is in state S10, what should the value of (d2,d1,d0) be?

Question 7:

If the circuit is in state S12, what should the value of (d2,d1,d0) be?

Task 5:

Design the circuit in Logicworks. Use the following encoding for the states: S0, S1, S2.... is represented by 0000, 0001, 0010,..., respectively. Get a print out of your working circuit. Attach the truth table that you used to program the 2732.

(Hint: Suppose the circuit is in state S11, and Run = 1. If SwC = 0 then the player has missed the ball and the next state should be S12. On the other hand, if SwC = 1 then the player hits the ball and the next state should be S1, i.e., the ball is at LED 2 and proceeds down court. To get to S12, have the '163 continue counting. To get to S1, have the '163 load the encoding for S1, which is 0001. Hence, the value at (D,C,B,A) for the '163 should be LLLH.)

Task 6:

With your group, build the Court Display on the protoboard.

Task 7:

Now that you've built these modules, it'd be nice to see if they work. On your protoboard, connect the modules together as shown below to get a single player game (similar to paddleball). This helps to determine if your modules are interoperable. Demonstrate to the TA that your circuit works.

5. Racquetball 1 - The Sequal

You are to design, build, and demonstrate (to the TA) Racketball 1. This game has only one ball speed, so the Run input of the Court Display should be set to 1. The following is a block diagram of the complete Racketball 1 circuit.

Task 8:

Draw the ASM chart for the controller module. (Hint: Let the controller have two states, keeping track of who's turn it is to hit or serve.)

You are to design the circuit using D flip flops from the 74175, NANDs, NORs, and voltage inverters. You should minimize your circuit, since it should make your circuit simpler. Simpler circuits are easier to debug.

Task 9:

Construct Logicworks modules for the Racket Module and Court Display and store them in your library. Now build the controller in Logicworks. Connect the controller to the modules to get a complete Racketball 1 circuit. Get a print out of the circuit diagram. Turn in your working circuit on disk to the TA.

Task 10:

Build Racketball 1 on your protoboard. Demonstrate it to the TA when it's working.

6. Racquetball 2 - The Final Episode

Rackeball 1 was okay, but doesn't compare with the available hand held toys on the market. So we'd like to make the game a little more interesting by having two ball speeds: "slow" and "fast." The "slow" speed means that the ball advances every two clock periods, while the "fast" speed means that the ball advances every clock period (just like in Racketball 1). Note that you can control the rate at which the ball advances by using the Run input.

When the ball is served, it goes at the "slow" speed. When the ball returns from the wall and is at LED 1 (i.e., the state of the Court Display is S11), it will stay at LED 1 for two clock periods. If the player swings during the first clock period then the ball is returned at the "fast" speed. If the player swings during the second clock period then the ball is returned at the "slow" speed. Once the ball goes "fast", it stays fast until the game is over.

Task 11.

Draw another ASM chart for the controller to realize Racketball 2.

Task 12.

Build Racketball 2 in Logicworks. Use the Racket Module and Court Display LogicWorks modules that you have in your library. Get a print out of your circuit. If you used a 2732 in your controller, attach the truth table you used to program it.

Task 13.

Build Racketball 2 on your protoboard. Demonstrate it to the TA when it works.