MarkG
New Member
Offline
Posts: 1
|
I have a question about the Cadence library ahdlLib -> analog_mux, the code is copied below.
Why do you need *BOTH* the following type of lines?
selector = (V(vsel) > vth) ? 1: 0;
@ (cross(V(vsel) - vth, 1, 1.0, vsel.potential.abstol)) selector = 1;
won't the conditional operator (?:) , make it so that the selector value is always correct? Or, do you need the @cross() so that you force the simulator to ALSO evaluate the value of "selector" at the crossings too (so that you get the value of selector changing at the correct time)?
code below: --------------------------------------------------------------- module analog_mux(vin1, vin2, vsel, vout); input vin1, vin2, vsel; output vout; electrical vin1, vin2, vsel, vout ; parameter real vth = 2.5;
integer selector; real vout_val;
analog begin selector = (V(vsel) > vth) ? 1: 0;
@ (cross(V(vsel) - vth, 1, 1.0, vsel.potential.abstol)) selector = 1;
@ (cross(V(vsel) - vth, -1, 1.0, vsel.potential.abstol)) selector = 0;
if (selector == 1)begin vout_val = V(vin1); end else if (selector == 0)begin vout_val = V(vin2); end
V(vout) <+ vout_val; end endmodule
---------------------------------------------------------------
thanks M
|