Waveform Block Equations can also be used to generate random digital and analog data.
Generate a Digital Signal with Random Values
•Add a new signal and draw a waveform segment that is about 300ns long. |
|
•Double click on the segment to open the Edit Bus State dialog. •Press the Insert Block button to open the Waveform Equation Block Properties dialog. |
•Change the Sampling Period to 20ns. •Choose Random Integer from the pre-defined equation flyout. •In the code block, change the maxValue to 255. •Press the Ok button to close the dialog and generate the digital signal. •Notice that the digital segments on the signal are 20ns long and the random values are between 255 and 0. |
Display the Signal as Analog:
•Double click on the signal name to open the Signal Properties dialog. •Change the name to Random. •Check the Analog Display box. •Change the MSB to 7 and the LSB to 0. This will make it an 8 bit signal which can display the random values in the 255 to 0 range. •Press the Ok button to close the dialog and display the signal. |