In the TSTE16 course, we have started to look at the system and how to create a test-driven environment. There are – I guess – some different options that you can choose as starting point: 1) either you drive the top-level in matlab only or 2) you use matlab and cadence together.
In fact, I would suggest to start looking at the system from matlab only, since in this case we are able to quickly and swiftly change parameters such as the number of bits in the ADC and number of bits in the DAC.
Anyway, this post is about the command ocnPrint in cadence. This enables you to save waveform data to file, which can be read by Matlab. A good way to check intermediate nodes in Cadence inside your Matlab world.
The syntax is found by typing
help ocnPrint in the CIW. Let’s see:
ocnPrint( [?output t_filename | p_port] [?precision x_precision] [?numberNotation s_numberNotation] [?numSpaces x_numSpaces] [?width x_width] [?from x_from] [?to x_to] [?step x_step] o_waveform1 [o_waveform2 ...] )
An example would then be:
( ocnPrint ?output "./tste16ProjDac/m/dacOutputWaveform.txt" ?precision 16 ?from 0 ?to tStopTime ?step tSample (VT "/dacOutput") )
Notice the two variables,
tSample as well as my choice of node name, of course you need to pick what suits your test bench.
tStopTime is the stop time of your simulation or whatever range you want. and
tSample is the kind-of virtual sample frequency at which you want to observe data. For example, choose a big number, some 128 times the DAC and ADC sample frequencies. If you can, also try to maintain coherent sampling.
Paste the command into the CIW and check the file. Try out and comment, please. Possibly you want to add more waveforms to the file (see the help) or change the precision — make sure you have the required accuracy to meet your system spec!)
Also notice that you will get some “u” and “n” or “p”, etc., you might need to apply a function in matlab to clear that up for you. Possibly do a search and replace in emacs.