Hardware Modeling with MATLAB Code
You can write MATLAB code to model state machines and implement hardware elements such as counters and RAM for HDL code generation. When authoring the code, follow for loop best practices and guidelines to write efficient MATLAB code to generate HDL code.
Model for HDL Code Generation
To write MATLAB code that models hardware and is suitable for HDL code generation, use this design pattern.
The following design pattern shows MATLAB examples of Mealy and Moore state machines which are suitable for HDL code generation.
This example shows how to use persistent variables and System objects to model state and delays in a MATLAB® design for HDL code generation.
The following example shows how to use local functions in MATLAB, so that each execution of a local function corresponds to a separate hardware module in the generated HDL code.
You can write MATLAB code that maps to RAM during HDL code generation by using:
To map a matrix constant to ROM:If your MATLAB code meets these requirements, HDL Coder™ inserts a no-reset register at the output of the matrix in the generated code.
Best Practices and MATLAB Test Bench
Guidelines for writing efficient MATLAB code and design requirements for efficient HDL code generation.
HDL Coder supports bit shift, bit rotate, bit slice operations that mimic HDL-specific operators without saturation and rounding logic.
Best practices when using for loops in your MATLAB code for HDL code generation.
What is a MATLAB test bench, requirements and best practices for HDL code generation.