The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> Accessing/Modifying "disciplines.vams"
https://designers-guide.org/forum/YaBB.pl?num=1190721712

Message started by Prathap on Sep 25th, 2007, 5:01am

Title: Accessing/Modifying "disciplines.vams"
Post by Prathap on Sep 25th, 2007, 5:01am

Hi,

Can we be able to actually modify the disciplines.vams file. I mean just as we have an "electrical" discipline (which contains two natures - voltage and current), can we have an user defined nature and discipline.

To be more specific, i am right now trying to model a PLL. A PLL has a frequency divider circuit. Of course there are models available for that (for instance , there is one Ken Kundert's model available in the Designer's Guide website). But i thought that we could possibly define a nature for frequency and access it thro' some user defined disciplines. For this i added this piece of code in my "disciplines.vams" file.


nature Frequency
            units = "Hz"
            access = Fr;
`ifdef FREQUENCY_ABSTOL
            abstol = `FREQUENCY_ABSTOL
`else
            abstol = 1e-12;
`endif
endnature

/// Conservative discipline

discipline period
             potential Frequency;
enddiscipline



But when i actually executed this discipline in the following program it gave me error. this is the code where i used it.


// VerilogA for PLL_Prathap, Freq_Discipline_Check, veriloga

`include "constants.vams"
`include "disciplines.vams"

`include "/h/prathsi/disciplines_modified.vams"           -------- Location where the modified discipline file is present

module Freq_Discipline_Check(in, out);
input in;
output out;

period in;
voltage in;
period out;

real temp, temp_1;

analog begin

     @(cross(V(in)-0.1, 1)) begin
     
           temp = Fr(in);
           temp_1 = 10 * temp;
           Fr(out) <+ transition(temp_1, 10n, 10n, 10n);

     end
     
endmodule


What i have done might be completely incorrect. If so please try to correct/guide me.


Thanks You.

Regards,
Prathap.

Title: Re: Accessing/Modifying "disciplines.vams"
Post by Stefan on Sep 25th, 2007, 5:32am

I think you're trying to MIX the disciplines, that's not possible.
The two natures voltage and current are dependent on each other and I don't think it's possible to define an additional third nature for it.
You could however declare a discipline that uses voltage as potential and "frequency" as flow.
However, I don't know if that wouldn't mess up everything also.

Title: Re: Accessing/Modifying "disciplines.vams"
Post by Geoffrey_Coram on Sep 25th, 2007, 6:11am

You may be having a problem because you're including the default one and your modified one.

I find that some simulators will find "disciplines.vams" in your working directory instead of the standard include directory, or alternately you can just not `include "disciplines.vams" and instead `include your modified one, and make it contain only the disciplines/natures that you really want.

Why do you have "in" as both voltage and period?  What exactly is the error message you got?

Title: Re: Accessing/Modifying "disciplines.vams"
Post by Prathap on Sep 25th, 2007, 11:54pm

Thanks Stefan & Geoffrey.  :)

I declared frequency as a flow. Then i removed the default declaration of disciplines (`include "disciplines.h"). I didnt get any errors.

But i realized i made had made a mistake in my code (a logical one). The module which i had posted was intended to divide the input frequency by 10 times. That is if the input freq if 10M then its output should be 1M. But after running the code i realized that it didnt work. Instead the voltage was multiplied by 10.

I actually thought that just like one can access the voltage of a node (using V()) or the current (using I()), we could access and calculate the frequency by Fr() (this Fr being a user defined one).  But then i came to know that potential or current can only be measured.  

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.