Using Atmel WinCUPL
A PLD (programmable logic device) is a chip that can be programmed to replace a lot
of logic gates and flip-flops in a logic circuit. The PLD we will be using is the
ATF16V8B.
Notice from the diagram that there are 10 dedicated input pins (I0 – I9) and 8 pins that
can be either input or output (I/O0 – I/O7), plus two power supply pins.
When you are building a counter or anything else with a clock you must use pin 1 as
the clock.
Which pin do you connect to 0V?
Which pin do you connect to 5V?
Which pins can you use as outputs?
Which pins can only be used as inputs?
Getting started
Start → All Programs → Atmel WinCUPL → WinCUPL
If this is the first time you have used WinCUPL on this machine set it up so that it
stores your files in ‘My Documents’
Options → WinCUPL → General and Browse for your My Documents folder
Now start a new project. For the first project we are just going to make a NAND gate.
A
B
Q
File → New → Project
Make the Name something sensible like Nand
Put your name in the Designer box.
Make the device g16v8 to tell CUPL we are using an ATF16V8
Press OK
There are two input pins on your NAND gate so enter 2 and press OK
There is one output pin on your NAND gate
We are not going to use ant pinnodes so enter 0 and press OK
Now we need to say which pins we are using. The input pins must be pins 1-9 or 11,
the output pins must be pins 12-19.
We could use pins 5 and 6 as inputs and pin 15 as an output.
/* *************** INPUT PINS *********************/
PIN
5 = A
; /* Use pin 5 as first input */
PIN
6 = B
; /* Use pin 6 as second input */
/* *************** OUTPUT PINS *********************/
PIN 15 = Q
; /* Use pin 15 as output
*/
Note
“PIN 5=A;” is called a statement, every statement ends with a semicolon. Anything
between /* and */ is a comment. WinCUPL ignores comments; comments are there to
explain your code to others and to remind you what you were doing when you look at
code you wrote a few days ago.
You then need to type in the logic statement for the NAND gate so type
/* *************** LOGIC *********************/
Q = !(A&B);
Use the following table to understand the logic statement. Note
Operator
!
&
#
$
Description
NOT
AND
OR
XOR
Now compile the code to produce the file needed to program the chip.
Run → Device Dependent Compile
Or press
Using WinSim
You should now check the design works using a simulator. Start WinSim using
Utilities → WinSim
Or press
Use the project design you have just compiled using File → New
Click on
and file the file you just made NAND.PLD
then press
Now add signals using Signal → Add Signal Or press
Choose A then
choose B then
choose Q then
,
,
then press
There are four possible states with two inputs so you need to use four vector so add 3
more using Signal → Add Vector or press
and add 3 vectors.
Now set up the input signal make A1 low by right clicking in the box A1 and choose
drive input low or just left click on the bottom centre of box A1
Now drive input A2 high and then make the whole graph look like this
do not adjust the output Q
now simulate the design by Simulator → Run Simulator or press
OK
and press
Is the output correct?
Once you have done this practise your skills by designing and simulating a NOR gate.
Design a PLD to control a heating system in a school. The heating should come on in
the day when it is not hot and is not a holiday or a weekend. Use the underlined words
as inputs and outputs.
Designing a counter
You can use WinCUPL to design counters and other devices using flip-flops. One
way of designing a counter is to define a sequence.
Example – making a 1-6 dice
Start a new project named dice for a g16v8 with one input, four outputs and no nodes.
The input pin must be pin 1 as it is the clock
/* *************** INPUT PINS *********************/
PIN
1 = clk; /* Clock input
*/
You can define all the output pins together like this
/* *************** OUTPUT PINS *********************/
PIN
[12..15] = [Q0..Q3]; /* Binary outputs
*/
The [12..15] means pins 12 to 15 so pin 12=Q0, pin 13=Q1, pin 14=Q2, pin 15=Q3.
Now you do not need the other three PIN lines so delete them.
You can then refer to all of these pins as a single number using the FIELD statement
FIELD COUNT = [Q3..Q0];
So count is a number made of the binary digits Q3 (8s), Q2 (4s), Q1 (2s) and Q0 (1s).
You can then tell the chip how your sequence of numbers goes. The command
SEQUENCE is followed by curly brackets { } that contain the sequence.
SEQUENCE COUNT
PRESENT 0 NEXT
PRESENT 1 NEXT
PRESENT 2 NEXT
PRESENT 3 NEXT
PRESENT 4 NEXT
PRESENT 5 NEXT
PRESENT 6 NEXT
}
{
1;
2;
3;
4;
5;
6;
1;
Try typing in all these lines and compiling.
You should test the code using WinSIM. Start WinSIM
clk, Q0, Q1, Q2 and Q3 then press
and add the signals
.
Now add 8 vectors.
Right click your mouse in one of the cells on the clk row and Set Whole Signal to C,
this will make a square wave at the clock input. Now Simulate the design using
and check the output is correct.
Design a counter that counts just the odd numbers 1, 3, 5, 7, 9 and then go back to 1
and start again.
© Copyright 2026 Paperzz