48 July 2017
buttons; LEDs; and pin headers to access FPGA pins. There
is no integrated USB-Blaster (for FPGA programming),
but the package I bought also included an external
As for the real world tests, needless to say, the FPz8
didn’t work the first time! After thinking a bit and reading
compiler output messages, I figured out that it was
probably a timing issue. This is a very common dilemma
when designing with programmable logic, but as this
was my second FPGA design ever, I didn’t pay enough
attention to it.
Checking the timing analysis messages, I could see
a warning that the maximum clock should be around 24
MHz. At first, I tried using a divider-by- 2 to generate a
25 MHz CPU clock, but it wasn’t reliable. I then used a
divider-by- 3. Everything started to work perfectly!
That’s why FPz8 currently runs at 16.666 MHz. It is
possible to achieve higher speeds by using one of the
internal PLLs to multiply/divide the main clock in order to
get a resulting clock lower than 24 MHz, but higher than
Programming and Debugging
Using the FPz8 is very simple and straightforward.
Once the design is downloaded to the FPGA, the CPU
will start running any program loaded in memory. You can
supply a hex file and use the Mega Wizard Plug-in Manager
to change the program memory initialization file. That way,
your application code will start running following a reset
You can use the Zilog ZDS-II IDE to write Assembly
or C code, and generate the necessary hex files (I usually
select the Z8F1622 as my target device as it also has 2
KB of RAM and 16 KB of program memory). Thanks to
the on-chip debugger, it is also possible to use the ZDS-II
IDE to download code to the FPz8 using a serial debug
connection (USB, in our case).
Before connecting, make sure that debugger settings
are the same as in Figure 8. Uncheck the “Use page erase
before flashing” option, and select “SerialSmartCable”
as the current debug tool. Don’t forget to also check if
the FTDI’s virtual COM port is correctly selected as the
debug port (use the Setup button). You can set the desired
communication speed as well; 115,200 bps works very
well for me.
Note that when connecting to the FPz8, the ZDS-II
IDE will show a warning message informing you that the
target device is not the same as the project. That happens
because I didn’t implement some ID memory areas. Just
ignore the warning and proceed with the debugging
Once the code is successfully downloaded, you can
start the application (GO button), step instructions, inspect
or edit registers, set breakpoints, etc. As with any other
good debugger, you can, for example, select the PAOUT
register (under PORTS group) and even change the state of
the LEDs connected to PAOUT.
Some simple C code examples can be found at the
Just keep in mind that the FPz8 has a volatile program
memory. Thus, any program downloaded to it is lost when
the FPGA is powered down.
This project took me a couple weeks to complete, but
it was delightful to research and design a microcontroller
I hope this project can be useful for anyone wanting to
learn about computing basics, microcontrollers, embedded
programming, and/or VHDL. I believe that — if paired with
a low cost FPGA board — the FPz8 can provide a fantastic
learning (and teaching) tool. Have fun! NV
FIGURE 8. Debugger settings.
FIGURE 7. Altera Cyclone IV EP4CE6 mini board.