The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
May 5th, 2024, 3:51am
Pages: 1
Send Topic Print
Digitally Controlled Analog Events (Read 3168 times)
irfan
New Member
*
Offline



Posts: 5

Digitally Controlled Analog Events
Jan 08th, 2006, 11:43am
 
Hi!  I am a mixed-signal IC designer with strong emphasis on analog design.  About three weeks ago, I seriously started using the Verilog-AMS to model my existing designs.  In sharp contrast to what I had originally thought about modeling in AMS, I am now having way too much fun doing this.   Smiley

While modeling in purely analog form is no problem, I am having some issues when converting analog models to mixed-mode models, in particular, when using digital events to control analog behavior.  As I don't have a reference book handy at home, I will appreciate anyone's help with the following:

(1) Is there a way to make things level sensitive rather using either @(posedge X) or @(negedge X)?  I am trying to make the following more general as the control signals may change or may stay constant during the sim:

// Unit resistance vs. SG settings  
 @(posedge (SG00 | SG01))
     Runit = 4.6k;
 @(posedge SG10)
     Runit = 2.1k;
 @(posedge SG11)
     Runit = 1.0k;

(2) Can one use the “case” statement for a digital bus in order to control analog? If yes, then what is the correct syntax?  For example, I want S[3:0] to have 4 different cases and I am trying to get away from doing the following:

// Rint values vs. Range settings --> 2-to-4 digital decoder output
 @(posedge S[0])
     Rint = 116*Runit;
 @(posedge S[1])
     Rint = 87*Runit;
 @(posedge S[2])
     Rint = 69*Runit;
 @(posedge S[3])
     Rint = 57*Runit;

Thanks in advance for your help.

Irfan
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: Digitally Controlled Analog Events
Reply #1 - Jan 9th, 2006, 11:24am
 
Here's a little example, using a case statement. Note I'm also using always @(S) which means that the code will get invoked any time S changes (positive or negative), and then a case within. You could of course use if within.

Code:
`include "disciplines.vams"
module myres (a,b,S);
inout a,b;
input[1:0] S;
electrical a,b;
logic[1:0] S;

real rval;

always @(S)
  case (S)

  2'b00: rval=1.0K;
  2'b01: rval=2.0K;
  2'b10: rval=3.0K;
  2'b11: rval=4.0K;

  endcase

analog begin

  V(a,b)<+I(a,b)*rval;

end

endmodule 



This would then be compiled using:

Code:
ncvlog -ams myres.vams 



My testbench is as follows:

Code:
`include "disciplines.vams"
module testit;

reg[1:0] S;
electrical agnd;
ground agnd;
electrical n1;

initial begin

    S=2'b00;
    #50 S=2'b01;
    #50 S=2'b10;
    #50 S=2'b11;
    #50 $finish;

end

isource #(.dc(-1.0m)) I1(n1,agnd);
myres R1(n1,agnd,S);

endmodule 



And to compile this:

Code:
ncvlog -ams testit.vams 



With an analog control file (very simple) of:
Code:
//
tran tran stop=400n 



I can then elaborate and simulate with:
Code:
ncelab testit
ncsim -gui -analogcontrol testit.scs testit 



Attached is a png file (out of wavescan) showing the resulting waveforms (I'm plotting the voltage, as the resistor value changes). Note the model is pretty lousy, because it doesn't change the resistor value smoothly - it has an instantaneous switch (which is not a good thing), but this is just to illustrate the principle  ;D
Back to top
 

withcase.png
View Profile WWW   IP Logged
irfan
New Member
*
Offline



Posts: 5

Re: Digitally Controlled Analog Events
Reply #2 - Jan 9th, 2006, 4:49pm
 
Thanks a lot Andrew!  This is way more than what I had expected from this forum!   Grin
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.