Be the first to rate this file! 103 downloads (last 30 days) File Size: 10.29 KB File ID: #18727

Computing "mod" using embedded MATLAB

by Kiran Kintali

 

12 Feb 2008 (Updated 14 Aug 2008)

Code covered by BSD License  

This demo shows how to use embedded MATLAB to compute mod3 of a number in a hardware friendly fashio

Download Now | Watch this File

File Information
Description

Hardware design and implementation of an algorithm is all about finding alternatives to achieve some design goals like higher performance, low area or low power etc.,

Often when designing hardware algorithms one would stumble upon an expensive operation like division or modulo and would be hard pressed to replace it with a low cost alternative like repeated subtraction to meet the design goals.

Consider (m mod n) operation as shown below

 (m mod n) = (m - (n * floor(m/n))

In the above expression division operator consumes lots of FPGA resources and creates long critical paths reducing performance of the algorithm.

This demo shows how to compute modulo of in a hardware friendly fashion by avoiding expensive division. It shows how to compute mod3 of a 32 bit number as a tree of mod3 operations on a 4bit numbers which can be implemented as an inexpensive multiplexer.

This algorithm breaks the binary number (m) into equal number of chunks and computes modulo(n) on the smaller chunks, concatenates the resultant values and repeats;

This algorithm uses bitslice and bitconcat functions to extract smaller chunks (nibbles in this case) and a simple switch to calculate the mod3 of a 4bit slice;

Required Products Fixed-Point Toolbox
MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
14 Feb 2008

.

14 Aug 2008

add to eML category

Tag Activity for this File
Tag Applied By Date/Time
embedded matlab Kiran Kintali 22 Oct 2008 09:47:27
hdl Kiran Kintali 22 Oct 2008 09:47:27
fpga Kiran Kintali 22 Oct 2008 09:47:27
modulo Kiran Kintali 22 Oct 2008 09:47:27
embedded matlab Kiran Kintali 22 Oct 2008 09:47:27
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com