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

  • Download
  • Add to my manuals
  • Print
  • Page
    / 410
  • Table of contents
  • TROUBLESHOOTING
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 327
328 www.xilinx.com System Generator for DSP User Guide
UG640 (v 12.2) July 23, 2010
Chapter 4: Importing HDL Modules
bidi_port.setGatewayFileName('bidi.dat');
end
In the above example, a text file "bidi.dat" is used during simulation to provide stimulation
to the port. The data file should be a text file, where each line represents the signal driven
on the port at each simulation cycle. For example, a 3-bit bi-directional port that is
simulated for 4 cycles might have the following data file:
ZZZ
110
011
XXX
Simulation will return with an error if the specified data file cannot be found.
Configuring Port Sample Rates
The black box block supports ports that have different sample rates. By default, the sample
rate of an output port is the sample rate inherited from the input port (or ports, if the inputs
run at the same sample rate). Sometimes it is necessary to explicitly specify the sample rate
of a port (e.g., if the output port rate is different than the block's input sample rate).
Note:
When the inputs to a black box have different sample rates, you must specify the sample rates
of every output port.
SysgenPortDescriptor provides a method, setRate, which allows you to explicitly set the
rate of a port.
Note:
The rate parameter passed to the setRate method is not necessarily the Simulink sample rate
of that the port runs at. Instead, it is a positive Integer value that defines the ratio between the desired
port sample period and the Simulink system clock period defined by the System Generator block
dialog box.
Assume you have a model in which the Simulink system period value for the model is
defined as 2 sec. Also assume, the example dout port is assigned a rate of 3 by invoking
the setRate method as follows:
dout.setRate(3);
A rate of 3 means that a new sample is generated on the dout port every 3 Simulink system
periods. Since the Simulink system period is 2 sec, this means the Simulink sample rate of
the port is 3 x 2 = 6 sec.
Note:
If your port is a non-sampled constant, you may define it as so in the configuration M-function
using the setConstant method of SysgenPortDescriptor. You can also define a constant by passing
Inf to the setRate method.
Dynamic Output Ports
A useful feature of the black box is its ability to support dynamic output port types and
rates. For example, it is often necessary to set an output port width based on the width of
an input port. SysgenPortDescriptor provides member variables that allow you to
determine the configuration of a port. You can set the type or rate of an output port by
examining these member variables on the block's input ports.
For example, you can obtain the width and rate of a port (in this case din) as follows:
input_width = this_block.port('din').width;
input_rate = this_block.port('din').rate;
Note: A black box's configuration M-function is invoked at several different times when a model is
compiled. The configuration function may be invoked before the data types and rates have been
propagated to the black box.
Page view 327
1 2 ... 323 324 325 326 327 328 329 330 331 332 333 ... 409 410

Comments to this Manuals

No comments