VHDL
Matlab to VHDL
Code Conversion
A Tutorial by:
http://appliedelectronicsengineering.blogspot.com
Introduction
In this tutorial we show how a to write a
Matlab function code and covert it to a VHDL
code. We will write a simple multiplexer
code for the purpose of illustration.
Send Feedback to:
http://appliedelectronicsengineering.blogspot.com
Step1: Create a Function File
• Create a new Project in Matlab
and create a Function File
named mux_func(a,b,sel)
• Save the function file with name
mux_func.m
http://appliedelectronicsengineering.blogspot.com
Step 2: Create a script file
• Create another script file enter
the code as shown
• Save the script file with some
name like test.m
• This script file is used to test the
function mux_func that was
created earlier
http://appliedelectronicsengineering.blogspot.com
Step 3: Run the Test file
• Run the test file to ensure
Editor
that the function works as Run
Tab
intended
• To do this just click on the
Run button in the Editor tab
http://appliedelectronicsengineering.blogspot.com
Step 4: Select HDL Coder
Select the APPS tab and click on the HDL Coder
Step 5: Specify Project Name to your
HDL Code Project
Once you click the HDL coder in step 4 a window will pop up just like the
one below where you can specify a project name for you HDL coder
project with the name of your choosing. In this case mux_hdl was given
as project name
Step 6: Select File to Convert
The HDL Coder screen will open as shown
http://appliedelectronicsengineering.blogspot.com
Browse for the Files
Click here to Add
MATLAB function
Add the function file
mux_func to convert
Browse and select the mux_func function file
Click on
WorkFlow
Advisor
Similarly add the test.m file
Step 7: Convert matlab function to HDL using
Workflow Advisor