The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl Modeling >> Behavioral Models >> Digitally Controlled Analog Events https://designers-guide.org/forum/YaBB.pl?num=1136749415 Message started by irfan on Jan 8th, 2006, 11:43am |
Title: Digitally Controlled Analog Events Post by irfan on Jan 8th, 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. :) 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 |
Title: Re: Digitally Controlled Analog Events Post by Andrew Beckett on 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:
This would then be compiled using: Code:
My testbench is as follows: Code:
And to compile this: Code:
With an analog control file (very simple) of: Code:
I can then elaborate and simulate with: Code:
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 |
Title: Re: Digitally Controlled Analog Events Post by irfan on Jan 9th, 2006, 4:49pm Thanks a lot Andrew! This is way more than what I had expected from this forum! ;D |
The Designer's Guide Community Forum » Powered by YaBB 2.2.2! YaBB © 2000-2008. All Rights Reserved. |