Generate Bitstream and Program FPGA
Now that you have prepared your model for IP core generation, you can proceed to generate a bitstream and load it onto the FPGA of your radio device. The bitstream is a file that contains all the information required to implement the HDL code you generated for your algorithm on the FPGA of your radio device. The Build Bitstream option automatically handles the IP core generation, so you do not need to run Generate IP Core beforehand.
When you have successfully generated a bitstream for your design, you can proceed to the Generate Host Interface Scripts step. The generated scripts include MATLAB® code that will program the FPGA with your bitstream. To program the FPGA from Simulink®, follow the steps in Program Target Device.
Generating a deployable algorithm is an iterative process. If you return to the Map Target Interfaces step to modify the sink or source connection of a data streaming interface, you can regenerate the hand-off information file without rebuilding the bitstream. For details, see Regenerate Hand-Off Information File. For any other change to the model or the interface mapping table, you must rebuild the bitstream.
Build Bitstream
To generate a bitstream, first open the deployment settings from the Build Bitstream dropdown menu and ensure that the Run build process externally option is selected. This setting is the default and it ensures that the bitstream build executes in an external shell, which allows you to continue using MATLAB while building the FPGA image.
Click Build Bitstream to create a Vivado® project, generate the IP core, and build a bitstream. The build performs basic
project checks, and then the Diagnostic Viewer displays Build Bitstream
Successful
, along with warning messages. The bitstream build continues in the
external shell. This process can take some time. Wait until the external shell indicates a
successful bitstream build before continuing to the next step.
Note
Closing the external shell before the bitstream build is complete terminates the build.
The build creates the following files:
The hand-off information file,
<modelName>_wthandoffinfo.mat
, is generated in the project folder that you set up in the Configure HDL Code Generation Settings step. This MAT-file describes the DUT interfaces.The bitstream file, a
.bit
file, is generated in the project folder, for example,<projectFolder>/build_N320_HG/build-N320_HG/n3xx.bit
.The device tree file, a
.dts
file, is generated in the project folder, for example,<projectFolder>/build_N320_HG/build/usrp_n320_fpga_HG.dts
. If your radio is an NI™ USRP™ X310, the build does not create this file.
To build a bitstream, your host must have enough memory. The size of the bitstream depends on the complexity of your design and the target NI USRP radio device.
Radio Device | RAM Required for a Typical Bitstream |
---|---|
USRP N310 | 9GB |
USRP N320 | 8GB |
USRP N321 | 8GB |
USRP X310 | 8GB |
USRP X410 | 21GB |
Note
If your bitstream build terminates prematurely with the error "make[1]:
/bin/sh: Argument list too long
", specify a project directory with a shorter path.
Return to the Workflow Settings step.
Update the Project Folder configuration parameter. Specify an absolute path that is relatively short. For example, "
/home/user/prj
".
Regenerate Hand-Off Information File
If you return to the Map Target Interfaces step to modify the sink or source connection of a data streaming interface, you can regenerate the hand-off information file without rebuilding the bitstream.
In the Build Bitstream dropdown menu, select Create IP
Core Project. This overwrites the existing hand-off information file,
<modelName>_wthandoffinfo.mat
, in the project folder that you set
up in the Configure HDL Code Generation Settings step.
When you regenerate the hand-off information file, you must return to the Generate Host Interface Scripts step.
Program Target Device
You can program the FPGA on your radio device with your bitstream in MATLAB using the interface script file generated in a later step, Generate Host Interface Scripts, or in the Command Window
with the programFPGA
function.
To program the FPGA on your radio with your bitstream in Simulink, from the HDL Code tab, open the Deployment Settings window from the Build Bitstream dropdown menu and expand the Program Target Device settings. The IP address is set to the default value for your radio. If you changed the IP address from the default value when you set up your radio using the Radio Setup wizard, update this field with the correct IP address. Then, click Program Target Device in the Build Bitstream dropdown menu.
The Diagnostic Viewer informs you of the progress. For example:
### Programming target FPGA ... Loading bitstream to FPGA... Loading bitstream to FPGA is not complete. Programming target device successful.
If your radio is a USRP X310, this takes approximately five minutes. For other radios, it takes less than a minute.