Home > Community > Forums > Custom IC Design > How to plot the verilogA module data points using OCEAN

## Email

Recipients email * (separate multiple addresses with commas)

Message *

 Send yourself a copy

## Subscribe

Intro copy of the newsletter section here, some intro copy of the newsletter. Instruction of how to subscribe to this newsletter.

First Name *

Last Name *

Email *

Company / Institution *

 Send Yourself A Copy

# How to plot the verilogA module data points using OCEAN

Last post Fri, Jun 28 2013 5:37 AM by Andrew Beckett. 9 replies.
 Started by RFStuff 21 Jun 2013 06:58 AM. Topic has 9 replies and 1569 views
• #### Fri, Jun 21 2013 6:58 AM

• RFStuff
• Joined on Tue, Feb 5 2013
• Posts 255
• Points 4,510
How to plot the verilogA module data points using OCEAN
 Dear All,I used a verilogA module in my schematic which measures the period of the output  waveform of a block.The verilogA code is as follows:-`include "disciplines.vams"(*instrument_module*)module frequency_meter(in);    parameter real thresh=0;    // threshold (V)    parameter integer dir = 1 from [-1:1] exclude 0;                // 1 for rising edges, -1 for falling    input in;    voltage in;    integer timing;    real t0, t, period, freq;    analog begin    t = last_crossing(V(in) - thresh, dir);    @(cross(V(in) - thresh, dir)) begin        if (timing) begin        period = t - t0;        freq = 1/period;        \$strobe("period = %rs (measured at %rs).\n", t - t0, \$abstime);        end        t0 = t;        timing = 1;    end    endendmodule  I want to plot freq versus time  using OCEAN script. Can anybody please tell how it can be done.I did :save I5:period I5:freqplot(I5:freq).This gives error in OCEAN script.But in input.scs file I worte:-save I5:period I5:freq I ran the simulation and in the wavescan I was able to plot freq-vs-time.     Kind Regards,
• Post Points: 20
• #### Mon, Jun 24 2013 1:54 PM

Re: How to plot the verilogA module data points using OCEAN
 In the spectre netlist, you can add:  myOpts options saveahdlvars=allor in OCEAN you could say:  saveOption( ?saveahdlvars "all" ) And then to reference the freq signal, you'd do:  plot(getData("I5:freq" ?result 'tran))Or you could make the frequency an output pin of the meter instead - but that involves changing it a bit so that you are contributing to a node - for your needs the above is probably sufficient?Best Regards, Andrew.
• Post Points: 20
• #### Wed, Jun 26 2013 2:49 AM

• RFStuff
• Joined on Tue, Feb 5 2013
• Posts 255
• Points 4,510
Re: How to plot the verilogA module data points using OCEAN
 Dear Andrew,Thanks a lot.Now, I am beginner to verilogA coding. I have some doubt regarding the above verliogA code.1:- \$Strobe prints at what instants2:- Looks like it is printing even if there is NO thresold crossKind Regards,
• Post Points: 20
• #### Wed, Jun 26 2013 6:07 AM

Re: How to plot the verilogA module data points using OCEAN
 It should print when there's a threshold crossing and timing==1. That's what I see. Are you sure you don't have threshold crossings?Andrew.
• Post Points: 20
• #### Wed, Jun 26 2013 6:24 AM

• RFStuff
• Joined on Tue, Feb 5 2013
• Posts 255
• Points 4,510
Re: How to plot the verilogA module data points using OCEAN
 Dear Andrew,Theree are thresold crossings. But it is printing ( what is inside  \$strobe )even between the  zero crossings.To me it looks like it is being printed at the end of  each simulation time step ? This I am not able to understand.Kind Regards,
• Post Points: 20
• #### Wed, Jun 26 2013 8:26 AM

Re: How to plot the verilogA module data points using OCEAN
 Can you put together a simple example (just with voltage sources, analogLib res/cap) which shows the problem? Then post the input.scs (also the version of spectre that you're using).Thanks,Andrew.
• Post Points: 20
• #### Thu, Jun 27 2013 11:33 PM

• RFStuff
• Joined on Tue, Feb 5 2013
• Posts 255
• Points 4,510
Re: How to plot the verilogA module data points using OCEAN
 Sorry Andrew,I misinterpreted the result. It is printing as you have mentioned.1:-  I have some doubt regarding the initial parameter value of  "t0" and "timing" in the 1st iteration.2:- Could you please tell what change I have to make to make freq as an output node in the code ?3:- Could you please tell how to plot it in GHz unit instead of GV ? Kind Regards,
• Post Points: 20
• #### Thu, Jun 27 2013 11:53 PM

Re: How to plot the verilogA module data points using OCEAN
 1. The initial values will be 0 - this is in the VerilogAMS language definition.2 & 3 - see the model below. By specifying the output as a frequency discipline, the graph comes out with the right units too (I'd not seen your third point until I'd updated the model, but it solves 3 too...)`include "disciplines.vams"// could specify the fout signal as being electrical// but it's nicer to do it as the specific discipline - this// way we can have a custom abstol and blowup, since the// magnitude of the frequency will be much larger than // voltages in the circuitnature Frequency    units="Hz";    access=Freq;    abstol=1;    blowup=100G;endnaturediscipline frequency    potential Frequency;enddiscipline (*instrument_module*)module frequency_meter(in,fout);    parameter real thresh=0;    // threshold (V)    parameter integer dir = 1 from [-1:1] exclude 0;                // 1 for rising edges, -1 for falling    input in;    voltage in;    output fout;    frequency fout;    integer timing;    real t0, t, period, freq;    analog begin    t = last_crossing(V(in) - thresh, dir);    @(cross(V(in) - thresh, dir)) begin        if (timing) begin        period = t - t0;        freq = 1/period;        \$strobe("period = %rs (measured at %rs).\n", t - t0, \$abstime);        end        t0 = t;        timing = 1;    end    // use a transition filter to ensure that the frequency doesn't    // change discontinuously    Freq(fout) <+ transition(freq,0,100p);    endendmodule  Kind Regards,Andrew
• Post Points: 20
• #### Fri, Jun 28 2013 2:16 AM

• RFStuff
• Joined on Tue, Feb 5 2013
• Posts 255
• Points 4,510
Re: How to plot the verilogA module data points using OCEAN
 Dear Andrew,Thanks a lot.Whether setting abstol and blowup in this code affects the accuracy.Actually, I am seeing some differnece in the frequency plots ( i.e. periodic spike ) in this code as compared to the code ( without having a pin) Kind Regards,
• Post Points: 20
• #### Fri, Jun 28 2013 5:37 AM

Re: How to plot the verilogA module data points using OCEAN
 blowup won't, abstol might. Depends on what frequencies you're dealing with - ideally abstol should be about a millionth of a typical frequency that is being measured.Also, the transition time should not be excessively sharp if the frequency is low. Or it may be too short - I don't know what frequency ranges you're dealing with.Regards,Andrew.
• Post Points: 5