M
mm77
Guest
Hi all!
I'm a bit new to Verilog-AMS.
I need to model a comparator.
Several analog input signals are sampled when some digital signals
change state.
I thought I could use something like (next is not the actual code,
just simplified version to show my point):
----------------------
`include "constants.vams"
`include "disciplines.vams"
module Comp (Ph, PhB, v0, v1, vo);
input [2:0] Ph, PhB;
input v0, v1;
output vo;
electrical v0, v1;
logic [2:0] Ph;
logic [2:0] PhB;
electrical vo;
parameter real gain = 10000;
parameter real offset = 0;
parameter real delay = 160n;
// sampled differential input signal
real v0_val;
// differential ramp signal
real v1_val;
// output signal
real vo_val;
analog begin
// sample the signal
@ (posedge Ph[0]) begin
v0_val = V(v0) ;
end
// sample the signal
@ (negedge Ph[1]) begin
v1_val = V(v1) ;
end
if (Ph[3])
vo_val = 0;
else begin
vo_val = 1.65 - gain*(v0 - v1 - offset);
end
V(vo) <+ absdelay (vo_val, delay);
end
endmodule
-----
Apparently this doesn't work (but compiles and elaborates, just
doesn't do what expected).
Why?
Note that it works if I use separate signals (Ph2, Ph1, Ph0).
However I want to group them in a vector since they are in the
schematic I am modeling.
I haven't found any example showing this usage (posedge on vector)....
Is it not supported in Verilog-AMS? Why Not?
Thanks for any hint/help/information!
Kind regards,
Marco
I'm a bit new to Verilog-AMS.
I need to model a comparator.
Several analog input signals are sampled when some digital signals
change state.
I thought I could use something like (next is not the actual code,
just simplified version to show my point):
----------------------
`include "constants.vams"
`include "disciplines.vams"
module Comp (Ph, PhB, v0, v1, vo);
input [2:0] Ph, PhB;
input v0, v1;
output vo;
electrical v0, v1;
logic [2:0] Ph;
logic [2:0] PhB;
electrical vo;
parameter real gain = 10000;
parameter real offset = 0;
parameter real delay = 160n;
// sampled differential input signal
real v0_val;
// differential ramp signal
real v1_val;
// output signal
real vo_val;
analog begin
// sample the signal
@ (posedge Ph[0]) begin
v0_val = V(v0) ;
end
// sample the signal
@ (negedge Ph[1]) begin
v1_val = V(v1) ;
end
if (Ph[3])
vo_val = 0;
else begin
vo_val = 1.65 - gain*(v0 - v1 - offset);
end
V(vo) <+ absdelay (vo_val, delay);
end
endmodule
-----
Apparently this doesn't work (but compiles and elaborates, just
doesn't do what expected).
Why?
Note that it works if I use separate signals (Ph2, Ph1, Ph0).
However I want to group them in a vector since they are in the
schematic I am modeling.
I haven't found any example showing this usage (posedge on vector)....
Is it not supported in Verilog-AMS? Why Not?
Thanks for any hint/help/information!
Kind regards,
Marco