MATLAB DESIGN HDL CODER RELEASE NOTES User's Guide Page 63

  • Download
  • Add to my manuals
  • Print
  • Page
    / 410
  • Table of contents
  • TROUBLESHOOTING
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 62
System Generator for DSP User Guide www.xilinx.com 63
UG640 (v 12.2) July 23, 2010
Compiling MATLAB into an FPGA
state = seen_10;
end
case seen_10 % seen 10
if din==1
state = seen_101;
else
% no part of sequence seen, go to seen_none
state = seen_none;
end
case seen_101
if din==1
state = seen_1;
matched = true;
else
state = seen_10;
matched = false;
end
end
The following diagram shows a state machine subsystem containing a MCode block after
compilation; the MCode block uses M-function detect1101_w_state.
Parameterizable Accumulator
This example shows how to use the MCode block to build an accumulator using persistent
state variables and parameters to provide implementation flexibility. The following M-
code, which defines function xl_accum is contained in file xl_accum.m:
function q = xl_accum(b, rst, load, en, nbits, ov, op,
feed_back_down_scale)
% q = xl_accum(b, rst, nbits, ov, op, feed_back_down_scale) is
% equivalent to our Accumulator block.
binpt = xl_binpt(b);
init = 0;
precision = {xlSigned, nbits, binpt, xlTruncate, ov};
persistent s, s = xl_state(init, precision);
q = s;
if rst
if load
% reset from the input port
s = b;
else
% reset from zero
s = init;
Page view 62
1 2 ... 58 59 60 61 62 63 64 65 66 67 68 ... 409 410

Comments to this Manuals

No comments