You are on page 1of 31

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
that the function works as
intended
To do this just click on the
Run button in the Editor tab

http://appliedelectronicsengineering.blogspot.com

Editor
Tab

Run

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

You might also like