Hardware Modeling with MATLAB Code

MATLAB® design and test bench guidelines for HDL code generation

Functions

hdl.RAMSingle, simple dual, or dual-port RAM for memory read/write access
hdl.BlackBoxBlack box for including custom HDL code

Topics

Model for HDL Code Generation

Model a Counter for HDL Code Generation

This design pattern shows a MATLAB example of a counter, which is suitable for HDL code generation.

Model a State Machine for HDL Code Generation

The following design pattern shows MATLAB examples of Mealy and Moore state machines which are suitable for HDL code generation.

Model State with Persistent Variables and System Objects

This example shows how to use persistent variables and System objects to model state and delays in a MATLAB® design for HDL code generation.

Generate Hardware Instances For Local Functions

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.

Implement RAM Using MATLAB Code

You can write MATLAB code that maps to RAM during HDL code generation by using:

Map Matrices to ROM

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.

Bitwise Operations in MATLAB for HDL Code Generation

HDL Coder supports bit shift, bit rotate, bit slice operations that mimic HDL-specific operators without saturation and rounding logic.

Hexadecimal and Binary Values (MATLAB)

Specify hexadecimal and binary values either as literals or as text. Hexadecimal and binary literals are stored as integers. You can convert text representing hexadecimal and binary values to numbers, and numbers to text representations.

Best Practices and MATLAB Test Bench

Guidelines for Writing MATLAB Code to Generate Efficient HDL Code

Guidelines for writing efficient MATLAB code and design requirements for efficient HDL code generation.

For-Loop Best Practices for HDL Code Generation

Best practices when using for loops in your MATLAB code for HDL code generation.

MATLAB Test Bench Requirements and Best Practices for HDL Code Generation

What is a MATLAB test bench, requirements and best practices for HDL code generation.