cbmeeks wrote:
1) What language are you guys using to program these CPLD's? I've seen WinCUPL mentioned (I'm assuming CUPL is the language).
WinCUPL is the
lingua franca of Atmel CPLDs, and may also be used to program GALs. You can download WinCUPL
from here. I attached a copy of the CUPL reference manual.
Quote:
2) This CPLD will be used for glue logic but I'd like to learn a "hello world" with it by flashing some LED's. Are there any tutorials out there for something like that? I have actually searched online but *EVERYTHING* I find is centered around VHDL/Verilog and FPGA. Perhaps my search skills are failing me.
My suggestion would be to start by writing some simple combinatorial logic in WinCUPL so you can learn how to use the language and the tools. It's like anything else: you develop skill and insight by making mistakes and fixing them. Once you get the hang of it you can design something that will give you some blinkenlights.
Quote:
3) 64 macrocells doesn't sound like it can do much. But I admit, I'm still not 100% sure what a macrocell actually is. How many macrocells do you guys think would be needed for a BASIC VGA controller? Nothing fancy...just driving some pixels from SRAM. I'm planning for a future project where I will either use a larger CPLD or a small FPGA.
You'd be amazed how much you can fit into 64 macrocells. One of the things I learned was to let the fitter, which is the part of the software that actually synthesizes your design into a particular device, to assign the pins. If you assign pin numbers yourself you could develop a design that simulates but won't fit. The fitter generates a report (
<something>.fit) that will tell you what got assigned to what. You can then take that information and permanently assign pins in your source file so as to retain them in the event you make some minor changes. That's how I did POC V2's logic.
Note that the ATF1504AS has 32 uncommitted I/O pins. It is possible to use the JTAG pins as I/Os, but doing so will make it impossible to reprogram the device with the Atmel or Altera programmer. Also note that the 1504 has an assigned clock input (
GCLK1, on pin 43) and assigned reset input (
GCLR, on pin 1). These two should be permanently assigned in your CUPL source file, with statements such as the following:
Code:
pin 1 = RESB; /* system reset */
pin 43 = PHI2; /* system clock */
For other inputs and outputs, omit the actual pin number from the assignment, which will cause the fitter to work out the assignments for you. The fitter's goal is to minimize the use of logic resources, as well as actually fit the design to the particular device in use. It is certainly possible for one to do the work of the fitter by studying the internal structure of the part and then making the proper assignments. It's a very tedious process, however.
In addition to the
PIN assignment statement, there is also the
PINNODE statement, which doesn't use a pin number.
PINNODE is how you set up buried logic, e.g., flip-flops. For example:
Code:
pinnode = [blatch0..3]; /* bank address latches */
The above, which is from the source code for POC V2's logic, sets up four latches named
blatch to capture the 65C816's A16-A19 address components:
Code:
/*
========================
A16-A19 GENERATION LOGIC
========================
*/
[blatch0..3].LE = bavalid; /* open latches */
[blatch0..3].L = bavalid & [D0..3]; /* capture bank */
bank0 = [blatch0..3]:'b'0000; /* 1 if bank is $00 */
extram = !bank0; /* 1 if bank is not $00 */
In the above,
bavalid is a pin node that goes true when the '816 is emitting a valid bank address on D0-D7, that is, when the expression
(VDA # VPA) & !PHI2 is true, where
# is logical OR and
& is logical AND. The suffix
.LE opens a D-type latch and the suffix
.L refers to the latch content proper. All of this is explained in the CUPL reference manual.
At the beginning of your source file, you can insert some statements that affect how WinCUPL processes your logic and fits your design to the device:
Code:
property atmel {cascade_logic=on};
property atmel {logic_doubling=off};
property atmel {output_fast=off};
property atmel {pin_keep=on};
property atmel {preassign=keep};
property atmel {security=off};
property atmel {xor_synthesis=on};
All of this is explained in the help files. Start with the above settings and then play around with them to see how they affect the process. Note that the
output_fast property affects the slew rate of the CPLD's outputs. Play with it and observe and output with the 'scope to see what happens.
Your general workflow in WinCUPL is to create a project, write your CUPL code (CUPL means "compiled universal programming language") with the built-in editor, compile, fix any compilation errors, and then simulate your design. Within the simulator, you can set inputs, run the simulation and see how the outputs are affected. Once you are satisfied with your design you can run the Atmel ISP program to program your CPLD.
If you do a search here you should be able to find other posts about this stuff.