Categories: 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

Reviving an Amiga 600: From Dead Video to a Clean Boot

I managed to score an Amiga 600 motherboard which was faulty for £41. This weekend…

2 weeks ago

The Amiga 1200 That Fought Back: The Faults I Missed the First Time

I recently repaired an Amiga 1200 with a difficult to find fault. Unfortunately, it came…

3 weeks ago

Why Recapping Isn’t Always the Cure: And Amiga 1200 Repair Story

I often see on places such as Facebook that an Amiga owner will show a…

1 month ago

KDE Plasma Automatic Time Zone

I have been a full time KDE Plasma user for quite a while now. Whilst…

1 month ago

The wolfDemo Board Story: From Idea to Reality

I work building open-source cybersecurity solutions for wolfSSL. These solutions often involve embedded environments, which…

2 months ago

Upgrading the RAM Detective: A Firmware Adventure with RAMCHECK

The firmware in my RAMCHECK is very old, there were many updates since then. Unfortunately,…

5 months ago