Bus Functional Model (BFM) Simulation
Bus Functional Model (BFM) Simulation
Summary This note provides the flow for simulating Processor Intellectual Property (PIP) cores using Bus
Functional Models (BFMs). The PIP cores used as examples include a new core, existing
cores, and a sample system core. The simulation results of the OPB GPIO core are given to
illustrate the capability of a BFM simulation. An introduction to writing stimuli for BFM simulation
using a Bus Functional Language (BFL) in conjunction with a VHDL test bench is given.
The example designs are intended to aid in the understanding the functionality of PIP cores.
The comments in the code indicate the function being verified. The user can learn techniques
for writing test benches/BFLs by reading and re-using the example code. The references
provide information for users interested in writing complex or exhaustive test bench/BFLs.
Introduction Xilinx manufactures FPGAs which contain IBM Power PC™ hard processors on Virtex™ -II Pro
and Virtex-4 families. Xilinx also offers the MicroBlaze™ soft core processor, which can be
used in either Spartan™ or Virtex families. The Power PC processor interfaces to PIP
peripherals using the IBM CoreConnect buses, including the Processor Local Bus (PLB), On-
chip Peripheral Bus (OPB), and the Device Control Register (DCR) bus. The Microblaze soft
core processor uses the OPB. The BFMs discussed in this note model transactions on the PLB
and OPB buses.
The Xilinx EDK Bus Functional Language (BFM) package is not included in EDK. The BFM
package can be downloaded at no charge after obtaining a license for the IBM CoreConnect
Bus Architecture. To obtain a license for CoreConnect, complete the form at
http://www.xilinx.com/ipcenter/processor_central/register_coreconnect.htm. Once the request
has been approved (typically within 24 hours), an e-mail granting access to the protected web
site provides instructions on downloading the toolkit.
The traditional form of simulation, shown in Figure 1, uses a test bench to generate stimuli to,
Processor IP VHDL
Core Test Bench
xapp516_01_050806
and to check the results from, a device under test (DUT), the PIP core. In the BFM simulation
shown in Figure 2, the PIP core interfaces to the microprocessor bus on one side and to
external pins on the other side. The BFM is used to model the microprocessor bus side. As with
© 2006 Xilinx, Inc. All rights reserved. All Xilinx trademarks, registered trademarks, patents, and further disclaimers are as listed at http://www.xilinx.com/legal.htm. PowerPC is a
trademark of IBM Inc. All other trademarks and registered trademarks are the property of their respective owners. All specifications are subject to change without notice.
NOTICE OF DISCLAIMER: Xilinx is providing this design, code, or information "as is." By providing the design, code, or information as one possible implementation of this feature,
application, or standard, Xilinx makes no representation that this implementation is free from any claims of infringement. You are responsible for obtaining any rights you may require
for your implementation. Xilinx expressly disclaims any warranty whatsoever with respect to the adequacy of the implementation, including but not limited to any warranties or
representations that this implementation is free from claims of infringement and any implied warranties of merchantability or fitness for a particular purpose.
traditional simulation, a VHDL test bench generates stimuli to, and checks results from, the PIP
core. A Bus Functional Language (BFL) provides a method to read and write the registers of
the PIP core. The BFL configures the BFM to generate stimuli to and check results from the bus
side.
Using a BFM provides an efficient means of including bus transactions in simulation. It is
simpler to generate bus transactions using a BFM than an actual microprocessor model
because there is no C code involved. A designer need know only the addresses of the PIP
registers and the bus operation. Knowledge of the microprocessor architecture, instructions,
registers, and ports is not required. The use of a BFM allows control over bus transactions,
transaction spacing, and the ability to simulate abnormal transactions, such as aborts, retries,
and errors.
xapp516_02_050806
Synchronizing Stimuli
Either the BFM or the VHDL test bench interfaces with the PIP core at a time. There are
handshaking signals between the BFM and the test bench which ensure that the BFM-PIP core
and VHDL test bench-PIP core interfaces are synchronized. In a typical simulation of the
microprocessor writing to a peripheral, the BFM writes to the control registers of the PIP core,
causing the PIP core to perform some function, then the VHDL test bench verifies the function
by reading the PIP output. In a simulation of the PIP core generating data for the
microprocessor to read, the test bench generates external stimuli to the PIP core, then the BFM
does a read operation to verify that the PIP core produces the expected results.
Examples for BFM simulation are provided in the bfm_simulation.zip file. The first example,
opb_myled_cntlr, is a BFM simulation of a new IP core using Create IP wizard. It is a simple
example, providing limited BFL - VHDL test bench code. The second set of examples are
existing PIP cores. The reason for simulating existing peripherals is that they provide good
examples of BFL-VHDL test benches generating BFL - VHDL test bench stimuli.
Running BFM To run BFM simulation on an existing core, unzip bfm_simulation.zip and change to a core’s
Simulation simulation/behavioral directory. Invoke Modelsim, edit the path to the test bench in
bfm_system.do if necessary, and run
do ../../scripts/run.do
This provides a complete functional simulation of the core. The <core>_tb.vhd and <core>.m4
files provide stimuli. Comments in these files indicate the test performed. The wave.do file adds
the signals and generics needed to understand the operation of the core.
Developing a This section provides the steps used in developing a BFM simulation of the OPB GPIO.
BFM Simulation 1. Create a directory named designs/opb_gpio_bfm. From XPS, do the following.
Using Create IP Invoke Hardware -> Create/Import User Peripheral and select Create templates for a
Wizard new peripheral
Repository or Project panel : Browse to /designs/opb_gpio_bfm
Core Name and Version : Enter opb_gpio for the Name, and 3_01_b for the Version name
Bus Interfaces panel : Select OPB.
Understanding This section describes the simulation results of the OPB GPIO core. A common use of the OPB
BFM Simulation GPIO core is to provide output register interfaces to LEDs and input register interfaces to
switches. This example shows external stimuli generated by the VHDL test bench and checked
Results by the BFM. It then shows stimuli generated by the BFM and checked by the VHDL test bench.
It also shows the synchronization signals used in the simulation.
The GPIO is configured with C_IS_DUAL = 0, C_INTERRUPT_PRESENT = 1, and
C_GPIO_WIDTH = 32, the generic values in the opb_gpio_defs.m4, and
opb_gpio_tb_v3_01_b.vhd files. The signal waveforms below are the result of the stimuli from
the test code in the opb_gpio.m4 and opb_gpio_tb_v3_01_b.vhd files.
As shown in Figure 3, at 250 and 300 ns, the BFM (lines 11:12 in opb_gpio.m4) reads
0x00000000 and 0xFFFFFFFF from the DATA and TRI registers. The test bench writes a status
message to the simulator transcript window indicating the operation performed.
XAPP516_03_050806
As shown in Figure 4, from 350 ns to 650 ns, the opb_gpio.m4 (20:31) prompts the VHDL test
bench to generate input stimuli into GPIO_IO_I. The synchronization pulses occur at 350, 450,
550, and 650 ns. The 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000 input stimuli is
generated by the test bench at 360, 460, 560, 660 ns. Control is transferred to the BFM, and the
BFM verifies that the data register contains the data received from the GPIO_IO_I inputs at
410, 510, 610, and 710 ns.
XAPP516_04_050906
As shown in Figure 5, from 750 ns to 1000 ns, the simulation verifies that the GPIO writes data
correctly to the GPIO_IO_O outputs. The opb_gpio.m4 writes 0x00000000, 0xFFFFFFFF, and
0x00000000 to the data register at 770, 860, and 940 ns. The opb_gpio_tb_v3_01_b.vhd
verifies this data at the GPIO_IO_O output pins, and writes a status message.
XAPP516_05_050906
As shown in Figure 6, from 1660 to 2000 ns, the simulation verifies that interrupts function
correctly. For the GPIO, an interrupt is generated when there is a change in input value on
GPIO_IO_I. The Interrupt Service Register (ISR) is reset at 1580 ns. The BFM enables
interrupts by writing to the IER and GIE at 1630 and 1710 ns. The BFM receives an interrupt at
1840ns. The BFM reads the ISR at 1940 ns.
XAPP516_0_050906
Tools/Methods Figure 7 shows the tools used to develop BFM test code. Generating the BFM test code is done
for Writing BFL by writing either m4 or BFL code. If m4 is used, the GNU m4 processor reads a <core>.m4 and
writes <core>.bfl. The Bus Functional Compiler reads the BFL and writes the simulator specific
simulation commands. The simulator used is specified in the BFC control file (.bfcrc). The
simulator command files are <core>.do and system.sh for ModelSim and NcSim, respectively.
The m4 and BFL files are easier to read and write than the simulator specific command files.
core_defs.m4
<core>.m4 core.do
m4 BFC Simulator
XAPP516_07_050906
OPB GPIO
Bus Functional VHDL
GPIO_IO_I
Model (BFM) Testbench
GPIO_IO_O
xapp516_08_050906
assert_in(1, opb_clk, synch_out(5 to 5)) - VHDL waits for sync pulse from BFL. When
received, the VHDL displays a status message to simulator transcript window.
assert_out(1, opb_clk, synch_out(6 to 6)) - VHDL generates a sync pulse to BFL
indicating that message has been displayed
assign_in(1, opb_clk, synch_in(7 to 7)) - VHDL waits for sync pulse from BFL. When
received, the VHDL generates external stimuli to PIP core.
assign_out(1, opb_clk(synch_out(8 to 8)) - VHDL generates a sync pulse to BFL
indicating external stimuli to PIP core has been generated.
References
assert FALSE report "Checking that data register writes 0's" severity
NOTE;
for abit in 0 to C_GPIO_WIDTH-1 loop
assert GPIO_IO_O(abit) = '0' report "GPIO_IO_O did not write 0's"
severity ERROR;
end loop;
References XAPP515: Using Xilinx m4 Functions to Write BFL Stimuli for CoreConnect™ Buses
GNU m4, version 1.4
Revision The following table shows the revision history for this document.
History
Date Version Revision
05/25/06 1.0 Initial Xilinx release.