Grlib IP Library User's Manual
Grlib IP Library User's Manual
1.3 Overview
The GRLIB IP Library is an integrated set of reusable IP cores, designed for system-on-chip (SOC)
development. The IP cores are centered around a common on-chip bus, and use a coherent method for
simulation and synthesis. The library is vendor independent, with support for different CAD tools and
target technologies. A unique plug&play method is used to configure and connect the IP cores with-
out the need to modify any global resources.
AMBA AHB
AMBA APB
AHB Memory AHB/APB
Controller Controller Bridge
VGA PS/2 UART Timers IrqCtrl I/O port
PROM I/O SRAM SDRAM Video PS/2 IF RS232 WDOG 32-bit I/O port
DAC
31 24 23 12 11 10 9 5 4 0
Configuration word
31 20 19 16 15 4 3 0
The configuration word for each device includes a vendor ID, device ID, version number, and inter-
rupt routing information. The BARs contain the start address for an area allocated to the device, a
mask defining the size of the area, information whether the area is cacheable or pre-fetchable, and a
type declaration identifying the area as an AHB memory bank, AHB I/O bank or APB I/O bank. The
configuration record can contain up to four BARs and the core can thus be mapped on up to four dis-
tinct address areas.
1.9 Portability
GRLIB is designed to be technology independent, and easily implemented on both ASIC and FPGA
technologies. Portability support is provided for components such as single-port RAM, two-port
RAM, dual-port RAM, single-port ROM, clock generators and pads. The portability is implemented
by means of virtual components with a VHDL generic to select the target technology. In the architec-
ture of the component, VHDL generate statements are used to instantiate the corresponding macro
cell from the selected technology library. For RAM cells, generics are also used to specify the address
and data widths, and the number of ports.
1.12 Licensing
The main infra-structure of GRLIB is released in open-source under the GNU GPL license. This
means that designs based on the GPL version of GRLIB must be distributed in full source code under
the same license. For commercial applications where source-code distribution is not desirable or pos-
sible, Cobham Gaisler offers low-cost commercial IP licenses. Contact [email protected] for more
information or visit http://www.gaisler.com/.
or
NOTE: Do NOT use WinZip on the .tar.gz file, this will corrupt the files during extraction!
GRLIB uses the GNU ‘make’ utility to generate scripts and to compile and synthesis designs. It must
therefore be installed on a UNIX system or in a ‘UNIX-like’ environment. Tested hosts systems are
Linux and Windows with Cygwin.
2.2 Upgrading
When migrating from earlier GRLIB releases the steps below should be followed in order to mini-
mize the number of possible conflicts when upgrading:
•The new package should be extracted in its own directory. Do not overwrite the existing GRLIB tree with
the new package.
•Added designs and IP cores should be copied into the new tree.
•All existing scripts (file lists) should be removed and then re-generated using the appropriate make targets
in the new GRLIB tree.
•The Changelog (available in the doc/ directory) of the new library should be studied. Check for new fea-
tures or VHDL generics that have been deprecated compared to the previous version that was used.
Other vendor-specific directories are also delivered with GRLIB, but are not necessary for the under-
standing of the design concept. Libraries and IP cores are described in detail in separate documenta-
tion. Many of the tech/* directories are populated by performing simulation library installation. This
is described in section 2.5.
3.2 Overview
Implementing a LEON3 system is typically done using one of the template designs on the designs
directory. For this tutorial, we will use the LEON3 template design for the GR-XC3S-1500 board.
Implementation is typically done in three basic steps:
• Configuration of the design using xconfig
• Simulation of design and test bench
• Synthesis and place&route
The template design is located in designs/leon3-gr-xc3s-1500, and is based on three files:
• config.vhd - a VHDL package containing design configuration parameters. Automatically generated by the
xconfig GUI tool.
• leon3mp.vhd - contains the top level entity and instantiates all on-chip IP cores. It uses config.vhd to config-
ure the instantiated IP cores.
• testbench.vhd - test bench with external memory, emulating the GR-XC3S-1500 board.
Each core in the template design is configurable using VHDL generics. The value of these generics is
assigned from the constants declared in config.vhd, created with the xconfig GUI tool.
AMBA AHB
AMBA APB
AHB Memory AHB/APB
Controller Controller Bridge
VGA PS/2 UART Timers IrqCtrl I/O port
3.4 Simulation
The template design can be simulated in a test bench that emulates the prototype board. The test
bench includes external PROM and SDRAM which are pre-loaded with a test program. The test pro-
gram will execute on the LEON3 processor, and tests various functionality in the design. The test pro-
gram will print diagnostics on the simulator console during the execution.
The following command should be give to compile and simulate the template design and test bench
using Mentor ModelSim/QuestaSim or Aldec Riviera-PRO (simulator is selected based in the
GRLIB_SIMULATOR environment variable, default is ModelSim):
make sim
make sim-launch
Make targets also exist for other simulators. See documentation of tools in this document or issue
make help to view a list of available targets.
Some designs require that the environment variable GRLIB_SIMULATOR is set to the simulator to
use in order for all parts of the design to be built correctly (in particular template designs for Xilinx
devices that make use of the Xilinx MIG). Refer to the design’s README.txt file and section 4.3 of
this document for additional information.
A typical simulation log can be seen below.
$ make sim-run
The test program executed by the test bench consists of two parts, a simple PROM boot loader
(prom.S) and the test program itself (systest.c). Both parts can be re-compiled using the make soft
command. This requires that the BCC tool-chain is installed on the host computer. The BCC tool-
chain by default includes AMBA plug&play scanning routines that are able to scan over AHB
bridges. This is seldom required for system tests and simulation time is decreased by the default
assignment of the environment variable LDFLAGS to LDFLAGS=-qnoambapp. The default assign-
ment can be avoided by defining the LDFLAGS variable.
The simple PROM boot loader (prom.S) contains code to initialize the processor, memory controller
and other peripherals. If the file prom.S is missing from the template design folder then a default ver-
sion located at software/leon3/prom.S will be used. Configuration constants used by prom.S are
located in the file prom.h. If the memory controller in a design is changed, or the base address of main
memory is moved, then prom.h and possibly prom.S may need to be updated to correctly initialize the
new configuration. If prom.h or prom.S are modified then make soft is required before the changes
take effect.
Note that the simulation is terminated by generating a VHDL failure, which is the only way of stop-
ping the simulation from inside the model. An error message is then printed:
# Test passed, halting with IU error mode
# ** Failure: *** IU in error mode, simulation halted ***
# Time: 1104788 ns Iteration: 0 Process: /testbench/iuerr File: testbench.vhd
# Stopped at testbench.vhd line 338
In both cases, the final programming file will be called ‘leon3mp.bit’. See the GRLIB User’s Manual
chapter 3 for details on simulation and synthesis script files.
For interactive programming, use Xilinx Impact software. See the GR-XC3S-1500 Manual for details
on which configuration PROMs to specify.
A pre-compiled FPGA bit file is provided in the bitfiles directory, and the board can be re-pro-
grammed with this bit file using:
make ise-prog-prom-ref
initialising ..............
detected frequency: 40 MHz
Component Vendor
LEON3 SPARC V8 Processor Gaisler Research
AHB Debug UART Gaisler Research
AHB Debug JTAG TAP Gaisler Research
SVGA frame buffer Gaisler Research
GR Ethernet MAC Gaisler Research
AHB ROM Gaisler Research
AHB/APB Bridge Gaisler Research
LEON3 Debug Support Unit Gaisler Research
DDR266 Controller Gaisler Research
Generic APB UART Gaisler Research
Multi-processor Interrupt Ctrl Gaisler Research
Modular Timer Unit Gaisler Research
Keyboard PS/2 interface Gaisler Research
Keyboard PS/2 interface Gaisler Research
To download an application, use the ‘load’ command. To run it, use ‘run’ :
load stanford.exe
run
The console output will occur in the grmon window if grmon was started with -u, otherwise it will be
send to the RS232 connector of the board.
The GRLIB files are accessed through the environment variable GRLIB. This variable can either be
set in the local shell or in a local makefile, since the ‘make’ utility is used to automate various com-
mon tasks. A GRLIB-specific makefile is located in bin/Makefile. To avoid having to specify the
GRLIB makefile using the -f option, the local makefile should includes the GRLIB makefile:
GRLIB=../../grlib
include $(GRLIB)/bin/Makefile
Running ‘make help’ with this makefile will print a short menu:
$ make help
interactive targets:
make avhdl-launch : start active-hdl gui mode
make riviera-launch : start riviera
make vsim-launch : start modelsim
make ncsim-launch : compile design using ncsim
make actel-launch-synp : start Actel Designer for current project
make ise-launch : start ISE project navigator for XST project
make ise-launch-synp : start ISE project navigator for synplify project
make quartus-launch : start Quartus for current project
make quartus-launch-synp : start Quartus for synplify project
make synplify-launch : start synplify
make vivado-launch : start Vivado project navigator
make planahead-launch : start PlanAhead project navigator
make xgrlib : start grlib GUI
batch targets:
The local makefile is primarily used to generate tool-specific compile scripts and project files, but can
also be used to compile and synthesize the current design. To do this, additional settings in the make-
file are needed. The makefile in the design template grlib/designs/leon3mp can be seen as an exam-
ple:
$ cd grlib/designs/leon3mp
$ cat Makefile
GRLIB=../..
TOP=leon3mp
BOARD=gr-pci-xc2v
include $(GRLIB)/boards/$(BOARD)/Makefile.inc
DEVICE=$(PART)-$(PACKAGE)$(SPEED)
UCF=$(GRLIB)/boards/$(BOARD)/$(TOP).ucf
QSF=$(BOARD).qsf
EFFORT=1
VHDLSYNFILES=config.vhd leon3mp.vhd
VHDLSIMFILES=testbench.vhd
SIMTOP=testbench
SDCFILE=$(GRLIB)/boards/$(BOARD)/default.sdc
BITGEN=$(GRLIB)/boards/$(BOARD)/default.ut
CLEAN=local-clean
include $(GRLIB)/bin/Makefile
The table below summarizes the common (target independent) ‘make’ targets:
4.3.1 Overview
The ‘make scripts’ command will generate compile scripts and/or project files for the Model/Questa-
Sim, Riviera, NCsim, Xilinx and gHDL simulators. This is done by scanning GRLIB for simulation
files according to the method described in “GRLIB organisation” on page 145. These scripts are then
used by further make targets to build and update a GRLIB-based design and its test bench. The local
makefile should set the VHDLSYNFILES to contain all synthesizable VHDL files of the local design.
Likewise, the VHDLSIMFILES variable should be set to contain all local design files to be used for
simulation only. The variable TOP should be set to the name of the top level design entity, and the
variable SIMTOP should be set to the name of the top level simulation entity (e.g. the test bench).
VHDLSYNFILES=config.vhd ahbrom.vhd leon3mp.vhd
VHDLSIMFILES=testbench.vhd
TOP=leon3mp
SIMTOP=testbench
The variables must be set before the GRLIB makefile is included, as in the example above.
All local design files are compiled into the VHDL work library, while the GRLIB cores are compiled
into their respective VHDL libraries.
The following simulators are currently supported by GRLIB:
Simulator Comments
GNU VHDL (GHDL) version 0.25, VHDL only
Aldec Active-HDL batch and GUI
Aldec Riviera batch and GUI
Mentor Modelsim version version 10.5 or later
Cadence NcSim IUS-5.8-sp3 and later
Xilinx ISIM ISE-14 or later
Xilinx XSIM Vivado 2016.4 or later
Synopsys VCS version 2017.03-SP2 or later
Value Comment
ALDEC Aldec Riviera Pro or Aldec ActiveHDL
ALDEC_RWS Aldec Riviera Pro Workspace (WS) flow, see section 4.7.7.
ModelSim Mentor ModelSim SE or QuestaSim
ModelSim-PE ModelSim PE
ModelSim-SE Alias for ModelSim
Questa Mentor QuestaSim
Xilinx Xilinx XSim/ISim
The TOP variable should be set to the top level entity name to be synthesized. TECHNOLOGY,
PART, PACKAGE and SPEED should indicate the target device parameters. VHDLSYNFILES
should be set to all local design files that should be used for synthesis. SDCFILE should be set to the
(optional) Synplify constraints file, while XSTOPT should indicate additional XST synthesis options.
The UCF variable should indicate the Xilinx constraint file, while QSF should indicate the Quartus
constraint file. The EFFORT variable indicates the Xilinx place&route effort and the BITGEN vari-
able defines the input script for Xilinx bitfile generation.
The technology related variables are often defined in a makefile include file in the board support
packages under GRLIB/boards. When a supported board is targeted, the local makefile can include
the board include file to make the design more portable:
BOARD=gr-pci-xc2v
include $(GRLIB)/boards/$(BOARD)/Makefile.inc
SDCFILE=$(GRLIB)/boards/$(BOARD)/$(TOP).sdc
UCF=$(GRLIB)/boards/$(BOARD)/$(TOP).ucf
DEVICE=$(PART)-$(PACKAGE)-$(SPEED)
Note that the batch targets for invoking the synthesis tools typically do not depend on the complete
file list. If one of the local design files is modified then the tool will typically be re-run on the whole
design. If a design file in a GRLIB library is modified then it may be necessary to run the command
‘make distclean’ to remove the currently generated files in order to resynthesize the full design using
the batch targets.
include $(GRLIB)/bin/Makefile
By default, all technology cells and mapping wrappers are included in the scripts and later compiled.
To select only one or a sub-set of technologies, the variable TECHLIBS can be set in the makefile:
TECHLIBS = unisim
The table below shows which libraries should added to TECHLIBS for each supported technology.
Note that availability of technology mappings for the technologies listed above varies with type of
GRLIB distribution. Contact Cobham Gaisler for details.
It is also possible to skip compliation of the simulation libraries (located in the tech/ directory in the
GRLIB file tree). This can be useful if prebuilt libraries should used since these may otherwise be
overwritten when compiling the full GRLIB file list. In order to skip compliation of simulation librar-
ies set:
SKIP_SIM_TECHLIBS=1
This will prevent files under lib/tech/ from being built. Note that technology map files under lib/tech-
map may depend on libraries in lib/tech/ and that any prebuilt libraries should be mapped before com-
piling the GRLIB files.
File Description
compile.ghdl Compile script for GRLIB files
make.ghdl Makefile to rebuild local design
gnu Directory with compiled models
SIMTOP Executable simulation model of test bench
To rebuild the local design, run make ncsim again. This will use the ncupdate utility to rebuild out-of-
date files. The tables below summarizes the make targets and the files creates by make scripts.
File Description
compile.ncsim Compile script for GRLIB files
make.ncsim Makefile to rebuild GRLIB and local design
xncsim Directory with compiled models
File Description
TOP_rtl_fpro.fl FormalPro filelist of project RTL files. TOP in the filename is replaced
with the top-level design name, typically leon3mp or leon4mp.
File Description
compile.vsim Compile script for GRLIB files
make.work Makefile to rebuild GRLIB and local design
modelsim Directory with compiled models
SIMTOP.mpf Modelsim project file for compilation and simulation
File Description
compile.asim Compile script for GRLIB files (batch mode)
make.asim Compile script for GRLIB files and local design (batch mode)
activehdl Directory with compiled models (batch mode)
work Directory with compiled models (GUI mode)
avhdl.tcl Active-HDL tcl file for compilation and simulation (GUI mode)
File Description
make.riviera Riviera script for GRLIB_SIMULATOR=ALDEC
riviera_ws_create.do Rivera script file for simulation (GUI mode)
File Description
make.simv Makefile to rebuild GRLIB and local design
simv Directory with compiled models
The synthesis script will set the following mapping option by default:
set_option -symbolic_fsm_compiler 0
set_option -resource_sharing 0
set_option -use_fsm_explorer 0
set_option -write_vhdl 1
set_option -disable_io_insertion 0
File Description
compile.synp Tcl compile script for all GRLIB files
TOP_synplify.prj Synplify project file
synplify Directory with netlist and log files
The environment variable PRECISIONOPT can be set in to pass arguments to Precision. For exam-
ple, to always start with RTL+ the following line can be added to the design Makefile:
PRECISIONOPT=-rtlplus
File Description
TOP_precision.tcl Tcl compile script to create Precision project file
TOP_precision.psp Precision project file
precision Directory with netlist and log files
File Description
TOP_designer.tcl Batch script for Actel Designer place&route
The environment variables used by the Designer flow are listed in the table below. Note that the input
to designer is typically a netlist generated by Synplify. This means that the environment variables
listed in section 4.7.9 also affect the flow.
Note for Libero IDE: Note that when Synplify is launched from Libero the first time, the constraints
file defined in the local Makefile is not included in the project, and must be added manually. Before
simulation is started first time, the file testbench.vhd in the template design should be associated as
stimuli file.
File Description
TOP_libero.prj Libero IDE project file
TOP_libero.tcl Script that generates Libero SoC project
TOP_libero_genbit.tcl Script for generating programming file
TOP_libero_progfpga.tcl Script for programming FPGA
TOP_libero/TOP.prjx Libero SoC project file generated by running TOP_libero.tcl
The environment variables used by the Libero IDE flow are listed in the table below. The variables
used for the Libero SoC flow is listed in a table further down.
The environment variables used by the Libero SoC flow are listed in the table below.
File Description
TOP.qpf Project file for Quartus-only flow
TOP_synplify.qpf Project file for EDIF flow
File Description
compile.xst XST synthesis include script for all GRLIB files
TOP.xst XST synthesis script for local design
TOP.npl ISE 8 project file for XST flow
TOP.ise ISE 9/10project file for XST flow
TOP.xise ISE 11/12/13/14 XML project file for XST flow
TOP_synplify.npl ISE 8 project file for EDIF flow
The environment variables used by the ISE 11/12/13/14 flow are listed in the table below.
The make scripts command will create compile scripts for the PlanAhead tool, useful with ISE-14
and above. When executing make planahead-launch, the compile scripts will be used to launch the
PlanAhead project manager. Synthesis and place&route can also be run in batch mode (preferred
option) using make planahead.
Many Xilinx FPGA boards are supported in GRLIB, and can be re-programmed using make ise-prog-
fpga and make ise-prog-prom. The first command will only re-program the FPGA configuration, while
the second command will reprogram the configuration proms (if available). Programming will be
done using the ISE Impact tool in batch mode.
It is possible to specify Bitgen options to be used in the PlanAhead flow. This is done via the PLA-
NAHEAD_BITGEN environment variable. If this variable is set then the contents will be used to
specify additional Bitgen options in the PlanAhead flow.
File Description
compile.planahead PlanAhead synthesis include script for all GRLIB files
planAhead.tcl PlanAhead script for creating a PlanAhead project and to build the
project.
The environment variables used by the PlanAhead flow are listed in the table below.
File Description
compile.vivado Vivado synthesis include script for all GRLIB files
vivado.tcl Vivado script for creating a PlanAhead project and to build the project.
The environment variables used by the Vivado flow are listed in the table below.
$ cat leon4mp_dc.tcl
sh mkdir synopsys
set objects synopsys
#set trans_dc_max_depth 1
#set hdlin_seqmap_sync_search_depth 1
#set hdlin_nba_rewrite false
set hdlin_ff_always_sync_set_reset true
set hdlin_ff_always_async_set_reset false
#set hdlin_infer_complex_set_reset true
#set hdlin_translate_off_skip_text true
set suppress_errors VHDL-2285
#set hdlin_use_carry_in true
source compile.dc
analyze -f VHDL -library work config.vhd
analyze -f VHDL -library work ahbrom.vhd
analyze -f VHDL -library work clkgate.vhd
analyze -f VHDL -library work qmod.vhd
analyze -f VHDL -library work qmod_prect.vhd
analyze -f VHDL -library work leon4mp.vhd
elaborate leon4mp
The script can be run with dc_shell-xg-t via the command make dc. The created script will analyze and
elaborate the local design. Compilation and mapping will not be performed, the script should be seen
as a template only. The default script can be overriden by setting the DCSCRIPT variable. Additional
command line flags can be passed to dc_shell-xg-t via the DCOPT variable.
The created script will analyze and elaborate the local design, and save it to a Verilog file. Compila-
tion and mapping will not be performed, the script should be seen as a template only.
The GRLIB technology map for eASIC Nextreme2 makes extensive use of eASIC’s RAM and pad
generators, and also of wrappers for the DDR2 PHY. When eASIC’s IP library has been imported into
GRLIB (via the import-easic-n2x make target), the normal technology map components (pads, mem-
ory, DDR2 PHY) can be used.
The GRLIB SYNCRAM* components map to both rFiles and bRAMs. The conditions for selecting
between these RAM types may need to be adjusted for each design in order to not over-utilize one or
the other. The selection between rFiles and bRAMs is made with the function n2x_use_rfile(..) that is
defined in the file lib/techmap/nextreme2/memory_n2x_package.vhd.
The technology map also includes a clock generator map for eASIC PLLs. However it is strongly rec-
ommended to use eASIC’s IP generators instead and directly instantiate the Nextreme2 PLLs in the
design.
4.8.1 Introduction
NOTE: Some template designs require commands to be issued to install special libraries or to gener-
ate parts of the design. These special commands are not available in XGrlib and must instead be given
via the command line interface.
XGrlib serves as a graphical front-end to the makefile system described in the previous chapters. It is
written in tcl/tk, using the Visual-tcl (vtcl) GUI builder. XGrlib allows to select which CAD tools will
be used to implement the current design, and how to run them. XGrlib should be started in a directory
with a GRLIB design, using make xgrlib. Other make variables can also be set on the command line,
as described earlier:
make xgrlib SYNPLIFY=synplify_pro GRLIB=”../..”
Since XGrlib uses the make utility, it is necessary that all used tools are in the execution path of the
used shell. The tools are divided into three categories: simulation, synthesis and place&route. All
tools can be run in batch mode with the output directed to the XGrlib console, or launched interac-
tively through each tool’s specific GUI. Below is a figure of the XGrlib main window:
4.8.2 Simulation
The simulator type can be selected through the left menu button in the frame marked ‘Simulation’.
There are seven options available: modelsim, ncsim, GHDL, libero, riviera, active-hdl, and active-hdl
batch. Once the simulator has been selected, the design can be compiled by pressing the green ‘Build’
button. The simulator can then be launched interactively by pressing the ‘Run’ button. If the ‘Batch’
check-button has been set, the ‘Run’ button will run the default test bench in batch mode with the out-
put displayed in the console frame. The ‘Clean’ button will remove all generated file for the selected
tool.
Note: on windows/cygwin platforms, launching modelsim interactively can fail due to conflict of cyg-
win and modelsim tcl/tk libraries.
5.2.1 General
The AMBA Advanced High-performance Bus (AHB) is a multi-master bus suitable to interconnect
units that are capable of high data rates, and/or variable latency. A conceptual view is provided in fig-
ure 5. The attached units are divided into master and slaves, and controlled by a global bus arbiter.
BUS
CONTROL
SLAVE 1 SLAVE 2
Since the AHB bus is multiplexed (no tristate signals), a more correct view of the bus and the attached
units can be seen in figure 6. Each master drives a set of signals grouped into a VHDL record called
ahbmo. The output record of the current bus master is selected by the bus multiplexers and sent to the
input record (ahbsi) of all AHB slaves. The output record (ahbso) of the active slave is selected by the
bus multiplexer and forwarded to all masters. A combined bus arbiter, address decoder and bus multi-
plexer controls which master and slave are currently selected.
ahbmo(1)
MASTER 1
MASTER 2
ahbso(2)
SLAVE 2
BUS ARBITER,
MULTIPLEXER,
& DECODER
ahbmo(3)
MASTER 3
ahbmi
The elements in the record types correspond to the AHB master signals as defined in the AMBA 2.0
specification, with the addition of three sideband signals: HIRQ, HCONFIG and HINDEX. A typical
AHB master in GRLIB has the following definition:
entity ahbmaster is
generic (
hindex : integer := 0); -- master bus index
port (
reset : in std_ulogic;
clk : in std_ulogic;
ahbmi : in ahb_mst_in_type; -- AHB master inputs
ahbmo : out ahb_mst_out_type -- AHB master outputs
);
end entity;
The input record (AHBMI) is routed to all masters, and includes the bus grant signals for all masters
in the vector AHBMI.HGRANT. An AHB master must therefore use a generic that specifies which
HGRANT element to use. This generic is of type integer, and typically called HINDEX (see example
above).
The elements in the record types correspond to the AHB slaves signals as defined in the AMBA 2.0
specification, with the addition of four sideband signals: HSEL, HIRQ, HCONFIG and HINDEX. A
typical AHB slave in GRLIB has the following definition:
library grlib;
use grlib.amba.all;
library ieee;
use ieee.std_logic.all;
entity ahbslave is
generic (
hindex : integer := 0); -- slave bus index
port (
reset : in std_ulogic;
clk : in std_ulogic;
abhsi : in ahb_slv_in_type; -- AHB slave inputs
ahbso : out ahb_slv_out_type -- AHB slave outputs
);
end entity;
The input record (ahbsi) is routed to all slaves, and include the select signals for all slaves in the vec-
tor ahbsi.hsel. An AHB slave must therefore use a generic that specifies which hsel element to use.
This generic is of type integer, and typically called HINDEX (see example above).
5.2.6.1 Overview
The cores in GRLIB and the GRLIB infrastructure can be configured to support an AMBA AHB data
bus width of 32, 64, 128, or 256 bits. The default AHB bus width is 32 bits and AHB buses with data
vectors having widths over 32 bits will in this section be referred to as wide AHB buses.
Changing the AHB bus width can increase performance, but may also increase the area requirements
of a design, depending on the synthesis tool used and the type of cores instantiated. Manual modifica-
tion of the GRLIB CONFIG package is required to enable support for wide AHB buses. Alternatively,
a local version of the GRLIB CONFIG package can be placed in the current template design, overrid-
ing the settings in the global GRLIB CONFIG package.
When modifying the system's bus width, care should be taken to verify that all cores have been instan-
tiated with the correct options with regards to support for wide buses.
Note that the APB bus in GRLIB will always be 32-bits, regardless of the AHB data bus width.
5.3.1 General
The GRLIB implementation of the AHB bus includes a mechanism to provide plug&play support.
The plug&play support consists of three parts: identification of attached units (masters and slaves),
address mapping of slaves, and interrupt routing. The plug&play information for each AHB unit con-
sists of a configuration record containing eight 32-bit words. The first word is called the identification
register and contains information on the device type and interrupt routing. The last four words are
called bank address registers, and contain address mapping information for AHB slaves. The remain-
ing three words are currently not assigned and could be used to provide core-specific configuration
information.
31 24 23 12 11 10 9 5 4 0
04 USER-DEFINED
08 USER-DEFINED
0C USER-DEFINED
BAR0 10 HADDR
ADDR 00 P C MASK
MASK TYPE
31 20 19 18 17 16 15 4 3 0
TYPE
P = Prefetchable
C = Cacheable 0001 = APB I/O space
0010 = AHB Memory space
0011 = AHB I/O space
The plug&play information for all attached AHB units appear as a read-only table mapped on a fixed
address of the AHB, typically at 0xFFFFF000. The configuration records of the AHB masters appear
in 0xFFFFF000 - 0xFFFFF800, while the configuration records for the slaves appear in 0xFFFFF800
- 0xFFFFFFFC. Since each record is 8 words (32 bytes), the table has space for 64 masters and 64
slaves. A plug&play operating system (or any other application) can scan the configuration table and
automatically detect which units are present on the AHB bus, how they are configured, and where
they are located (slaves).
The top four words of the plug&play area (0xFFFFFFF0 - 0xFFFFFFFF) may contain device specific
information such as GRLIB build ID and a (SoC) device ID. If present, this information shadows the
bank address registers of the last slave record, limiting the number of slaves on one bus to 63. All sys-
tems that use the GRLIB AHB controller have the library’s build ID in the least significant half-word,
and a (SoC) device ID in the most significant half-word, of the word at address 0xFFFFFFF0. The
contents of the top four words is described in the AHB controller’s IP core manual.
The configuration record from each AHB unit is sent to the AHB bus controller via the HCONFIG
signal. The bus controller creates the configuration table automatically, and creates a read-only mem-
ory area at the desired address (default 0xFFFFF000). Since the configuration information is fixed, it
can be efficiently implemented as a small ROM or with relatively few gates. A debug module, present
within the AHB bus controller, can be used to print the configuration table to the console during sim-
ulation, which is useful for debugging. A typical example is provided below:
Vendor ID
Cobham Gaisler 0x01
Pender Electronic Design 0x02
European Space Agency 0x04
Astrium EADS 0x06
OpenChip.org 0x07
OpenCores.org 0x08
Various contributions 0x09
DLR 0x0A
Eonic BV 0x0B
Telecom ParisTech 0x0C
DTU Space 0x0D
Vendor ID
Barcelona Supercomputing Center 0x0E
Radionor 0x0F
Gleichmann Electronics 0x10
Menta 0x11
Sun Microsystems 0x13
Movidia 0x14
Orbita 0x17
Siemens AG 0x1A
Synopsys 0x21
NASA 0x22
NIIET 0x23
S3 0x31
Thales Alenia Space 0xA5
Recore Systems BV 0xA6
Microsemi/Actel Corporation 0xAC
Applecore 0xAE
TU Braunschweig C3E 0xC3
CBK PAN 0xC8
Caltech 0xCA
Ceton 0xCB
SSTL 0xD6
Embeddit 0xEA
NASA GSFC 0xFC
AZST 0xFE
Vendor ID 0x00 is reserved to indicate that no core is present. Unused slots in the configuration table
will have Identification Register set to 0. IP cores added to GRLIB must only use vendor ID 0x09 to
prevent that the user IP core is detected as an IP core from another vendor. Vendor IDs for organiza-
tions can be requested via e-mail to [email protected].
An AHB slave can have up to four address mapping registers, thereby decode four independent areas
in the AHB address space. HSEL is asserted when any of the areas is selected. To know which partic-
ular area was selected, the ahbsi record contains the additional bus signal HBSEL(0:3). The elements
in HBSEL(0:3) are asserted if the corresponding to BAR(0-3) caused HSEL to be asserted. HBSEL is
only valid when HSEL is asserted. For example, if BAR1 caused HSEL to be asserted, the HBSEL(1)
will be asserted simultaneously with HSEL.
5.3.4 Cacheability
In processor-based systems without an MMU, the cacheable areas are typically defined statically in
the cache controllers. The LEON processors build the cachebility table automatically during synthe-
sis, using the cacheability information in the AHB configuration records. In this way, the cacheability
settings always reflect the current configuration.
For systems with an MMU, the cacheability information can be read out by from the configuration
records through software. This allows the operating system to build an MMU page table with proper
cacheable-bits set in the page table entries.
The same applies to the output of each slave which includes all 32 interrupt signals in the vector
ahbso.hirq. An AHB slave must therefore use a generic that specifies which HIRQ element to drive.
This generic is of type integer, and typically called HIRQ (see example below).
component ahbslave
generic (
hindex : integer := 0; -- slave index
hirq : integer := 0); -- interrupt index
port (
rst : in std_ulogic;
clk : in std_ulogic;
hslvi : in ahb_slv_in_type; -- AHB slave inputs
hslvo : out ahb_slv_out_type); -- AHB slave outputs
end component;
slave2 : ahbslave
generic map (hindex => 2, hirq => 2)
port map (rst, clk, hslvi, hslvo(1));
The AHB bus controller in the GRLIB provides interrupt combining. For each element in HIRQ, all
the ahbmo.hirq signals from the AHB masters and all the ahbso.hirq signals from the AHB slaves are
logically OR-ed. The combined result is output both on ahbmi.hirq (routed back to the AHB masters)
and ahbsi.hirq (routed back to the AHB slaves). Consequently, the AHB masters and slaves share the
same 32 interrupt signals.
An AHB unit that implements an interrupt controller can monitor the combined interrupt vector
(either ahbsi.hirq or ahbmi.hirq) and generate the appropriate processor interrupt.
5.4.1 General
The AMBA Advanced Peripheral Bus (APB) is a single-master bus suitable to interconnect units of
low complexity which require only low data rates. An APB bus is interfaced with an AHB bus by
means of a single AHB slave implementing the AHB/APB bridge. The AHB/APB bridge is the only
APB master on one specific APB bus. More than one APB bus can be connected to one AHB bus, by
means of multiple AHB/APB bridges. A conceptual view is provided in figure 8.
AHB SLAVE 2
AHB SLAVE 1
APB MASTER
APB BUS
Since the APB bus is multiplexed (no tristate signals), a more correct view of the bus and the attached
units can be seen in figure 9. The access to the AHB slave input (AHBI) is decoded and an access is
made on APB bus. The APB master drives a set of signals grouped into a VHDL record called APBI
which is sent to all APB slaves. The combined address decoder and bus multiplexer controls which
slave is currently selected. The output record (APBO) of the active APB slave is selected by the bus
multiplexer and forwarded to AHB slave output (AHBO).
APBO(2)
SLAVE 2
AHB SLAVE
APB MASTER
AHBO
The elements in the record types correspond to the APB signals as defined in the AMBA 2.0 specifi-
cation, with the addition of three sideband signals: PCONFIG, PIRQ and PINDEX. A typical APB
slave in GRLIB has the following definition:
library grlib;
use grlib.amba.all;
library ieee;
use ieee.std_logic.all;
entity apbslave is
generic (
pindex : integer := 0); -- slave bus index
port (
rst : in std_ulogic;
clk : in std_ulogic;
apbi : in apb_slv_in_type; -- APB slave inputs
apbo : out apb_slv_out_type -- APB slave outputs
);
end entity;
The input record (APBI) is routed to all slaves, and include the select signals for all slaves in the vec-
tor APBI.PSEL. An APB slave must therefore use a generic that specifies which PSEL element to
use. This generic is of type integer, and typically called PINDEX (see example above).
5.5.1 General
The GRLIB implementation of the APB bus includes the same type of mechanism to provide
plug&play support as for the AHB bus. The plug&play support consists of three parts: identification
of attached slaves, address mapping, and interrupt routing. The plug&play information for each APB
slave consists of a configuration record containing two 32-bit words. The first word is called the iden-
tification register and contains information on the device type and interrupt routing. The last word is
the bank address register (BAR) and contains address mapping information for the APB slave. Only a
single BAR is defined per APB slave. An APB slave is neither prefetchable nor cacheable.
31 24 23 12 11 10 9 5 4 0
31 20 19 18 17 16 15 4 3 0
All addressing of the APB is referenced to the AHB address space. The 12 most significant bits of the
AHB bus address are used for addressing the AHB slave of the AHB/APB bridge, leaving the 20 least
significant bits for APB slave addressing.
The plug&play information for all attached APB slaves appear as a read-only table mapped on a fixed
address of the AHB, typically at 0x---FF000. The configuration records of the APB slaves appear in
0x---FF000 - 0x---FFFFF on the AHB bus. Since each record is 2 words (8 bytes), the table has space
for 512 slaves on a signle APB bus. A plug&play operating system (or any other application) can scan
the configuration table and automatically detect which units are present on the APB bus, how they are
configured, and where they are located (slaves).
The configuration record from each APB unit is sent to the APB bus controller via the PCONFIG sig-
nal. The bus controller creates the configuration table automatically, and creates a read-only memory
area at the desired address (default 0x---FF000). Since the configuration information is fixed, it can
be efficiently implemented as a small ROM or with relatively few gates. A debug module, present
within the APB bus controller, can be used to print the configuration table to the console during simu-
lation, which is useful for debugging
As an example, to decode an 4 kByte AHB I/O bank at address 0x---24000, the ADDR field should be
set to 0x240, and the MASK to 0xFF0. Note that the 12 most significant bits of AHBI.HADDR are
io0 : apbio
generic map (pindex => 1, paddr => 16#240#, pmask => 16#FF0#)
port map (rst, clk, apbi, apbo(1));
slave3 : apbslave
generic map (pindex => 1, pirq => 2)
port map (rst, clk, pslvi, pslvo(1));
The AHB/APB bridge in the GRLIB provides interrupt combining, and merges the APB-generated
interrupts with the interrups bus on the AHB bus. This is done by OR-ing the 32-bit interrupt vectors
from each APB slave into one joined vector, and driving the combined value on the AHB slave output
bus (AHBSO.HIRQ). The APB interrupts will then be merged with the AHB interrupts. The resulting
interrupt vector in available on the AHB slave input (AHBSI.HIRQ), and is also driven on the APB
slave inputs (APBI.PIRQ) by the AHB/APB bridge. Each APB slave (as well as AHB slave) thus sees
the combined AHB/APB interrupts. An interrupt controller can then be placed either on the AHB or
APB bus and still monitor all interrupts.
Constant Description
CFG_AHBDW Selects the maximum AHB data width to be used in the system
CFG_AHB_ACDM Enable AMBA compliant data multiplexing in cores that support
this.
GRLIB_CONFIG_ARRAY Array of configuration values that enable different types of func-
tionality in the library. The available values together with short
descriptions can be seen in the file lib/grlib/stdlib/config_-
types.vhd. The available settings are also described in table 58.
GRLIB_CONFIG_ARRAY(Constant) Description
grlib_debug_level Controls (simulation) debug output from TECHMAP layer
grlib_debug_mask
grlib_techmap_strict_ram Defines if struct RAM TECHMAP should be used. Otherwise
small (shallow) RAMs may be mapped to inferred technology.
Not supported by all target technologies.
grlib_techmap_testin_extra Expand testin vector to SYNCRAM components with additional
bits (value defines number of additional bits).
grlib_sync_reset_enable_all Add synchronous reset to all registers (requires support in
instantiated IP cores). Synchronization registers will not have
resets added.
Note that IP cores may have VHDL generics that override the
library settings.
grlib_async_reset_enable Add asynchronous reset to all registers (requires support in
instantiated IP cores, see IP core manual). This option must not
be enabled together with grlib_sync_reset_enable_all.
Asynchronous reset will not be used for synchronization regis-
ters and for registers where the reset state depends on external
input signals.
Note that IP cores may have VHDL generics that override the
library settings.
grlib_syncramft_autosel_disable Disables automatic override of ECC implementation in syn-
cramft wrappers (GRLIB-FT only).
grlib_syncram_selftest_enable Enables data monitors on syncram blocks.
grlib_external_testoen Disable testoen multiplexing in IP cores. Not supported by all IP
cores.
grlib_amba_inc_nirq Increase maximum number of interrupts
Total number of interrupt lines: (32 + grlib_amba_inc_irq*32)
Note: Should be left at 0 at present time. > 32 interrupts is not
supported by all IP cores and it is not supported by the GRLIB
plug&play version 0.
grlib_little_endian Reserved for future use.
5.7.1 General
GRLIB provides portability support for both ASIC and FPGA technologies. The support is imple-
mented by means of encapsulation of technology specific components such as memories, pads and
clock buffers. The interface to the encapsulated component is made technology independent, not rely-
ing on any specific VHDL or Verilog code provided by the foundry or FPGA manufacturer. The inter-
face to the component stays therefore always the same. No modification of the design is therefore
required if a different technology is targeted. The following technologies are currently supported by
the TECHMAP.GENCOMP package:
constant inferred : integer := 0;
constant virtex : integer := 1;
constant virtex2 : integer := 2;
constant memvirage : integer := 3;
constant axcel : integer := 4;
constant proasic : integer := 5;
constant atc18s : integer := 6;
constant altera : integer := 7;
constant umc : integer := 8;
constant rhumc : integer := 9;
constant apa3 : integer := 10;
constant spartan3 : integer := 11;
constant ihp25 : integer := 12;
constant rhlib18t : integer := 13;
constant virtex4 : integer := 14;
constant lattice : integer := 15;
constant ut25 : integer := 16;
constant spartan3e : integer := 17;
constant peregrine : integer := 18;
constant memartisan : integer := 19;
constant virtex5 : integer := 20;
constant custom1 : integer := 21;
constant ihp25rh : integer := 22;
constant stratix1 : integer := 23;
constant stratix2 : integer := 24;
constant eclipse : integer := 25;
constant stratix3 : integer := 26;
constant cyclone3 : integer := 27;
constant memvirage90 : integer := 28;
constant tsmc90 : integer := 29;
constant easic90 : integer := 30;
constant atc18rha : integer := 31;
constant smic013 : integer := 32;
constant tm65gpl : integer := 33;
constant axdsp : integer := 34;
constant spartan6 : integer := 35;
constant virtex6 : integer := 36;
constant actfus : integer := 37;
constant stratix4 : integer := 38;
constant st65lp : integer := 39;
constant st65gp : integer := 40;
constant easic45 : integer := 41;
constant cmos9sf : integer := 42;
constant apa3e : integer := 43;
constant apa3l : integer := 44;
constant ut130 : integer := 45;
constant ut90 : integer := 46;
constant gf65 : integer := 47;
constant virtex7 : integer := 48;
constant kintex7 : integer := 49;
constant artix7 : integer := 50;
constant zynq7000 : integer := 51;
constant rhlib13t : integer := 52;
constant saed32 : integer := 53;
constant dare : integer := 54;
constant igloo2 : integer := 55;
constant smartfusion2: integer := 55;
constant rhs65 : integer := 56;
constant rtg4 : integer := 57;
Each encapsulating component provides a VHDL generic (normally named TECH) with which the
targeted technology can be selected. The generic is used by the component to select the correct tech-
This synchronous single-port RAM component is used in the AHB RAM component shown in the
following code example.
component ahbram
generic (
hindex : integer := 0; -- AHB slave index
haddr : integer := 0;
hmask : integer := 16#fff#;
memtech : integer := 0; -- memory technology
kbytes : integer := 1); -- memory size
port (
rst : in std_ulogic;
clk : in std_ulogic;
hslvi : in ahb_slv_in_type; -- AHB slave input
hslvo : out ahb_slv_out_type); -- AHB slave output
end component;
ram0 : ahbram
generic map (hindex => 1, haddr => 16#240#, hmask => 16#FF0#,
tech => virtex, kbytes => 4)
port map (rst, clk, hslvi, hslvo(1));
In addition to the selection of technology (VIRTEX in this case), the size of the AHB RAM is speci-
fied in number of kilo-bytes. The conversion from kilo-bytes to the number of address bits is per-
formed automatcally in the AHB RAM component. In this example, the data width is fixed to 32 bits
and requires no generic. The VIRTEX constant used in this example is defined in the TECH-
MAP.GENCOMP package.
The following generic memory components are available in the TECHMAP library:
5.7.5 Pads
As for memory cells, the pads used in a design are always technology dependent. The TECHMAP
library provides a set of encapsulated components that hide all the technology specific details from
the user. In addition to the VHDL generic used for selecting the technology (normally named TECH),
generics are provided for specifying the input/output technology levels, voltage levels, slew and driv-
ing strength. A typical open-drain output pad is shown in the following code example:
component odpad
generic (
tech : integer := 0;
level : integer := 0;
slew : integer := 0;
voltage : integer := 0;
strength : integer := 0
);
port (
pad : out std_ulogic;
o : in std_ulogic
pad0 : odpad
generic map (tech => virtex, level => pci33, voltage => x33v)
port map (pad => pci_irq, o => irqn);
The TECHMAP.GENCOMP package defines the following constants that to be used for configuring
pads:
-- input/output voltage
-- pad types
The slew control and driving strength is not supported by all target technologies, or is often imple-
mented differently between different technologie. The documentation for the IP core implementing
the pad should be consulted for details.
5.8.1 Overview
Scan test is a method for production testing digital ASICs. A test mode is added to the design that
changes all flip-flops in the design to shift registers that can be set and read out serially. This is imple-
mented partially in RTL code and partially in the implementation flow.
In a typical GRLIB ASIC, a number of signals are added for scan test. All signals except testen are
usually muxed with other slow I/O signals so only one pin has to be added to the design.
The signals added are:
testen - Enables test mode (top-level pin)
scanen - Muxes flip-flop data inputs to previous in chain instead of normal function
testoen - Controls all output-enables in test mode
testrst - Controls all async-resets in test mode
scanin - Scan chain inputs
scanout - Scan chain outputs
The top level of the design adds the testen signal to the port list and muxes in the scanen, testoen and
testrst signals. The scanin and scanout signals are not handled at the RTL level.
At the RTL level, the test signals are connected to any hard macro that needs them, such as block
RAM:s and PLL:s. Also testoen and testrst are handled fully at source code level. The RTL also con-
tains logic so that all flip-flops are directly clocked by an input clock pin when test mode is enabled.
During synthesis, the synthesis tool implements registers using special "scan flip-flops" containing
the necessary muxing for the scan chain. The actual scan chain connections are not derived until after
placement, so the scan order can be selected to minimize routing.
Note that if the mapping for a technology drives customoutx, it must also set the syncram_has_cus-
tomif entry in gencomp.vhd, otherwise the customout vector is driven with all-zero to avoid undriven
signal warnings in synthesis:
nocust: if syncram_has_customif(tech)=0 generate
customoutx <= (others => ’0’);
end generate;
Some mappings, such as syncrambw and syncramft, may in some cases instantiate multiple syncram
blocks internally. For such mappings, the customin/out vectors’ widths is multiplied by the maximum
number of sub-instances in order to provide a unique in/out vector for each block. Depending on how
many blocks are actually instantiated, the top part of the vector may be unused (only the (custombits *
Nsyncrams) lowest bits are used).
entity ipcore is
port(
...
mtesti : in ipcore_memtest_type := grpci2_memtest_none;
mtesto : out ipcore_memtest_type;
mtestclk : in std_ulogic := ‘0’
);
end;
architecture rtl of ipcore is
end;
5.10.1 Introduction
GRLIB contains test software that is intended to be run on a LEON processor in simulation. The col-
lection of test software contains tests for both the LEON processors and peripheral units.
The test software is intended as a system level sanity check that verifies that IP cores have been cor-
rectly connected to the system. It does not provide in general full coverage of the IP cores. Higher
coverage is achieved through the use of standalone test benches. For communication interfaces, some
of the test software requires simulation models of external functions, such as transceivers. In this case
the test software is also used to check that an off-chip interface has been correctly connected.
One way of generating the output would be to use the accelerated UART tracing that can be enabled
for GRLIB's APBUART and use printf() to output the status messages. In order to reduce simulation
time, the test output is instead generated by a test module. This test module monitors write accesses
and performs different functions based on the addresses and values written by the processor. The
available test modules include:
•AHBREP - AMBA slave test module. Connects as an AHB slave to the AHB bus
•SDRTESTMOD - SDRAM test module. Connects to external SDRAM interface and monitors it for test mod-
ule output.
•GRTESTMOD - Connects to system via a memory controllers memory-mapped IO interface.
The default address for the test module is at offset 0x20000000. This is the address traditionally used
for memory-mapped IO in LEON/GRLIB systems. When the system test software is built with
default settings the use of the report* functions will cause write operations to the memory area at
0x20000000. If nothing, or if another IP core, is mapped at this address then the test program is likely
going to fail and at least will not show any output. The base address for the test module can be
The default behaviour for the test program is to use 32-bit accesses. In case the GRTESTMOD is used
and is connected to a 16-bit wide interfaces then the test software can be built to use half-word
accesses instead through the define GRLIB_REPORTDEV_WIDTH. As an example, for a 16-bit wide
memory-mapped IO interface with base address 0xD0000000, the following BOPT settings should be
used:
BOPT=-DGRLIB_REPORTDEV_BASE=0xD0000000 -DGRLIB_REPORTDEV_WIDTH=16
Will be replaced by versions that do not depend on the presence of a test module. Reporting will
instead be used through calls to printf(). Note that tests that depend on simulation models of, for
example, external transceivers will not function in standalone mode.
FPGA
Vendor FPGA Board Template design name
Altera Altera Stratix-II Development boardS leon3-altera-ep2s60-sdr,
leon3-altera-ep2s60-ddr,
leon3-altera-ep2sgx90-av
Altera Altera Cyclone-III Starter Kit leon3-altera-ep3c25
Altera Altera Cyclone-III Multimedia board leon3-altera-ep3c25-eek
Altera Altera CycloneV E Development kit leon3-altera-c5ekit
Altera Altera Stratix-III FPGA Development kit leon3-altera-ep3sl150
Altera Arrow BE Micro SDK Cyclone IV board leon3-arrow-bemicro-sdk
Altera TerASIC DE-4 Development and Education leon3-terasic-de4
board
Altera TerASIC DE2-115 Cyclone-IV board leon3-terasic-de2-115
Altera TerASIC DE2 Cyclone II board leon3-altera-de2-ep2c35
Altera TerASIC DE0-Nano board leon3-terasic-de0-nano
Altera TerASIC SoCKit leon3-terasic-sockit
Microsemi Actel Fusion Advanced Development kit leon3-actel-fusion
Microsemi Actel ProASIC3L Starter Kit leon3-actel-proasic3l
Microsemi Actel CoreMP7 Developers Kit leon3-actel-proasic3
Microsemi Microsemi IGLOO2 Evaluation Kit leon3-microsemi-m2gl-eval-kit
Microsemi ProASIC3 MCC-C Board leon3-gr-mcc-c
Microsemi GR-CPCI-AX board leon3-rtax-cid*
Microsemi RTG4 Development Kit leon3-microsemi-rtg4-devkit-es
Microsemi SmartFusion2 Evaluation Kit leon3-microsemi-m2s090ts-eval-kit
Microsemi SmartFusion2 Advanced Development Kit leon3-microsemi-m2s150ts-adv-kit
Xilinx Avnet Spartan3-1500 board leon3-avnet-3s1500
Xilinx Avnet Virtex4 Evaluation board leon3-avnet-eval-xc4vlx25,
leon3-avnet-eval-xc4vlx60
Xilinx Digilent Virtex2pro XUP board leon3-digilent-xup
Xilinx Digilent Basys3 board leon3-digilent-basys3
Xilinx Digilent Nexys 3 board leon3-digilent-nexys3
Xilinx Digilent Nexys 4 board leon3-digilent-nexys4
Xilinx Digilent Nexys 4 DDR board leon3-digilent-nexys4ddr
Xilinx Digilent Nexys Video board leon3-digilent-nexys-video
Xilinx Digilent Spartan3 Starter board leon3-digilent-xc3s1000
Xilinx Digilent Spartan3E Development board leon3-digilent-xc3s1600e
Xilinx Digilent Spartan6 Atlys board leon3-digilent-atlys
Xilinx Digilent XC7Z020 leon3-digilent-xc7z020
Xilinx Nuhorizons Spartan3-1500 board leon3-nuhorizons-3s1500
Xilinx Pender/Gaisler GR-XC3S1500/2000 board leon3-gr-xc3s-1500
Xilinx Pender/Gaisler GR-PCI-XC2V3000 board No longer supported.
Xilinx Pender/Gaisler GR-CPCI-XC2V6000 board No longer supported
Xilinx Pender/Gaisler GR-CPCI-XC4VLX100/200 leon3-gr-cpci-xc4v
board
FPGA
Vendor FPGA Board Template design name
Xilinx Pender/Gaisler GR-PCI-XC5VLX50/110 leon3-gr-pci-xc5v
board
Xilinx Pender/Gaisler GR-XC6S-LX75 Spartan6 leon3-gr-xc6s
board
Xilinx Pender/Gaisler GR-CPCI-XC7K board leon3-gr-cpci-xc7k
Xilinx Xilinx ML401 / ML402 / ML403 / ML501 / leon3-xilinx-ml40x, leon3-xilinx-ml403,
ML505 / ML506 / ML507 / ML510 boards leon3-xilinx-ml501, leon3-xilinx-ml50x,
leon3-xilinx-ml510
Xilinx Xilinx Spartan3A DSP-1800 Starter Platform leon3-xilinx-xc3sd-1800
Xilinx Xilinx SP601 Spartan6 Evaluation kit leon3-xilinx-sp601
Xilinx Xilinx SP605 Spartan6 Evaluation kit leon3-xilinx-sp605
Xilinx Xilinx ML605 Virtex-6 Development board leon3-xilinx-ml605
Xilinx Xilinx AC701 Artix-7 Evaluation kit leon3-xilinx-ac701
Xilinx Xilinx VC707 Virtex-7 Evaluation kit leon3-xilinx-vc707
Xilinx Xilinx KC705 Kintex Evaluation kit leon3-xilinx-kc705
Xilinx Xilinx Zynq ZC702 leon3-xilinx-zc702
Xilinx ZTEX USB-FPGA Module 1.11 leon3-ztex-ufm-111
Xilinx ZTEX USB-FPGA Module 1.15 leon3-ztex-ufm-115
The number of LEON3 processors in this design example can be selected by means of the NCPU
generic shown in the entity declaration excerpt above.
signal leon3i : l3_in_vector(0 to NCPU-1);
signal leon3o : l3_out_vector(0 to NCPU-1);
signal irqi : irq_in_vector(0 to NCPU-1);
signal irqo : irq_out_vector(0 to NCPU-1);
signal l3dbgi : l3_debug_in_vector(0 to NCPU-1);
signal l3dbgo : l3_debug_out_vector(0 to NCPU-1);
The debug support and interrupt handling is implemented separately for each LEON3 instantiation in
a multi-processor system. The above signals are therefore declared in numbers corresponding to the
NCPU generic.
signal apbi : apb_slv_in_type;
signal apbo : apb_slv_out_vector := (others => apb_none);
signal ahbsi : ahb_slv_in_type;
signal ahbso : ahb_slv_out_vector := (others => ahbs_none);
signal ahbmi : ahb_mst_in_type;
signal ahbmo : ahb_mst_out_vector := (others => ahbm_none);
The multiple LEON AMBA interfaces do not need any special handling in this example, and the AHB
master/slave are therefore declared in the same way as in the previous example.
----------------------------------------------------------------------
--- LEON3 processor and DSU -----------------------------------------
----------------------------------------------------------------------
cpu : for i in 0 to NCPU-1 generate
u0 : leon3s -- LEON3 processor
generic map (hindex => i, fabtech => FABTECH, memtech => MEMTECH,
fpu => fpu, dsu => dbg, disas => disas,
pclow => pclow, tbuf => 8*dbg,
v8 => 2, mac => 1, nwp => 2, lddel => 1,
The multiple LEON3 processors are instantiated using a generate statement. Note that the AHB index
generic is incremented with the generate statement. Note also that the complete AHB slave input is
fed to the processor, to allow for cache snooping.
There is only one debug support unit (DSU) in the design, supporting multiple LEON3 processors.
There is also only one interrupt controller, supporting multiple LEON3 processors.
To prepare the design for simulation with ModelSim, move to the grlib/designs/leon3mp directory
and execute the ‘make vsim’ command.
$ make vsim
TECHLIBS = $(shell grep FABTECH config.vhd | grep -o "[^ ]*$$" | sed -e 's/;//g')
inferred grdware dware secureip unisim
DCOPT = -x "set argv [lindex [list $(TECHLIBS)] 0]; set top $(TOP)"
DCSCRIPT=dc.tcl
FMOPT = -x "set argv [lindex [list $(TECHLIBS)] 0]; set top $(TOP)"
FMSCRIPT=fm.tcl
Only the variable VSIMGTLOPT are local and the variables DCOPT, DCSCRIPT, FMOPT,
FMSCRIPT and VSIMOPT are all integrated GRLIB variables.
The synthesis script calls the scripts timing.tcl for general timing constraints, report.tcl to report tim-
ing and design exceptions found during synthesis and ASIC technology setup and timing scripts are
located in the directory grlib/designs/leon3asic/grtechscripts.
For every ASIC technology a setup and timing script is required. The setup script grtechscripts/
<techmap_name>_setup.tcl specify the ASIC library location and which cells to use during the syn-
thesis. The timing script grtechscripts/<techmap_name>_timing.tcl specify clocks, timing margin
and operation condition to be used for ASIC technology.
After launching System Builder, write “hpms” as name for the system (see figure below) and click
“OK”. The System Builder GUI will be opened.
In the first “Device Features” tab, check the boxes as in the figure below, and click on “Next”. SERS-
ESIF_0 must be checked only if Ethernet has been enabled during design configuration (Step 2).
The configuration in the figure above will enable the DDR memory controller, connected to the
onboard Mobile DDR memory, the embedded Non-Volatile Memory, used to store the processor boot-
code, and the peripheral DMA controller.
In the following section, i.e., Memories, select the MDDR tab and click on “Import Configuration”.
Import the lpddr_config file, located in <GRLIB path>/boards/microsemi-m2gl-eval-kit/. In the
same tab select “LPDDRI” as I/O standard (see figure below).
In the ENVM tab select “Data Storage” and click “Add to system”. A window will appear in order to
setup the content of the eNVM. The eNVM is by default mapped at address 0x0 in the LEON3 pro-
cessor bus, thus it can be used to store the boot code. In the “Add Data Storage Client” window, write
a name for the client, select “prom.srec” file (located in the template design directory) and:
select Motorola-S as format;
check Use Absolute addressing;
check Use content for simulation;
select 32 bits as word size (see figure below).
In the Clocks tab, select the on-chip 50MHz oscillator as clock source, 160 MHz for HPMS and
MDDR clocks, and 80 MHz for all the other fields (see figure below). FIC_0 clock is used as system
clock for the entire processor subsystem in the FPGA fabric.
In the HPMS Options tab, setup the values for the HPMS AHB bus matrix and the DDR Bridge. In
particular, the DDR Bridge is used by the HPDMA module to transfer data to/from the external DDR
memory, exploiting a second interface of the MDDR controller. The DDR Bridge includes internal
buffers to cache last reads/writes. In particular, some write operations will be performed on the DDR
memory only after a timeout period, which invalidates the content of the writes buffer. Since each
MDDR port uses different read/writes buffers, if an access to the DDR memory is made during this
period through the other MDDR port (i.e., the one directly connected to the processor subsystem bus),
wrong data will be read. To always ensure data coherency, set the Nonbufferable region size equal to
the DDR memory size (see figure below).
In the SECDED tab, disable the MDDR ECC interrupt (see figure below).
The last two tabs of System Builder are not relevant for this HPMS component generation flow for
the target design. At the end of the generation process, a new component (hpms_sb_0) will appear in
the Smart Design view (see figure below).
The Smart Design window will show the architecture of the hpms_sb component (see figure below).
The IGLOO2 HPMS is represented by the hpms_sb_HPMS_0 component.
It can be noted that three instances of CoreAHBLite are present. These components are included by
default in order to access the MDDR and FIC interfaces of the HPMS. Custom wrappers are then
needed to interface the LEON3 subsystem to the CoreAHBLite interfaces. A slightly more efficient
approach is to use custom wrappers (already instantiated in the design top entity leon3mp) to access
directly the AHBLite interfaces shown by the MDDR and FIC. The three CoreAHBLite instances can
be removed from the block diagram. AMBA_MASTER_0, HPMS_FIC_0_USER_MASTER,
HPMS_FIC_0_HPDMA_CONTROLLER_MASTER, HPMS_FIC_0_SYS_SERVICES_MASTER
and AMBA_SLAVE_0 ports will be disconnected and must be also removed. Finally, MDDR_D-
DR_AHB0_SLAVE, FIC_0_AHB_SLAVE and FIC_0_AHB_MASTER ports of the hpms_sb_H-
PMS_0 component must be promoted to the top level (right-click on the port name and select
Promote to Top Level). The hpms_sb SmartDesign view should be similar to the one shown in the
next figure.
Click on Generate Component button in the SmartDesign toolbar and return to the SmartDesign win-
dow associated to the top level component generated through System Builder.
A warning sign is shown in the unique instance. Right-click on it and select Update instance with lat-
est component to update its I/O ports. Then, all the I/O ports of the component that are not connected
must be promoted to the top-level by right-clicking on the port name and selecting Promote to top
level. Power_on_reset_n port must be marked as unused. If SERDESIF_0 has been enabled, two
additional ports will be shown on the component (i.e. FAB_CCC_GL3 and FAB_CCC_LOCK).
These ports must be marked as unused.
After I/O promotion, the Smart Design view must look as shown in the figure below. By clicking on
Generate component button, the VHDL files associated to the customized components will be cre-
ated.
6.6.2.10 Step 10: Add generated component files to simulation and synthesis
Before simulating and synthesizing the design, a last step is required. In the Design Flow window,
right-click on Simulate, under Verify Pre-Synthesized Design, and select Organize Input Files > Orga-
nize Source Files. In the Organize Source Files window, select the files associated to the previously
generated HPMS component (left side), and add them to the simulation sources (right side) by click-
ing on the Add button (see figure below). The files that must not be added to simulation are:
· osc_comps.vhd;
· osc_comps_pre.vhd;
· hpms_sb_HPMS_pre.vhd;
· hpms_sb_HPMS_syn.vhd.
6.6.2.11 Step 11: SERDES I/F - ONLY if SERDES I/F is enabled in the design configuration
This step is only needed if SERDES is enabled and the pregenerated IP component is not used.
In the Design Flow window in Libero SoC, double-click on Create Smart Design. Write igl_ser-
des_epcs as component name (see figure below).
Search for High Speed Serial Interface in the Catalog tab (see figure below) and drop it into the Smart
Design view. Righ-tclick on the component in the Smart Design view and select Configure to setup
the SERDES interface in SGMII mode. In the High Speed Serial Interface Configuration window (see
second figure below) select:
· Simulation Level : RTL
· Type: EPCS
· Number of Lanes: x1 – Lane 3
· Reference Clock Source: REFCLK1 (Differential)
· PHY RefClk Frequency: 125 MHz
· Data Rate: 1250 Mbps (10 bit)
A new component will be generated in Smart Design view. Sets the ports of the component as in the
figure below.
In particular:
· tielow EPCS_3_PWRDN, EPCS_3_TX_OOB and EPCS_3_RX_ERR;
· tiehigh EPCS_3_TX_VAL;
6.6.2.12 Step 12: Add generated component files to simulation and synthesis
Open the igl_serdes_epcs component in the “Design Hierarchy” tab and click on Generate Compo-
nent button to generate the associated HDL files.
In the Design Flow tab of Libero SoC, right-click on Simulate, under Verify Pre-Synthesized Design,
and select Organize Input Files > Organize Source Files. In the Organize Source Files window, select
the two files associated to the previously generated SERDES component (the ones highlighted in the
figure below), and add them to the simulation sources (right side) by clicking on the Add button.
In the Design Flow tab of Libero SoC, right-click on Synthesize, and select Organize Input Files >
Organize Source Files. In the Organize Source Files window, select only the files associated to the
previously generated SERDES component (the ones highlighted in the figure below), and add them to
the synthesis sources (right side) by clicking on the Add button.
6.6.2.13 Step 13
With the previous steps completed, the implementation flow in Libero SoC can be executed by run-
ning:
I. Synthesis;
II. Compile;
III. Place and Route;
IV. Verify Timing (in this step carefully check for setup/hold violations in the generated reports);
V. Generate Bitstream;
VI. Run Program Action.
Simulation of the pre-synthesized design can be launched right-clicking on Simulate under Verify
Pre-Synthesized Design (in the Design Flow tab), and selecting Open Interactively.
6.6.3 leon3-microsemi-m2s090ts-eval-kit
The steps below are described based on Libero v11.5-SP2. The flow is expected to be similar in later
versions of Libero SoC.
The template design also contains a pregenerated Microsemi IP. Use of this IP is enabled via xconfig
under the menu Synthesis > Use pregenerated Microsemi IP. If that option is enabled then the steps
described below to generate the system can be skipped and synthesis can be started immediately (skip
step6 to 12). The pregenerated IP has been built using Libero 11.7 SP1. If the xconfig option Synthe-
sis > Use pregenerated Microsemi IP is set to n before the Libero project is generated the pregener-
ated IP is included in the project as a SmartDesign and can be configured.
After launching System Builder, write “mss” as name for the system (see figure below) and click
“OK”. The System Builder GUI will be opened.
In the first “Device Features” tab, check the boxes as in the figure above, and click on “Next”. SERS-
ESIF_0 must be checked only if Ethernet has been enabled during design configuration (Step 2).
The configuration in the figure above will enable the DDR memory controller, connected to the on-
board Mobile DDR memory, the embedded Non-Volatile Memory, used to store the processor boot-
code, and the peripheral DMA controller.
In the following section, i.e., Memories, select the MDDR tab and click on “Import Configuration”.
Import the lpddr_config140MHz file, located in <GRLIB path>/boards/microsemi-m2s090ts-eval-
kit/. In the same tab select “LPDDRI” as I/O standard (see figure below).
In the ENVM tab select “Data Storage” and click “Add to system”. A window will appear in order to
setup the content of the eNVM. The eNVM is by default mapped at address 0x0 in the LEON3 pro-
cessor bus, thus it can be used to store the boot code. In the “Add Data Storage Client” window, write
a name for the client, select “prom.srec” file (located in the template design directory) and:
· select Motorola-S as format;
· check Use Absolute addressing;
· check Use content for simulation;
· select 32 bits as word size (see figure below).
Configure all masters and slaves to show an AHBLite interface (set by default).
In the Clocks tab, select the on-chip 50MHz oscillator as clock source, 140 MHz for M3 and MDDR
clocks, and 70 MHz for all the other fields (see figure below). FIC_0 clock is used as system clock for
the entire processor subsystem in the FPGA fabric.
The Microcontroller section presents several tabs. The ones associated to the Cortex-M3 and the
Cache Controller can be ignored since the ARM processor is not used by this template design.
In the Peripheral DMA tab select both options for “Use Fabric to MSS DMAREADY_FIC port”,
since they refer to signal that can be used during DMA transfers between MSS and LEON3 subsys-
tems. The options in AHB Bus Matrix tab may be optionally modified depending on user require-
ments.
In the SECDED tab, disable the MDDR ECC interrupt (see figure below).
The Security tab can be used to configure the security level for each master/slave of the MSS subsys-
tem. This template design assumes that the default values are used. The last two tabs of System
Builder are not relevant for this MSS component generation flow for the target design. At the end of
The Smart Design window will show the architecture of the mss_sb component (see next figure). The
SmartFusion2 MSS is represented by the mss_sb_MSS_0 component.
Right-click on it and select Configure. A new SmartDesign window will be opened, showing the
block diagram of the Microcontroller Subsystem (see figure below).
Configure the DDR Bridge block as in the figure below to enable the High Performance DMA con-
troller (HPDMA).
Other MSS blocks configurations may be changed by the user as long as they do not introduce addi-
tional I/O ports to the component. At the end of MSS configuration, click on the Generate Component
button in the SmartDesign window toolbar and return to the mss_sb view.
A warning symbol will be shown in the previously configured component. Right-click on it and select
Update instance with latest component. The M3_RESET_N port will be shown. Right-click on it and
select Promote to Top level.
In the same view, it can be noted that three instances of CoreAHBLite are present. These components
are included by default in order to access the MDDR and FIC interfaces of the MSS. Custom wrap-
pers are then needed to interface the LEON3 subsystem to the CoreAHBLite interfaces. A slightly
more efficient approach is to use custom wrappers (already instantiated in the design top entity
leon3mp) to access directly the AHBLite interfaces shown by the MDDR and FIC. The three
CoreAHBLite instances can be removed from the block diagram. AMBA_MASTER_0, AMBA_-
MASTER_1, and AMBA_SLAVE_0 ports will be disconnected and must be also removed.
Click on Generate Component button in the SmartDesign toolbar and return to the SmartDesign win-
dow associated to the top level component generated through System Builder.
A warning sign is shown in the unique instance. Right-click on it and select Update instance with lat-
est component to update its I/O ports. Then, all the I/O ports of the component that are not connected
must be promoted to the top level by right-clicking on the port name and selecting Promote to top
level. Power_on_reset_n port must be marked as unused. If SERDESIF_0 has been enabled, two
additional ports will be shown on the component (i.e., FAB_CCC_GL3 and FAB_CCC_LOCK).
These ports must be marked as unused.
After I/O promotion, the Smart Design view must look as shown in the figure below. By clicking on
Generate component button, the VHDL files associated to the customized components will be cre-
ated.
6.6.3.10 Step 10: Add generated component files to simulation and synthesis
Before simulating and synthesizing the design, a last step is required. In the Design Flow window,
right-click on Simulate, under Verify Pre-Synthesized Design, and select Organize Input Files > Orga-
Note: if the target simulator is Riviera, issue make patch-simriviera from the design directory in a
terminal before launching simulation from Libero SoC.
The same process must be performed before synthesis. In the Design Flow tab of Libero SoC, right-
click on Synthesize, and select Organize Input Files > Organize Source Files. On the left side of Orga-
nize Source Files window, select only the files associated to the previously generated MSS compo-
nent (i.e., with Origin field equal to mss_sb, mss or mss_sb_MSS), and add them to the synthesis
sources (right side) by clicking on the Add button (see figure). The files that must not be added to syn-
thesis are:
· osc_comps_pre.vhd;
· mss_sb_MSS_pre.vhd.
6.6.3.11 Step 11: SERDES I/F - ONLY if SERDES I/F is enabled in the design configuration
This step is only needed if SERDES is enabled and the pregenerated IP component is not used.
In the Design Flow window in Libero SoC, double-click on Create Smart Design. Write igl_ser-
des_epcs as component name (see figure below).
Search for High Speed Serial Interface 2 in the Catalog tab (see figure below) and drop it into the
Smart Design view. Righ-click on the component in the Smart Design view and select Configure to
setup the SERDES interface in SGMII mode. In the High Speed Serial Interface Configurator window
(see second figure below) select:
· Simulation Level : RTL
· Type: EPCS
· Number of Lanes: x1 – Lane 3
· Reference Clock Source: REFCLK1 (Differential)
· PHY RefClk Frequency: 125 MHz
· Data Rate: 1250 Mbps (10 bit)
A new component will be generated in Smart Design view. Sets the ports of the component as in the
figure below. In particular:
· tielow EPCS_3_PWRDN, EPCS_3_TX_OOB and EPCS_3_RX_ERR;
· tiehigh EPCS_3_TX_VAL;
6.6.3.12 Step 12: Add generated component files to simulation and synthesis
Open the igl_serdes_epcs component in the “Design Hierarchy” tab and click on Generate Compo-
nent button to generate the associated HDL files.
In the Design Flow tab of Libero SoC, right-click on Simulate, under Verify Pre-Synthesized Design,
and select Organize Input Files > Organize Source Files. In the Organize Source Files window, select
the two files associated to the previously generated SERDES component (the ones highlighted in the
figure below), and add them to the simulation sources (right side) by clicking on the Add button.
In the Design Flow tab of Libero SoC, right-click on Synthesize, and select Organize Input Files >
Organize Source Files. In the Organize Source Files window, select only the files associated to the
previously generated SERDES component (the ones highlighted in the figure below), and add them to
the synthesis sources (right side) by clicking on the Add button.
6.6.3.13 Step 13
With the previous steps completed, the implementation flow in Libero SoC can be executed by run-
ning:
I. Synthesis;
II. Compile;
III. Place and Route;
IV. Verify Timing (in this step carefully check for setup/hold violations in the generated reports);
V. Generate Bitstream;
VI. Run Program Action.
6.6.4 leon3-microsemi-m2s150ts-adv-kit
The steps below are described based on Libero v11.5-SP2. The flow is expected to be similar in later
versions of Libero SoC.
The template design also contains a pregenerated Microsemi IP. Use of this IP is enabled via xconfig
under the menu Synthesis > Use pregenerated Microsemi IP. If that option is enabled then the steps
described below to generate the system can be skipped and synthesis can be started immediately (skip
step 6 to 12). The pregenerated IP has been built using Libero 11.7 SP1. If the xconfig option Synthe-
sis > Use pregenerated Microsemi IP is set to n before the Libero project is generated the pregener-
ated IP is included in the project as a SmartDesign and can be configured.
After launching System Builder, write “mss” as name for the system (see figure below) and click
“OK”. The System Builder GUI will be opened.
In the first “Device Features” tab, check the boxes as in the figure below, and click on “Next”. SERS-
ESIF_3 must be checked only if Ethernet has been enabled during design configuration (Step 2).
The configuration in the figure above will enable the DDR memory controller, connected to the
onboard
Mobile DDR memory, the embedded NonVolatile Memory, used to store the processor bootcode, and
the peripheral DMA controller.
In the following section, i.e., Memories, select the MDDR tab and click on “Import Configuration”.
Import ddr3_config file, located in <GRLIB path>/boards/microsemi-m2s150ts-adv-kit/. In the same
tab select “Half Drive Strength” as I/O drive strength (see figure below).
In the ENVM tab select “Data Storage” and click “Add to system”. A window will appear in order to
setup the content of the eNVM. The eNVM is by default mapped at address 0x0 in the LEON3 pro-
cessor bus, thus it can be used to store the boot code. In the “Add Data Storage Client” window, write
a name for the client, select “prom.srec” file (located in the template design directory) and:
· select Motorola-S as format;
· check Use Absolute addressing;
· check Use content for simulation;
· select 32 bits as word size (see figure below).
In the Clocks tab, select the on-chip 50MHz oscillator as clock source, 160 MHz for M3_CLK, 320
MHz for MDDR_CLK, and 80 MHz for all the other fields (see figure below). FIC_0_CLK is used as
system clock for the entire processor subsystem in the FPGA fabric.
The Microcontroller section presents several tabs. The ones associated to the Cortex-M3 and the
Cache Controller can be ignored since the ARM processor is not used by this template design.
In the Peripheral DMA tab select both options for “Use Fabric to MSS DMAREADY_FIC port”,
since they refer to signal that can be used during DMA transfers between MSS and LEON3 subsys-
tems. The options in AHB Bus Matrix tab may be optionally modified depending on user require-
ments.
The Security tab can be used to configure the security level for each master/slave of the MSS subsys-
tem. This template design assumes that the default values are used. The last two tabs of System
Builder are not relevant for this MSS component generation flow for the target design. At the end of
the generation process, a new component (mss_sb_0) will appear in the Smart Design view (see fig-
ure below).
The Smart Design window will show the architecture of the mss_sb component (see figure below).
The SmartFusion2 MSS is represented by the mss_sb_MSS_0 component.
Right-click on it and select Configure. A new SmartDesign window will be opened, showing the
block diagram of the Microcontroller Subsystem (see figure below).
Right-click on the Reset Controller and select Configure to enable FPGA Fabric to M3 Reset Signal
(see figure below). An additional input port (i.e., M3_RESET_N) will be added to the component.
Configure the DDR Bridge block as in the figure below to enable the High Performance DMA con-
troller (HPDMA).
Configure the Interrupt Management block as in the figure below to show an additional output port
(i.e., MSS_INT_M2F) carrying information on interrupts generated by MSS blocks. This additional
port and the previously enabled EDAC_ERROR bus can be used to monitor the status of the MSS
from blocks implemented in the FPGA fabric. Other MSS blocks configurations may be changed by
the user as long as they do not introduce additional I/O ports to the component. At the end of MSS
configuration, click on the Generate Component button in the SmartDesign window toolbar and
return to the mss_sb view.
A warning symbol will be shown in the previously configured component. Right-click on it and select
Update instance with latest component. The M3_RESET_N, M3_NMI, COMM_BLK_INT and
MSS_INT_M2F ports will be shown. Right-click on them and select Promote to Top level.
In the same view, it can be noted that three instances of CoreAHBLite are present. These components
are included by default in order to access the MDDR and FIC interfaces of the MSS. Custom wrap-
pers are then needed to interface the LEON3 subsystem to the CoreAHBLite interfaces. A slightly
more efficient approach is to use custom wrappers (already instantiated in the design top entity
leon3mp) to access directly the AHBLite interfaces shown by the MDDR and FIC. Therefore, the
three CoreAHBLite instances can be removed from the block diagram. AMBA_MASTER_0,
AMBA_MASTER_1, and AMBA_SLAVE_0 ports will be disconnected and must be removed.
Click on Generate Component button in the SmartDesign toolbar and return to the SmartDesign win-
dow associated to the top level component generated through System Builder.
A warning sign is shown in the unique instance. Right-click on it and select Update instance with lat-
est component to update its I/O ports. Then, all the I/O ports of the component that are not connected
must be promoted to the top level by right-clicking on the port name and selecting Promote to top
level. If SERDESIF_0 has been enabled, two additional ports will be shown on the component (i.e.,
FAB_CCC_GL3 and FAB_CCC_LOCK). These two ports must be marked as unused.
After I/O promotion, the Smart Design view must look as shown in the figure below. By clicking on
Generate component button, the VHDL files associated to the customized components will be cre-
ated.
6.6.4.10 Step 10: Add generated component files to simulation and synthesis
Before simulating and synthesizing the design, a last step is required. In the Design Flow window,
right-click on Simulate, under Verify Pre-Synthesized Design, and select Organize Input Files > Orga-
nize Source Files. In the Organize Source Files window, select the files associated to the previously
generated MSS component (left side), and add them to the simulation sources (right side) by clicking
on the Add button (see figure below). The files that must not be added to simulation are:
· osc_comps.vhd;
· osc_comps_pre.vhd;
· mss_sb_MSS_pre.vhd;
· mss_sb_MSS_syn.vhd.
6.6.4.11 Step 11: SERDES I/F - ONLY if SERDES I/F is enabled in the design configuration
This step is only needed if SERDES is enabled and the pregenerated IP component is not used.
In the Design Flow window in Libero SoC, double-click on Create Smart Design. Write igl_ser-
des_epcs as component name (see figure below).
Search for High Speed Serial Interface in the Catalog tab (see figure below) and drop it into the Smart
Design view. Right-click on the component in the Smart Design view and select Configure to setup
the SERDES interface in SGMII mode. In the High Speed Serial Interface Configurator window (sec-
ond figure below) select:
· SerDesIF_3
· Simulation Level : RTL
· Type: EPCS
· Number of Lanes: x1 – Lane 3
· Reference Clock Source: REFCLK1 (Differential)
· PHY RefClk Frequency: 125 MHz
A new component will be generated in Smart Design view. Sets the ports of the component as in the
figure below.
In particular:
· tie-low EPCS_3_PWRDN, EPCS_3_TX_OOB and EPCS_3_RX_ERR;
· tie-high EPCS_3_TX_VAL;
· promote to top-level all remaining ports.
6.6.4.12 Step 12: Add generated component files to simulation and synthesis
Open the igl_serdes_epcs component in the “Design Hierarchy” tab and click on Generate Compo-
nent button to generate the associated HDL files.
In the Design Flow tab of Libero SoC, right-click on Simulate, under Verify Pre-Synthesized Design,
and select Organize Input Files > Organize Source Files. In the Organize Source Files window, select
the two files associated to the previously generated SERDES component (the ones highlighted in the
figure below), and add them to the simulation sources (right side) by clicking on the Add button.
In the Design Flow tab of Libero SoC, rightclick on Synthesize, and select Organize Input Files >
Organize Source Files. In the Organize Source Files window, select only the files associated to the
previously generated SERDES component (the ones highlighted in the figure below), and add them to
the synthesis sources (right side) by clicking on the Add button.
6.6.4.13 Step 13
With the previous steps completed, the implementation flow in Libero SoC can be executed by run-
ning:
I. Synthesis;
II. Compile;
III. Place and Route;
IV. Verify Timing (in this step carefully check for setup/hold violations in the generated reports);
V. Generate Bitstream;
Relative paths are allowed as entries in the libs.txt files. The path depth is unlimited. The leaf of each
path corresponds to a VHDL libary name (e.g. ‘grlib’ and ‘unisim’).
Each directory specified in the libs.txt contains the file dirs.txt, which contains paths to sub-directo-
ries containing the actual VHDL code. In each of the sub-directories appearing in dirs.txt should con-
tain the files vhdlsyn.txt and vhdlsim.txt. The file vhdlsyn.txt contains the names of the files which
should be compiled for synthesis (and simulation), while vhdlsim.txt contains the name of the files
which only should be used for simulation. The files are compiled in the order they appear, with the
files in vhdlsyn.txt compiled before the files in vhdlsim.txt.
The example below shows how the AMBA package in the GRLIB VHDL library is constructed:
$ ls lib/grlib
amba/ dirs.txt modgen/ sparc/ stdlib/ tech/ util/
$ cat lib/grlib/dirs.txt
stdlib util sparc modgen amba tech
$ ls lib/grlib/amba
ahbctrl.vhd amba.vhd apbctrl.vhd vhdlsyn.txt
$ cat grlib/lib/grlib/amba/vhdlsyn.txt
amba.vhd apbctrl.vhd ahbctrl.vhd
The libraries listed in the grlib/lib/libs.txt file are scanned first, and the VHDL files are added to the
automaticaly generated compile scipts. Then all sub-directories in lib are scanned for additional
libs.txt files, which are then also scanned for VHDL files. It is therefore possible to add a VHDL
library (= sub-directory to lib) without having to edit lib/libs.txt, just by inserting into lib.
When all libs.txt files have been scanned, the dirs.txt file in lib/work is scanned and any cores in the
VHDL work library are added to the compile scripts. The work directory must be treated last to avoid
circular references between work and other libraries. The work directory is always scanned as does
not appear in lib/libs.txt.
File listed in the tool specific vhdlsyn.txt file will only be added to the file list for a specific tool. For
example, file listed in vhdlxile.txt will only be added to Xilinx ISE and Vivado projects.
-- plug&play configuration
constant HCONFIG: ahb_config_type := (
0 => ahb_device_reg (VENDOR_EXAMPLE, EXAMPLE_AHBRAM, 0, 0, 0),
4 => ahb_membar(memaddr, '0', '0', memmask), others => X"00000000");
begin
ahbso.hconfig <= HCONFIG; -- Plug&play configuration
ahbso.hirq <= (others => ‘0’); -- No interrupt line used
-- original component
e0: ieee_example
port map(
rst, clk, ahbsi.hsel(ahbndx), ahbsi.haddr, ahbsi.hwrite, ahbsi.htrans, ahbsi.hsize,
ahbsi.hburst, ahbsi.hwdata, ahbsi.hprot, ahbsi.hready, ahbsi.hmaster,
ahbsi.hmastlock, ahbso.hready, ahbso.hresp, ahbso.hrdata, ahbso.hsplit);
end;
The files containing the entity ahb_example the entity for ieee_example should be added to GRLIB
by listing the files in a vhdlsyn.txt file located in a directory that will be scanned by the GRLIB
scripts, as described in section 8.2. The paths in vhdlsyn.txt can be relative, allowing the VHDL files
to be placed outside the GRLIB tree. The entities and packages will be compiled into a library with
the same name as the directory that holds the vhdlsyn.txt file.
In the ahb_example example, the core does not have the ability to assert an interrupt. In order to assert
an interrupt, an AHB core must drive the hirq vector in the ahb_slv_out_type (or ahb_mst_out_type)
output record. If the core is an APB slave, it should drive the apb_slv_out_type record’s pirq vector.
Position n of hirq/pirq corresponds to interrupt line n. All unused interrupt lines must be driven to ‘0’.
The ahb_config_type is an array of 32-bit vectors. Each position in this array corresponds to the same
word in the core’s plug&play information. Section 5.3.1 describes the plug&play information in the
following way: The first word is called the identification register and contains information on the
device type and interrupt routing. The last four words are called bank address registers, and contain
address mapping information for AHB slaves. The remaining three words are currently not assigned
and could be used to provide core-specific configuration information.
The AMBA package (lib/grlib/amba/amba.vhd) in GRLIB provides functions that help users create
proper plug&play information. Two of these functions are used above. The ahb_device_reg function
creates the identification register value for an AHB slave or master:
ahb_device_reg (vendor, device, cfgver, version, interrupt)
Parameter Comments
vendor Integer Vendor ID. Typically defined in lib/grlib/amba/devices.vhd. It is recom-
mended that new cores be added under a new vendor ID or under the contrib
vendor ID.
device Integer Device ID. Typically defined in lib/grlib/amba/devices.vhd. The combi-
nation of vendor and device ID must not match any existing core as this may
lead to your IP core being initialized by drivers for another core.
cfgver Plug&play information version, only supported value is 0.
version Core version/revision. Assigned to 5-bit wide field in plug&plat information.
interrupt Set this value to the first interrupt line that the core drives. Set to 0 if core does
not make use of interrupts.
If an IP core only has an AHB master interface, the only position in HCONFIG that needs to be spec-
ified is the first word:
constant hconfig : ahb_config_type := (
0 => ahb_device_reg ( venid, devid, 0, version, 0),
others => X"00000000");
If an IP core has an AHB slave interface, as in the ahb_example example, we also need to specify the
memory area(s) that the slave will map. Again, the HCONFIG constant from ahb_example is:
-- plug&play configuration
constant HCONFIG : ahb_config_type := (
0 => ahb_device_reg (VENDOR_EXAMPLE, EXAMPLE_AHBRAM, 0, 0, 0),
4 => ahb_membar(memaddr, '0', '0', memmask), others => X"00000000");
The last four words of ahb_config_type (positions 4 - 7) are called bank address registers (BARs), and
contain memory map information. This information determines address decoding in the AHB control-
ler (AHBCTRL core). Address decoding is described in detail under section 5.3.3. When creating an
AHB memory bank, the ahb_membar function can be used to automatically generate the correct lay-
out for a BAR:
ahb_membar(memaddr, prefetch, cache, memmask)
To create an AHB I/O bank, the ahb_iobar function can be used:
ahb_iobar(memaddr, memmask)
The parameters of these functions are described in the table below:
Parameter Comments
memaddr Integer value propagated to BAR.ADDR
memmask Integer value propagated to BAR.MASK
prefetch Std_Logic value propagated to prefetchable field (P) in bank address register.
Only applicable for AHB memory bars (ahb_membar function).
cache Std_Logic value propagated to cacheable field (C) in bank address register. Only
applicable for AHB memory bars (ahb_membar function).
An AHB slave can map up to four address areas (it has four bank address registers). Typically, an IP
core has one AHB I/O bank with registers and zero or several AHB memory banks that map a larger
memory area. One example is the GRLIB DDR2 controller (DDR2SPA) that has the following
HCONFIG:
constant hconfig : ahb_config_type := (
0 => ahb_device_reg ( VENDOR_GAISLER, GAISLER_DDR2SP, 0, REVISION, 0),
4 => ahb_membar(haddr, '1', '1', hmask),
5 => ahb_iobar(ioaddr, iomask),
others => zero32);
Position four, the first bank address register, defines an AHB memory bank which maps external
DDR2 SDRAM memory. Position five, the second bank address register, defines an AHB I/O bank
that holds the memory controller’s register interface. On this core, the haddr, hmask, ioaddr and
iomask values are set via VHDL generics.
For IP cores that map multiple memory areas, there is no need for the IP core to decode the address in
order to determine which bank that is accessed. The AHB controller decodes the incoming address
and selects the correct AHB slave via the HSEL vector. The AHB controller also indicates which
bank that is being accessed via the HMBSEL vector, when bank n is accessed HMBSEL(n) will be
asserted.
Example of APB slave IP core with one 32-bit register that can be read and written:
library ieee; use ieee.std_logic_1164.all;
library grlib; use grlib.amba.all; use grlib.devices.all;
library gaisler; use gaisler.misc.all;
entity apb_example is
generic (
pindex : integer := 0;
paddr : integer := 0;
pmask : integer := 16#fff#);
port (
rst : in std_ulogic;
clk : in std_ulogic;
apbi : in apb_slv_in_type;
apbo : out apb_slv_out_type);
end;
begin
-- write registers
if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then
case apbi.paddr(4 downto 2) is
when "000" => v.reg := apbi.pwdata;
when others => null;
end case;
end if;
-- system reset
if rst = '0' then v.reg := (others => '0'); end if;
rin <= v;
-- registers
regs : process(clk)
begin
if rising_edge(clk) then r <= rin; end if;
end process;
-- boot message
-- pragma translate_off
bootmsg : report_version
generic map ("apb_example" & tost(pindex) &": Example core rev " & tost(REVISION));
-- pragma translate_on
end;
The steps required to instantiate the apb_example IP core in a system are:
•Add the file to a directory covered by the GRLIB scripts (via libs.txt and dirs.txt)
•Add the file to vhdlsyn.txt in the current directory
•Modify the example to use a unique vendor and device ID (see creation of PCONFIG constant)
•Create a component for the apb_example core in a package that is also synthesized.
•Include the package in your design top-level
•Instantiate the component in your design top-level
For a complete example, see the General Purpose Register (GRGPREG) IP core located in lib/gaisler/
misc/grgpreg.vhd. That core is very similar to the example given in this section. The GRGPREG core
has a component declaration in the grlib.misc package located at lib/gaisler/misc/misc.vhd. Note that
both of these files are listed in the vhdlsyn.txt file located in the same directory.
The ahb_device_reg function has been described in section 8.3.2. The apb_iobar function takes the
same arguments as the ahb_iobar function, also described in section 8.3.2.
8.4.1 Overview
This example is based on the leon3-minimal design in the designs/ directory. It can be used to create a
minimalistic system for a new FPGA board with low effort. The design includes basic cores like the
LEON3 CPU, AMBA bus, memory controller and serial communication interfaces. However, the
included memory controller might have to be replaced with one that is compatible with the RAM type
on the target board. The serial communication interfaces available in this design are JTAG and UART.
The GRMON debug monitor can connect to the design through any of these interfaces.
A minimal GRLIB design requires that at least four files. They should be placed in a new directory ../
designs/<design name>.
Makefile Local makefile for the design. Sets variables for synthesis and calls the main GRLIB
makefile.
config.vhd Design configuration parameters. Generated through xconfig.
leon3mp.vhd Top level VHD file. The CPU and bus peripherals are instantiated here
leon3mp.ucf Xilinx constraint file. Maps input/output ports in the top level to pins on the FPGA.
The design example further down covers how to create and modify these files for a board that has a
Xilinx FPGA. The Xilinx ISE synthesis workflow is used in the example and is valid for the majority
of Xilinx FPGAs.
The first goal in the implementation process is to get a design that it is possible to connect to with
GRMON. To achieve this the leon3mp.vhd can mostly be left untouched, but a config.vhd and Make-
file needs to be created and is covered in detail in the example. The next step is to replace or configure
the memory controller in order to make accesses the on board RAM possible. This guide only covers
in detail how to access on-board SRAM.
In order to also be able to simulate the design, the files listed below are required.
testbench.vhd Testbench VHD file for simulation. Contains an instantiation of leon3mp.vhd and
peripherals that are connected to the FPGAs pins like RAM/ROM.
prom.srec Boot prom for the simulation that starts the program in sram.srec
sram.srec Contains a test program
wave.do Adds signals to simulator wave window.
Performing a simulation increases the probability of a successful implementation on the FPGA. When
a simulation is performed the AMBA bus controller will check for violations, e.g. if two masters have
the same index. It is also suitable to set up a simulation environment in order to test if the the memory
controller is correctly configured.
# Libraries, directories and files in GRLIB that should not be compiled for this design
LIBSKIP = core1553bbc core1553brm core1553brt gr1553 corePCIF \
tmtc ihp usbhc spw
DIRSKIP = b1553 pci/pcif leon2 leon2ft crypto satcan pci leon3ft ambatest can \
usb grusbhc spacewire ascs slink hcan \
leon4 leon4v0 l2cache pwm gr1553b iommu
FILESKIP = grcan.vhd
If there exists a constraints file in the board directory it is still possible to use a constraints file that is
local to a particular design. If the the UCF variable points to the UCF file in the board directory is it is
assigned UCF=$(GRLIB)/boards/$(BOARD)/$(TOP).ucf. In order to use the local UCF in the design
directory the variable is instead assigned UCF=$(TOP).ucf.
The cmd files are scripts for iMPACT and can be generated by running it as a GUI. In the directory
from where iMPACT was started a file "_impact.cmd" is created upon exit. It will contain the com-
mands that where executed in the GUI mode session and might require some cleanup. The cmd files
can not be overridden locally for a specific design and have to be placed in the boards directory.
Description of leon3mp.vhd
This section explains the leon3mp.vhd example file that exists in the LEON3-MINIMAL design and
the modifications have to be done to it.
The entity declaration in this leon3mp.vhd example contains the minimal number of generics and
ports. The four generics specify the technology used and are assigned in the generated config.vhd file.
entity leon3mp is
generic (
fabtech : integer := CFG_FABTECH;
memtech : integer := CFG_MEMTECH;
padtech : integer := CFG_PADTECH;
clktech : integer := CFG_CLKTECH);
After the port mapping follows the signal and constant declaration section. There are four constants
declared that are used to set the frequency of the LEON3 CPU and system bus.
constant clock_mult : integer := 10; -- Clock multiplier
constant clock_div : integer := 20; -- Clock divider
constant BOARD_FREQ : integer := 100000; -- Clock input frequency in KHz
constant CPU_FREQ : integer := BOARD_FREQ * clock_mult / clock_div; -- CPU freq in KHz
On most boards the FPGAs input clock frequency is within 50 - 200 MHz. The Nexys4 board has an
input clock that is 100 MHz that enters through the "clk" input signal. Therefore the BOARD_FREQ
constant is set to 100 000 kHz.
In this example the LEON3 CPU clock frequency is scaled to half the input clock frequency by set-
ting the clock multiplier to 10 and divider to 20. It is recommended to keep the system frequency low
at this stage in the development process in order to avoid a malfunctioning design because of timing
errors. The synthesis tool produces a warning in case of a timing error, but the bit file is still gener-
ated.
The frequency conversion is carried out in the "clkgen" IP-core that instantiates a DCM, PLL or an
equivalent clock generator that is suitable for the FPGA. However, the valid intervals of the multiplier
and divider parameters vary between different FPGAs, but the parameters suggested here are likely to
be valid in many cases. The new clock (50 MHz) is assigned to the "clkm" signal.
clkgen0 : clkgen
generic map (fabtech, clock_mult, clock_div, 0, 0, 0, 0, 0, BOARD_FREQ, 0)
port map (clk, gnd, clkm, open, open, open, open, cgi, cgo, open, open, open);
The btnCpuResetn signal originates from a button on the board and does therefore contain glitches.
Therefore the rstgen IP-core is used to create a clean reset signal named rstn. The signal that is output
when a button is pressed varies between FPGA boards. The reset button on the Nexys4 board pro-
duces a low value when pressed, and therefore the "acthigh" generic is set to 0. If it is uncertain how
the button on the board behaves and GRMON does not connect it can be attempted to hold the reset
button while trying to connect again.
rst0 : rstgen generic map (acthigh => 0) -- Change to 1 if reset button is act high
port map (btnCpuResetn, clkm, lock, rstn, rstraw);
The easiest way to connect to the board is through a serial interface like RS-232 and/or JTAG. On Xil-
inx FPGAs JTAG is the easiest since it is just to instantiate the ahbjtag core and the Xilinx tools will
connect the input/output signals. When creating a Xilinx design the tck, tms, tdi and tdo are dummy
signals, but have to be assigned for other FPGA manufacturers. In order for GRMON to connect
through JTAG an argument needs to be passed to it that depends on the JTAG vendor (e.g "-digilent",
"-xilusb" or "-jtag"). Refer to the GRMON manual for more details.
ahbjtag0 : ahbjtag generic map(tech => fabtech, hindex => 3)
port map(rstn, clkm, tck, tms, tdi, tdo, ahbmi, ahbmo(3),
open, open, open, open, open, open, open, gnd);
At this stage it is suitable to test if it is possible to connect to the FPGA with GRMON through either
JTAG or RS-232. Create the bitstream by running "make ise" and program the FPGA. When
GRMON successfully connects the remaining work is to get the on board memory working. In the
introduction chapter in the GRLIB IP Core User’s Manual, there is a table of available memory con-
trollers and their function. Since the configuration differs between various kinds of memories, the
method is explained by using the SRAM implementation as an example.
The first step would be to instantiate a memory controller. The Nexys4 has a 16-bit wide SRAM and
therefore the MCTRL is instantiated. The generic that controls where the SRAM is mapped in address
space is left at the default address 0x40000000. This is the recommended address since it is where the
binaries are uploaded by default.
sr1 : mctrl
generic map (hindex => 5, pindex => 0, paddr => 0, rommask => 0,
iomask => 0, ram8 => 0, ram16 => 1,srbanks=>1)
port map (rstn, clkm, memi, memo, ahbsi, ahbso(5), apbi, apbo(0), wpo, open);
The memory data bus is bidirectional and therefore iopads controled by the MCTRL must be used.
The MCTRL has one record that contains incoming signals into the core (memi) and one record that
contains outgoing signals (memo). The memo.bdrive signal decides if the data bus is read into
memi.data or is driven with value in memo.data. Further details about the MCTRL and its signals can
be found in the GRLIB IP Core User’s Manual.
When it comes to the memo signals it is likely that some SRAM chips will not require all the memo
signals. E.g. other chips might not require the mben signals. There can also be a difference in how the
address bus functions on different boards. Since the Nexys4 board has a 16 bit wide memory bus
accesses are done in 2 byte blocks. The LSB address bit in the memo.address is therefore not assigned
to the address bus. However another board could have an 8 bit PROM and a 32 bit SRAM and would
therefore require the LSB address bit in order to access the PROM.
After the memory controller has been added the design it is suggested to do a simulation. Then create
a new configuration file and program the FPGA. The first goal when trying to implement memory
access is to be able to write to the memory and detect that something changed from before. In this
development phase it is suitable to use long memory latencies in order to ensure that a failure is not
related to incorrect timings.
It is possible to set the various timings for the MCTRL core through GRMON. Since in this example
the MCTRL is used together with SRAM the read and write latency of the SRAM can be set by pass-
ing "-ramrws 3" and "-ramwws 3" as arguments when starting GRMON.
-- PROM
address => address(22 downto 0),
data => data(31 downto 16),
-- AHB Uart
RsRx => dsurx,
RsTx => dsutx,
sram1 : sram
generic map (index => 5, abits => 24, fname => sdramfile)
port map (address(23 downto 0), data(23 downto 16), RamCE, writen, oen);
By default a test bench in the design folder execute a small system test program in the LEON proces-
sor. Upon simulation start the SRAM is loaded with a binary from an SREC file, usually named
"ram.srec", which contains a test program. The file name is not assigned directly the to SRAM model
but rather through a constant named sdramfile or sramfile for convenience. It is possible to execute
most other binaries in simulation too as log as the binary is contained in an SREC file. The other
binary can then be simulated by changing the sdramfile constant to point its SREC file.
If there is a PROM on board it is added to the testbench.vhd and accessed though the same address
and data bus as the SRAM. The PROM is also instantiated with the SRAM simulation model since the
PROM read accesses are performed in the same way as for SRAM. The SRAM simulation model that
is used as a PROM is instead loaded with the "prom.srec" file.
Before it is possible to generate the ram.srec, prom.srec and ahbrom.vhd it is necessary to have valid
prom.h and systest.c files in the design directory, which are provided. The systest.c file contains the
main function which then calls different test modules. In this test bench example it does only perform
a basic test and does not require modifications.
The prom.h file contains constants that are applied to various configuration registers in the LEON
system during the boot. At this stage the MCTRL memory controller is being configured to properly
access the SRAM. The data written into the MCTRL registers is defined by the constants MCFG1,
MCFG2 and MCFG3 and correspond to three of the memory controllers registers. The SRAM is con-
figured through the MCFG2 constant and is used to set the data bus width and data access latency etc.
The register is described in further detail in the GRLIB IP Core User’s Manual. In order to configure
other memory controllers and memory types it might be necessary to add or modify a constant in
prom.h.
The generation of the sram.srec and prom.srec files is done be by running "make soft". To generate
the AHBROM IP core run "make ahbrom.vhd", which will create the ahbrom.vhd file.
Within the testbench.vhd there is a section that asserts the processor’s error signal, which indicates if
the CPU entered the error state. In the leon3mp top level design this signal is assigned to the on board
led(3) and made active high. If the led(3) signal ever goes high the simulation will immediately stop.
If an error occurs because of miss configured RAM the AHB address bus (ahbsi.haddr) will give a
hint when and at what address a faulty data access occurred.
led(3) <= ’L’; -- ERROR pull-down
error <= not led(3);
iuerr : process
begin
wait for 5 us;
assert (to_X01(error) = ’1’)
report "*** IU in error mode, simulation halted ***"
severity failure;
end process;
Within the leon3mp top level design a test reporting unit is instantiated. When the simulation runs, the
test reporting unit will print to the console whether the various test modules in the test program suc-
ceed or not. Notice that the --pragma translate on/off will remove the unit from the hardware synthesis
but will leave it in the simulation.
--pragma translate_off
test0 : ahbrep generic map (hindex => 4, haddr => 16#200#)
port map (rstn, clkm, ahbsi, ahbso(4));
--pragma translate_on
8.6.1 General
New technologies to support portability can be added to GRLIB without the need to modify any pre-
viously developed designs. This is achieved by technology independent encapsulation of components
such as memories, pads and clock buffers. The technology mapping is organized as follows:
•A VHDL library with the technology simulation models is placed in lib/tech/library
•Wrappers for memory, pads, PLL and other cells are placed under lib/techmap/library
•All ‘virtual’ components with technology mapping are placed in lib/techmap/maps
•Declaration of all ‘virtual’ components and technologies is made in lib/techmap/gencomp/gencomp.vhd
An entity that uses a technology independent component needs only to make the techmap.gencomp
package visible, and can then instantiate any of the mapped components.
8.6.4 Memories
The currently defined memory types are single-port, dual-port, two-port and triple-port synchronous
RAM. The encapsulation method described in the preceding section is applied to include a technology
implementing one of these memory types.
For example, the ASIC memory models from Virage are encapsulated at the lower level i the lib/
techmap/virage/mem_virage_gen.vhd file. Specifically, the single-port RAM is defined in
the VIRAGE_SYNCRAM entity:
entity virage_syncram is
generic (
abits : integer := 10;
dbits : integer := 8 );
port (
clk : in std_ulogic;
address : in std_logic_vector(abits -1 downto 0);
datain : in std_logic_vector(dbits -1 downto 0);
dataout : out std_logic_vector(dbits -1 downto 0);
enable : in std_ulogic;
write : in std_ulogic);
end;
The corresponding architecture instantiates the Virage specific technology specific memory cell, e.g.
hdss1_256x32cm4sw0 shown hereafter:
architecture rtl of virage_syncram is
signal d, q, gnd : std_logic_vector(35 downto 0);
signal a : std_logic_vector(17 downto 0);
signal vcc : std_ulogic;
constant synopsys_bug : std_logic_vector(37 downto 0) := (others => '0');
begin
The higher level single-port RAM model SYNCRAM is defined in the lib/techmap/maps/
syncram.vhd file. The entity declaration is technology independent:
entity syncram is
generic (
tech : integer := 0;
abits : integer := 6;
dbits : integer := 8 );
port (
clk : in std_ulogic;
address : in std_logic_vector((abits -1) downto 0);
datain : in std_logic_vector((dbits -1) downto 0);
dataout : out std_logic_vector((dbits -1) downto 0);
enable : in std_ulogic;
write : in std_ulogic);
end;
The corresponding architecture implements the selection of the lower level components based on the
MEMTECH or TECH generic:
architecture rtl of syncram is
begin
inf : if tech = infered generate
u0 : generic_syncram generic map (abits, dbits)
port map (clk, address, datain, dataout, write);
end generate;
...
vir : if tech = memvirage generate
u0 : virage_syncram generic map (abits, dbits)
port map (clk, address, datain, dataout, enable, write);
end generate;
...
end;
The GENCOMP package contains component declarations for all portable components, i.e. SYN-
CRAM, SYNCRAM_DP, SYNCRAM_2P and REGFILE_3P.
8.6.5 Pads
The currently defined pad types are in-pad, out-pad, open-drain out-pad, I/O-pad, open-drain I/O pad,
tri-state output-pad and open-drain tri-state output-pad. Each pad type comes in a discrete and a vec-
torized version.
8.7.1 Introduction
Each template design has a simple graphical configuration interface that can be started by issuing
make xconfig in the template design directory. The tool presents the user with configuration options
and generates the file config.vhd that contains configuration constants used in the design.
The subsections below describe how to create configuration menus for a core and then how to include
these new options in xconfig for an existing template design.
We will start by looking at the grgpio.in file. This file defines the menu structure and options for the
GRGPIO core:
The first line defines a boolean option that will be saved in the variable CONFIG_GRGPIO_EN-
ABLE. This will be rendered as a yes/no question in the menu. If this constant is set to yes (‘y’) then
the user will be able to select two more configuration options. First the width, which is defined as an
integer (int), and the interrupt mask which is defined as a hexadecimal value (hex).
The GUI has a help option for each item in the menu. When a user clicks on the help button a help text
can be optionally displayed. The contents of the help text boxes is defined in the file that ends with
.in.help, in this case grgpio.in.help:
GPIO port
CONFIG_GRGPIO_ENABLE
Say Y here to enable a general purpose I/O port. The port can be
configured from 1 - 32 bits, whith each port signal individually
programmable as input or output. The port signals can also serve
as interrupt inputs.
As can be seen above, each help entry consists of a topic, the name of the variable used in the menu
and the help text.
The two remaining files (grgpio.in.h and grgpio.in.vhd) are used when generating the config.vhd file
for a design. config.vhd typically consists of a set of lines for each core where the first line decides if
the core should be instantiated in the design and the following lines contain configuration options. For
the GRGPIO core, the file grgpio.in.vhd defines that the following constants should be included in
config.vhd:
-- GPIO port
constant CFG_GRGPIO_ENABLE : integer := CONFIG_GRGPIO_ENABLE;
constant CFG_GRGPIO_IMASK : integer := 16#CONFIG_GRGPIO_IMASK#;
constant CFG_GRGPIO_WIDTH : integer := CONFIG_GRGPIO_WIDTH;
In the listing above, we see a mix of VHDL and the constants defined in the menus (see listing for
grgpio.in above). The value we select for CONFIG_GRPIO_ENABLE will be assigned to the VHDL
constant CFG_GRGPIO_ENABLE. In the menu we defined CONFIG_GRGPIO_IMASK as a hexa-
decimal value. The VHDL notation for this is to enclose the value in 16#..# and this is done for the
CFG_GRGPIO_IMASK constant.
When exiting the xconfig tool, the .in.vhd files for all cores will be concatenated into one file. Then a
pre-processor will be used to replace all the variables defined in the menus (for instance CON-
FIG_GRGPIO_ENABLE) into the values they represent. In this process, additional information is
inserted via the .in.vhd.h files. The contents of grgpio.in.h is:
#ifndef CONFIG_GRGPIO_ENABLE
#define CONFIG_GRGPIO_ENABLE 0
#endif
#ifndef CONFIG_GRGPIO_IMASK
#define CONFIG_GRGPIO_IMASK 0000
#endif
#ifndef CONFIG_GRGPIO_WIDTH
#define CONFIG_GRGPIO_WIDTH 1
#endif
This file is used to guarantee that the CONFIG_ variable always exist and are defined to sane values.
If a user has disabled CONFIG_GRGPIO_ENABLE via the configuration menu, then this variable
and all the other GRGPIO variables will be undefined. This would result in a config.vhd entry that
looks like:
-- GPIO port
constant CFG_GRGPIO_ENABLE : integer := ;
constant CFG_GRGPIO_IMASK : integer := 16##;
constant CFG_GRGPIO_WIDTH : integer := ;
... and lead to errors during compilation. This is prevented by grgpio.in.h above, where all undefined
variables are defined to sane values. It is also possible to place additional intelligence in the .in.h file
where dependencies between variables can be expressed in ways that would be complicated in the
menu definition in the .in file.
and the config.vhd file has the following entries (also just around the GRGPIO port):
-- GPIO port
constant CFG_GRGPIO_ENABLE : integer := 1;
constant CFG_GRGPIO_IMASK : integer := 16#0000#;
constant CFG_GRGPIO_WIDTH : integer := (8);
-- Spacewire interface
....
The core that we will add support for is the I2C2AHB core. We start by making copies of the existing
configuration files for the GRGPIO core (described in section 8.7.2) and modify them for I2C2AHB.
The resulting files are listed below:
i2c2ahb.in:
bool 'Enable I2C to AHB bridge ' CONFIG_I2C2AHB
if [ "$CONFIG_I2C2AHB" = "y" ]; then
bool 'Enable APB interface ' CONFIG_I2C2AHB_APB
hex 'AHB protection address (high) ' CONFIG_I2C2AHB_ADDRH 0000
hex 'AHB protection address (low) ' CONFIG_I2C2AHB_ADDRL 0000
hex 'AHB protection mask (high) ' CONFIG_I2C2AHB_MASKH 0000
hex 'AHB protection mask (low) ' CONFIG_I2C2AHB_MASKL 0000
bool 'Enable after reset ' CONFIG_I2C2AHB_APB
hex 'I2C memory address ' CONFIG_I2C2AHB_SADDR 50
hex 'I2C configuration address ' CONFIG_I2C2AHB_CADDR 51
fi
i2c2ahb.in.help:
GRLIB I2C2AHB core
CONFIG_I2C2AHB
Say Y here to enable I2C2AHB
CONFIG_I2C2AHB_APB
Say Y here to configure the core's APB interface
CONFIG_I2C2AHB_ADDRH
Defines address bits 31:16 of the core's AHB protection area
... and so on ..
i2c2ahb.in.vhd:
-- I2C to AHB bridge
constant CFG_I2C2AHB : integer := CONFIG_I2C2AHB;
constant CFG_I2C2AHB_APB : integer := CONFIG_I2C2AHB_APB;
constant CFG_I2C2AHB_ADDRH : integer := 16#CONFIG_I2C2AHB_ADDRH#;
constant CFG_I2C2AHB_ADDRL : integer := 16#CONFIG_I2C2AHB_ADDRL#;
constant CFG_I2C2AHB_MASKH : integer := 16#CONFIG_I2C2AHB_MASKH#;
constant CFG_I2C2AHB_MASKL : integer := 16#CONFIG_I2C2AHB_MASKL#;
i2c2ahb.in.h:
#ifndef CONFIG_I2C2AHB
#define CONFIG_I2C2AHB 0
#endif
#ifndef CONFIG_I2C2AHB_APB
#define CONFIG_I2C2AHB_APB 0
#endif
#ifndef CONFIG_I2C2AHB_ADDRH
#define CONFIG_I2C2AHB_ADDRH 0
#endif
#ifndef CONFIG_I2C2AHB_ADDRL
#define CONFIG_I2C2AHB_ADDRL 0
#endif
#ifndef CONFIG_I2C2AHB_MASKH
#define CONFIG_I2C2AHB_MASKH 0
#endif
#ifndef CONFIG_I2C2AHB_MASKL
#define CONFIG_I2C2AHB_MASKL 0
#endif
#ifndef CONFIG_I2C2AHB_RESEN
#define CONFIG_I2C2AHB_RESEN 0
#endif
#ifndef CONFIG_I2C2AHB_SADDR
#define CONFIG_I2C2AHB_SADDR 50
#endif
#ifndef CONFIG_I2C2AHB_CADDR
#define CONFIG_I2C2AHB_CADDR 51
#endif
#ifndef CONFIG_I2C2AHB_FILTER
#define CONFIG_I2C2AHB_FILTER 2
#endif
Where the inclusion of i2c2ahb.in is made just before the endmenu statement.
We can now issue make xconfig in the template design directory to rebuild the graphical menu:
user@host:~/GRLIB/designs/leon3-gr-xc3s-1500$ make xconfig
make main.tk
make[1]: Entering directory `/home/user/GRLIB/designs/leon3-gr-xc3s-1500'
gcc -g -c ../../bin/tkconfig/tkparse.c
gcc -g -c ../../bin/tkconfig/tkcond.c
gcc -g -c ../../bin/tkconfig/tkgen.c
gcc -g tkparse.o tkcond.o tkgen.o -o tkparse.exe
./tkparse.exe config.in ../.. > main.tk
make[1]: Leaving directory `/home/user/GRLIB/designs/leon3-gr-xc3s-1500'
cat ../../bin/tkconfig/header.tk main.tk ../../bin/tkconfig/tail.tk > lconfig.tk
chmod a+x lconfig.tk
As can be seen from the output above, the change of config.in triggered a re-build of tkparse.exe and
lconfig.tk. tkparse.exe is used to parse the .in files and lconfig.tk is what is executed when issuing
make xconfig. In order to rebuild tkparse.exe the system must have a working copy of the GNU C
compiler installed.
Under some circumstances the menus may not be rebuilt after config.in has been modified. If this
happens try to issue touch config.in or remove the file lconfig.tk.
Now that the xconfig menus have been re-built we can check under Peripherals > UART, timer, I/O
port and interrupt controller to see our newly added entries for the I2C2AHB core. Once we save and
exit the xconfig tool a new config.vhd file will be generated that now also contains the constants
defined in i2c2ahb.in.vhd:
These constants can now be used in all files that include the work.config VHDL package.
Cobham Gaisler AB
Kungsgatan 12
411 19 Göteborg
Sweden
www.cobham.com/gaisler
[email protected]
T: +46 31 7758650
F: +46 31 421407
Cobham Gaisler AB, reserves the right to make changes to any products and services described herein at any
time without notice. Consult Cobham or an authorized sales representative to verify that the information in
this document is current before using this product. Cobham does not assume any responsibility or liability
arising out of the application or use of any product or service described herein, except as expressly agreed to
in writing by Cobham; nor does the purchase, lease, or use of a product or service from Cobham convey a
license under any patent rights, copyrights, trademark rights, or any other of the intellectual rights of Cobham
or of third parties. All information is provided as is. There is no warranty that it is correct or suitable for any
purpose, neither implicit nor explicit.