[SOLVED] proplem in verilog-a code

Status
Not open for further replies.

amr hema

Newbie level 6
Joined
Jan 3, 2013
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,360
i design sar adc and there is a proplem in sar logic code
the command @(initial_step) saw the first command only (ex. see counter=0) and the other statement repeated in code and i want to make them initial only

this is the code

// VerilogA for try, try, veriloga

`include "constants.vams"
`include "disciplines.vams"
module sar(comp,reset,clk,s1,s2,sp1,sp2,sp3,sn1,sn2,sn3);
input comp,reset,clk;
output s1,s2,sp1,sp2,sp3,sn1,sn2,sn3;
electrical comp,reset,clk,s1,s2,sp1,sp2,sp3,sn1,sn2,sn3;
parameter real Vlow = -1.2 ;
parameter real Vhigh = 1.2 ;
integer counter;
analog
begin
@(initial_step)
counter=0;
//V(s1)<+Vhigh; V(s2)<+Vhigh; V(sp1)<+Vhigh; V(sp2)<+Vhigh; V(sp3)<+Vhigh; V(sn1)<+Vhigh; V(sn2)<+Vhigh; V(sn3)<+Vhigh;
@(cross(V(clk)-1,+1))
counter=counter+1;
if (counter==1) begin
V(s1)<+Vlow; V(s2)<+Vlow;
end
if (counter==2) begin
if (V(comp)>Vhigh/2) begin
V(sp1)<+Vlow;
end
else if (V(comp)<Vhigh/2) begin
V(sn1)<+Vlow;
end
end
if (counter==3) begin
if (V(comp)>Vhigh/2) begin
V(sp2)<+Vlow;
end else if (V(comp)<Vhigh/2) begin
V(sn2)<+Vlow;
end
end
if (counter==4) begin
if (V(comp)>Vhigh/2) begin
V(sp3)<+Vlow;
end else if (V(comp)<Vhigh/2) begin
V(sn3)<+Vlow;
end
end
if (counter==5) begin
counter=0;
end
end
endmodule
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…