This introduction will walk you through the process of creating a MicroBlaze system for an Opal Kelly XEM3010-1500P. The sample OPB peripheral provides communication to the PC via USB and our FrontPanel API. Full behavioral simulation is also established along with hardware debug support through the Xilinx SDK.
The MicroBlaze core is compiled in Xilinx ISE as a stub device to allow top level attachment to the Opal Kelly HostInterface. This in turn allows for other logic in the FPGA fabric external to the MicroBlaze soft core to also utilize the same FrontPanel connection.
Note: This introduction is not intended to be a tutorial on FPGA design or on using Xilinx ISE, EDK, SDK, or ModelSim software. Rather, it was written to help quickly identify the core stages of Xilinx EDK development and to highlight one possible way to implement a connection between FrontPanel and a Xilinx FPGA embedded processor.
This introduction is divided into five parts:
C:\Work\XilinxEDK\FP3Sample1_XPS\system.xmp. Make sure to use a location with no spaces in the location.\FrontPanel\FrontPanelHDL\XilinxEDK to a directory structure with no spaces in the name. Default will be C:\Work\XilinxEDK\Repository.Next.Next.Next.Next.OK.Next.Generate.Finish.Project Information Area, select the IP Catalog tab. Under Peripheral Repositories, double click on okMicroInterface. Select Yes to add the IP.System Assembly view, you should now see the okMicroInterface_0 peripheral. With the Bus Interface Filter selected, expand the okMicroInterface_0 peripheral to expose its bus connection. Select the connection and pull down to connect the peripheral to the mp_opb bus. This is the default name given to the OPB bus, which in turn should be connected to the OPB controller and the debug_module.mp_opb controller was not added to your design, manually do so. The DOPB and IOPB bus connections to the MicroBlaze core should also be connected to this bus.Project Information Area, select the Project Tab and double click on the system.mhs to open it up. Altering port connections here is easier than doing it in the GUI. PORT sys_clk_pin = dcm_clk_s, DIR = I, SIGIS = CLK, CLK_FREQ = 65000000
PORT sys_rst_pin = sys_rst_s, DIR = I, RST_POLARITY = 0, SIGIS = RST
PORT ti_clk = ti_clk, DIR = I
PORT ok1 = ok1, DIR = I, VEC = [30:0]
PORT ok2 = ok2, DIR = O, VEC = [16:0]
PORT led = led, DIR = O, VEC = [7:0]
microblaze block needs to have the following line added (you may put this just below the other PORTs listed but before the END):PORT INTERRUPT = interrupt
system.mhs, make sure the okmicrointerface block shows: BEGIN okmicrointerface
PARAMETER INSTANCE = okmicrointerface_0
PARAMETER HW_VER = 3.00.a
BUS_INTERFACE SOPB = mb_opb
PARAMETER C_BASEADDR = 0x40000000
PARAMETER C_HIGHADDR = 0x4000ffff
PORT ok1 = ok1
PORT ok2 = ok2
PORT ti_clk = ti_clk
PORT led = led
PORT IP2INTC_Irpt = interrupt
END
Ctrl-S to save the changes to the system.mhs file. This will update the design. Close the file.System Assembly View, select the Address Filter in the System Assembly. Make sure the Base Address of okMicroInterface_0 is 0×40000000 and the High Address is 0x4000FFFF.Software Platform selected on the left, under Processor Parameters change the current value of CORE_CLOCK_FREQ_HS to 65000000 and change xmdstub_peripheral to none. The processor won’t boot properly unless you remove the debug_module from the xmdstub_peripheral.Interrupt Handlers selected on the left, change the Interrupt Handler for IP2INTC_Irpt to Test_Interrupt. This will point the interrupt routine to the function Test_Interrupt in our SDK project. Select OK.C:\Work\XilinxEDK\FP3Example_ISE\ISE_Proj.iseokLibrary.vhd from \FrontPanel\FrontPanelHDL\XilinxISE82\ into the local ...\FR3Example_ISE directory....\FR3Example_ISE as well.ok_system_stub.vhd, and xem3010_edk.ucf to XPS data directory at C:\Work\XilinxEDK\FP3Sample_XPS\data.okLibrary.vhd, fifo16_to_32_fwft.xco, fifo32_to_16.xco, ok_system_stub.vhd, and xem3010_edk.ucf/system.xmp file in the C:\Work\XilinxEDK\FP3Sample_XPS directory to ISE as a source as well.ok_system_stub.vhd should have been setup as the toplevel file. Select this file an double click on Generate Programming File underneath the Processes menu. You will be asked to recompile the Coregen FIFOs.Processes window double-click Manage Cores to work with the XCO files.Manage Cores will open the Xilinx CORE Generator. These FIFOs were originally FIFO Coregen Version 3.2. If you have newer or older IP, you may need to recustomize them here to update the files. You may also change the size of the FIFO to better fit your design. Doing so might change the size of some of the status registers and they will have to be altered in user_logic.vhd file in the okMicroInterface peripheral.ok_system_stub.bit file in the C:\Work\XilinxEDK\FP3Sample_ISEdirectory. This bit file must still be infused with the executable data that will be placed in the Block RAM used for program storage.C Application Project with automatic Makefile and select Next. Name the project FP3Sample_SDK and hit Finish.Properties. Under C/C++ Build, change Configuration to Release. Select OK.FP3Sample_SDK a temporary folder. In the SDK, select File → Import and choose File system. Hit Next. Browse to your temporary folder and then select main.c, sampleFunctions.c, and microInterface.h. Make sure the Into folder is FP3Sample_SDK. Select Finish. Ignore any overwrite warnings.FP3Sample_SDK.elf executable file. The default settings for the SDK is to rebuild the application automatically on any file save or addition. In any case, make sure the application has been built properly.Project Information Area, select the Applications tab. Right click on each of the projects here and make sure none of them have a check mark by Mark to initialize BRAMs.Applications tab, double click on Add Software Application Project...” and give the project the name FP3Sample_SDK. Check the Project is an ELF-only Project box and browse to your new .elf file in C:\Work\XilinxEDK\FP3Sample_XPS\SDK_projects\FP3Sample_SDK\Release. Select OK.FP3Sample_SDKand make sure Mark to initialize BRAMs is checked.Processes window, double click on Update Bitstream with Processor Data.FP3Sample_SDK.elf file data is intelligently combined with the ok_system_stub.bit file. This creates the final bit file in ISE project directory called ok_system_stub_download.bit. This file will boot this MicroBlaze core in a XEM3010-1500P and run the executable code we compiled.We’re now ready to start working with the MicroBlaze system.
Configure FPGA icon and navigate to ok_system_stub_download.bit. The MicroBlaze core should now be running if the sys_clk1 is correct.Load Profile icon and navigate to the FP3Sample_EDK.xfp file. You can find this file in the main archive.Now hardware debugging will be performed with a Xilinx Platform Cable USB, the JTAG header on the XEM3010, the ODP Hardware Debug Module (debug_module) built into the MicroBlaze core, and Xilinx SDK all working in concert.
Connection Type that Hardware is selected and then click on Save.Configuration mode is Debug, the Optimization Level” is set to “No Optimization, and the Debug Level has Generate Debug symbols (-g) enabled. Rebuild the .elf file if anything has changed and go back to ISE and once again double-click under Processes the option Update Bitstream with Processor Data. You may need to right-click on this option and select Re-run to make it fully process (ISE doesn’t always detect changes in the XPS or SDK projects correctly). Make sure the latest ok_system_stub_download.bit is configured in the XEM3010 with FrontPanel.Xilinx C/C++ ELF is selected, along with the Perspectives Debug: Debug and Run: None. Click New.FP3Sample_SDK should have been made. Under the Main tab, make sure the project is FP3Sample_SDK and the C/C++ Application is Debug/FP3Sample_SDK.elf. Under the XMD Target Connection tab, the target connector should be XMD target debug agent, and the target type should be MicroBlaze Hardware (OPB_MDM). Click Apply followed by Debug.Yes. We are now hardware debugging the SDK Sample project and should be frozen near the top of main.c Select Run → Resume to continue processing. You may now set break points, make changes in the FrontPanel XML profile while tracing changes in the Debug SDK, etc. Enjoy your debugging.If you have ModelSim 6 SE or PE, XPS can generate simulation files directly. If you have another simulator such as Aldec ActiveHDL, simulation is still possible but will require more work. Check with your tool provider for more assistance. For a more detailed explanation of how FrontPanel Simulation works, please see Part IV of the online tutorial here.
Before beginning, a free license and installation of IBM CoreConnect is required. This small package allows IBM Bus Functional Models (BFM) to be generated. IBM owns some of the bus technology used in these embedded processors, so this is required. Search Xilinx.com for IBM CoreConnect to find the latest link for registration and download the BFM package.
Also, the Flash_LEDs function in the SDK project has a long delay count which would take exceedingly long in simulation. The easiest way to alleviate this is to comment out the delay line:
//for (count = 0; count < Delay; count++);
or simply removed calls to Flash_LEDs (or pass in the number 0 to see a quick sweep in simulation).
Save this change and rebuild the application.
C:/Installed/SimLibs/ISE/, the SmartModels are in \Xilinx81\smartmodel\nt\installed_nt, and the EDK HDL libraries are in C:/Installed/SimLibs/EDK/.C:\Work\XilinxEDK\FP3Sample_XPS\simulation\behavioral with most of the files necessary for simulation, along with a few do files that aid in the compilation and instantiation of the simulation. The file system_init.vhd contains the Block RAM initialization information derived from the latest FP3Sample_SDK.elf file. However, a few changes will have to be made before we’re ready to simulate.\simulation\behavioral in the archive to this new local behavioral simulation folder. You should copy: ok_system_tf.vhd, ok_system.do, ok_setup.do, wave.do, fifo32_to_16_fwft.vhd, and fifo32_to_16.vhd.Manage Cores in ISE) to be structural simulation files. Xilinx behavioral models for FIFOs are not cycle accurate. The files included are structural Xilinx IP FIFO’s version 3.2 and they work well in a behavioral simulation.ok_system.do is a superset of the commands in the XPS generated system.do, while ok_setup.do is basically a simplified and modified system_setup.do.user_logic.vhd and okMicroInterface.vhd will have to be edited in ok_system.do to reflect the location where the Opal Kelly EDK Repository was copied. The location to the EDK simulation libraries will have to be altered as well. Copy these lines from the correctly generated locations in XPS generated system.do.system.do to ok_system.do.do ok_setup.do
ok_system.do and entering s with start the simulation and open the waveform settings detailed in wave.do. Enter both of these commands, one at a time, in order now. The simulation should be initialized and ready to run. Typing run 670us into the transcript will run the simulation through a few basic processes.ok_system_tf.vhd. If you are only making changes to this file, rerun simulation by running o and then s consecutively in the transcript.FP3Sample_SDK.elf, regenerate the simulation HDL files in XPS, and then recompile and run the simulator with the two main alias keys, c and s. We are now free to simulate not just code modifications in the SDK that run on the MicroBlaze processor, but also to make changes in the ok_system_tf.vhd file to simulate how a FrontPanel PC application with interface to the core through our OPB peripheral.Below is a collection of tips for improving the work flow of the entire EDK suite.
ok_system_stub.bit file. All changes will only be in the software SDK. This same bit file is simply initialized with the bit steam from the SDK .elf file within ISE. After any change and recompilation in the SDK, go back to ISE, double-click under Processes the option Update Bitstream with Processor Data. You may need to right-click on this option and select Re-run to make it fully process (ISE doesn’t always detect changes in the XPS or SDK projects correctly). print command. For instance, clicking on Trig 0×40 (4) will output the message “ISR 4”. If you do not have a hardware debug module connected to the MicroBlaze core and repeatedly hit this trigger, the output buffer will overflow and lock the processor. Of course, this can be prevented in code.