Electronics

Compiling Xilinx CPLD Verilog in Linux Command Line

I mostly edit my Verilog files for basic Xilinx CPLD devices in vim, so it is a pain to launch the entire Xilinx IDE just to compile the thing. After doing a bit of research I managed to figure out how to compile from the command line too.

You need three things to make this method work, the Verilog file, the UCF file and a build script below. The Verilog should be named PROJECT.v and the UCF file PROJECT.ucf (where “PROJECT” is your project name). Here is the script which I save as build.sh:

#!/bin/bash

PROJECT=FLASH_KICKSTART
DEVICE=xc9572xl
PART=XC9572XL-10-VQ44

cat <<! >$PROJECT.xst
run
-ifn $PROJECT.v
-ifmt verilog
-ofn $PROJECT.ngc
-p $DEVICE
!
rm -rf xst/work
xst -ifn $PROJECT.xst
RESULT=$?
if [ $RESULT -ne 0 ]; then
    exit $RESULT
fi
ngdbuild -uc $PROJECT.ucf $PROJECT.ngc -p $DEVICE
cpldfit  -p $PART -ofmt vhdl -optimize speed $PROJECT
hprep6 -s IEEE1149 -n $PROJECT -i $PROJECT
hprep6 -s IEEE1532 -n $PROJECT -i $PROJECT

The last line of this is only useful if you need the .isc file. If you are just flashing the Xilinx IC then you only probably only need the .jed created by the first hprep6.

There are three variables you need to set here:

  • PROJECT is the name of the project that your files are named after.
  • DEVICE is the device family name, in my case that is “xc9572xl”
  • PART is the target part number, you can usually find exact names in /opt/Xilinx/14.7/ISE_DS/ISE/ and the “chp” files in the directory for the larger device family (in the xc9500xl directory in my case)

You should then set your PATH environment variable to include the Xilinx binary directory. In my case it is /opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64.

That’s it! Run the script and you will get a lot of console output, so it might be useful to direct to the output to a file if you want to analyse it. Lots of files will be generated including the all important .jed file for your favourite JTAG programmer.

LinuxJedi

Recent Posts

The Legend Continues: Amiga 1000 Keyboard Revival

I have restored the boxed Amiga 1000 main unit and the mice that came with…

2 days ago

Amiga 4000 Repair: This one was just weird

I was recently sent an Amiga 4000 motherboard repair. It should have been quite straightforward,…

3 days ago

Unboxing the Legend Continues: Amiga 1000 Mouse Restoration.

I recently received a boxed Amiga 1000 which was in excellent condition, but required a…

1 week ago

Unboxing a Legend: Amiga 1000

I have a local friend who is a private collector of vintage computers and consoles,…

2 weeks ago

Amiga 4000 With Lots of Little Problems

I’ve had a few people send me things in to repair lately. Amongst these was…

2 months ago

Amiga A3640 CPU Card Repair

Lately, I've been very busy, but haven't had many interesting things to blog about happen.…

2 months ago