Program Standalone Altera FPGA Development Board from MATLAB
This example shows how to program a standalone FPGA with your MATLAB design, using the FPGA Turnkey workflow.
The target device in this example is an Altera® DE2-115 development and education board.
Before You Begin
To use the FPGA Turnkey workflow, you must:
Have your synthesis tool path set up. To learn how to setup your synthesis tool path, see Synthesis Tool Path Setup.
Connect the target device if you want to program it immediately. If the target device is not connected, you can still generate the programming file.
Create a Project
Create a new folder to hold your project files.
At the MATLAB® command line, open the design and test bench files:
edit mlhdlc_turnkey_led_blinking.m edit mlhdlc_turnkey_led_blinking_tb.m
Save copies of the design and test bench files to your new project folder.
Change directory to your new project folder.
At the MATLAB command line, enter:The project creation pane opens.
For Name, enter
myproject.prjand click OK.
Under MATLAB Function, click Add MATLAB Function and select
Under MATLAB Test Bench, click Add files and select
Click the Workflow Advisor button to open the HDL Workflow Advisor.
Convert Design To Fixed-Point
Right-click the Define Input Types task and select Run This Task.
In the Variables tab, for the
freqCountervariable, in the Proposed Type column, enter
numerictype(0, 27, 0)to set the type to unsigned 27-bit integer.
On the left, right-click the Fixed-Point Conversion task and select Run This Task.
Map Design Ports to Target Interface
In the Select Code Generation Target task, select the FPGA Turnkey workflow and Altera DE2-115 development and education board as follows:
For Workflow, select FPGA Turnkey.
For Platform, select Altera DE2-115 development and education board. If your target device is not in the list, select Get more to download the support package.
The coder automatically sets Chip family, Device, Package, and Speed according to your platform selection.
For FPGA clock frequency, for both Input and System, enter 100.
In the Set Target Interface task, map the design input and output ports to interfaces on the target device by setting the fields in the Target Platform Interfaces column as follows:
Blink_frequency_1to User-defined Push-button Switch [0:3]
Blink_directionto Slide Switch [0:17]
LEDto LED Green [0:8]
You can leave the
The HDL Workflow Advisor applies your settings immediately.
Generate Programming File and Download To Hardware
You can generate code, perform synthesis and analysis, and download the design to the target hardware using the default settings:
For the Synthesis and Analysis task group, uncheck the Skip this Step option.
For the Download to Target task group, uncheck the Skip this Step option.
Right-click Download to Target > Generate Programming File and select Run to Selected Task.
If your target hardware is connected and ready to program, select the Program Target Device subtask and click Run.