The Lab Book Pages

An online collection of electronics information

Dr. Andrew Greensted
Last modified: 31st July 2010

Hide Menu

Valid XHTML Valid CSS
Valid RSS VIM Powered
RSS Feed Icon

This site uses Google Analytics to track visits. Privacy Statement

Page Icon


The PicoBlaze is a simple 8 bit microprocessor core for Xilinx FPGAs. It's ideal as a replacement for a complex finite state machine.

Program Update without Resynthesis

This section describes how to update PicoBlaze code without having to resynthesise, place and route your design. The approach taken is:

  1. Use empty (non-initialised) program ROMs for each PicoBlaze in your design.
  2. Build the design, creating a bitfile.
  3. Assemble your PicoBlaze code.
  4. Alter the bitfile, initialising each program ROM with the correct data.
  5. Create a new bitfile including the PicoBlaze instruction data
  6. If you need to adjust your PicoBlaze code, go back to 3.

Step 1 - Non-Initialised Program ROMs

The PicoBlaze Program ROM component is implemented using a non-initialised Block RAM. The VHDL file below can be used for this task.

Non-initialised PicoBlaze Program ROM VHDL file

The ROM is instantiated as shown below. The instance name, in this case PicoROM, is used later in stage 4.

PicoROM : ProgramROM
port map (  clk            => clk,
            address        => pico_address,
            instruction    => pico_instruction);

Step 2 - Create your design

This is just the normal FPGA tool flow. You need to get right to the bitfile stage.

Step 3 - Assemble your PicoBlaze code

You need a PicoBlaze assembler that can generate a memory file of your assembled code. kpicosim will do this.

Personally, I prefer a simple command line assembler, such as picoasm. However, in order to get it to output a memory file a few minor tweaks to the source code are required.

> wget
> tar -zxf Picoasm_29mar08.tar.gz
> cd Picoasm
Replace cassembler.cpp with altered version (see link below)
> make

Altered cassembler.cpp for picoasm with memory file output

Note: If you get errors about strdup when trying to compile picoasm, you need to edit the file main.cpp. Change the include string to string.h on line 38.

Now if you assemble a PicoBlaze source file, you'll get a .mem file

Step 4 - Create new bitfile including PicoBlaze Instruction Data

The final step is to create a new bitfile with the memory file inserted into it. The script linked to below will do this for you.

Update Script bitUpdate.bash

The script uses some Xilinx ISE tools (xdl and data2mem), so you need to have sourced the Xilinx settings file to have these in your path. The script is invoked as follows:

> ./bitUpdate.bash PicoROM system.ncd pico.mem system.bit
PicoROM This is the instance name of the ProgramROM (see stage 1) connected to the PicoBlaze. This is required so the script can find which Block RAM within the FPGA is wired to the PicoBlaze.
system.ncd This file should have been generated in step 2. The file name depends on the ISE project name. You should be able to find it in the root of your ISE project directory. The file is first converted to a XDL file, which is then searched to find the BRAM location.
pico.mem This is the memory file created in stage 3
system.bit This is the main system bit file (created at stage 2). It will not be overwritten.

If everything runs OK, a new bitfile will be generated called download.bit. This can now ne used to configure the FPGA.

Note: This script only updates the ROM for one PicoBlaze, however, it can probably be run multiple times, once for each processor. However, you will have to make sure the bitfile read in, contains the previously inserted memory data.

Picoasm Build Problems

Compiling Picoasm (Version 29mar08) on 64bit machines can give some errors:

main.cpp: In function 'int main(int, char**)':
main.cpp:151: error: 'strdup' was not declared in this scope
main.cpp:158: error: 'strdup' was not declared in this scope
main.cpp:160: error: 'strrchr' was not declared in this scope
main.cpp:170: error: 'strdup' was not declared in this scope
main.cpp: In function 'bool printListing(std::string)':
main.cpp:261: error: 'strdup' was not declared in this scope
main.cpp:262: error: 'strrchr' was not declared in this scope

cassembler.cpp: In member function 'bool CAssembler::exportVHDL(std::string, std::string, std::string, bool)':
cassembler.cpp:587: error: 'strncmp' was not declared in this scope
cassembler.cpp:598: error: 'strcmp' was not declared in this scope

You can fix this by editing main.cpp and cassembler.cpp (If you are using the cassembler.cpp from above, you don't need to edit this file).

File Excerpt: main.cpp
#include "cassembler.h"
#include "cpicoblaze.h"
#include "cinstruction.h"

#include <string.h>     // CHANGE THIS LINE
#include <iostream>
#include <stdio.h>      // printf
#include <unistd.h>     // getopt
#include <libgen.h>     // dirname, basename
#include <strings.h>    // strcasecmp
File Excerpt: cassembler.cpp
#include "cassembler.h"

#include <stdio.h>
#include <string.h>     // ADD THIS LINE

Book Logo