We will design and construct a simple "bouncing ball " LED circuit using only a 22v10 and a LED bar-graph circuit. The circuit will behave like the following:
| clock | ||||||||
| C | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| C | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| C | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| C | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| C | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| C | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 |
| C | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| C | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
| C | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
| C | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
| C | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
To start, the CUPL software should be installed correctly. Check here to make sure.
To start the CUPL software package, type MCUPL at the DOS C: prompt in the CUPL directory.you should see this pop up:


It is a good idea to take the time and explore the different menu options to get familiar with navigation. The first thign to do is select the device ( Device Selection). Press <D> or select it using the arrow keys.At the next prompt choose the P22V10 device. It will then prompt for the package. We want the DIP (dual in-line) package.

Having picked the device, we will now create a new file for the bouncing LED device. At the main menu , choose <E>dit design file to start work on a new file.At the prompt, type in bounce.pld as the new file name and then press Enter. You should now be in the MS-DOS EDIT program.
The first thing to do is enter the header information The header information is used to keep track of the revisions and device selection. The format is:
| Name | Bounce; |
| Partno | 01; |
| Date | 1/16/97; |
| Rev | 01; |
| Designer | Joe Programmer; |
| Company | U. Penn; |
| Assembly | None; |
| Location | None; |
| Device | P22V10; |
The next thing to do is asign the pins to specific input and output variables. To start with, we will asign the P22v10 the following:
/**Inputs**/
Pin 1 = CLK;
Pin 2 = reset;
/**Outputs**/
Pin 15 = out3;
Pin 16 = out2;
Pin 17 = out1;
Pin 18 = out0;
Pin 19 = dir;
The next part for the design is to declare the states using define statements that have the same usage as in programming languages such as C. This is important for easy editing and readability of the code. If used correctly, define statements can relegate design changes to editing of the header statements.
The syntax for a define statement is the following:
We will use the define statement after the Pin declarations
$DEFINE S0 'b'1111
$DEFINE S1 'b'1110
$DEFINE S2 'b'1101
$DEFINE S3 'b'1011
$DEFINE S4 'b'0111
thus, when the file is run through the precompiler, the Sx values will be replaced with the binary values.
The next thing to do is declare the output FIELD. Look here to see more about the syntax.
FIELD count=[out3..0];
count.AR= reset;
count.SP= 'b'1111;
the .AR and .SP after count in the two following lines are known as extensions. Extensions control specific inputs to the type of flip-flop being used in the circuit.