Hm, OK let me start with 1..
first there are a couple ways to get the interaction in the analog engine..
1. you can just ACCESS the value of logic signal..
this leaves the CONTROL of when the simulator puts a time step in completely up to the analog side.. - ie if you
don't have anything else in the analog side forcing a time step while the signal is high, you may never observe it high in the analog side..
to force a timestep in the analog solver based on the digital signal you need to use an event
this case might miss events on dreg
Code:
module MySimpleAMS (input logic dreg, output electrical out);
real vsig;
parameter real vhi = 1.2;
parameter real vlo = 0;
parameter real tr = 100p;
parameter real tf = 100p;
analog begin
V(out) <+ transition(vsig,0,tr,tf);
if (dnet == 1'b1) vsig = vhi;
else vsig = vlo;
end
endmodule
this one uses the digital event to trigger the analog event
Code:
module MySimpleAMS (input logic dreg, output electrical out);
real vsig;
parameter real vhi = 1.2;
parameter real vlo = 0;
parameter real tr = 100p;
parameter real tf = 100p;
analog begin
V(out) <+ transition(vsig,0,tr,tf);
@(initial_step) vsig = vlo; // assume 0 until first event
@(posedge dreg) vsig = vhi;
@(negedge dreg) vsig = vlo;
end
endmodule
Similarly if you just access the (analog) value in an always block on the digital side, the event controlling that block will determine when that value is updated..
so a block like
Code:always @(dsig) begin
rvar = V(asig);
end
may not see the event you want..
where
Code:
always @(cross(V(asig)-vth),0)) begin
dreg = V(asig)>vth;
end
will always force the digital engine event when the signal crosses..
simple way to remember it.. "event" style interaction will PUSH the value from the other solver.. "ACCESS" style interaction will PULL the value from the other solver..
Hope this helps..
jbd