Hello!
I want to make a MTK PE+ protocol tester.
So I want make a current wave like this:
_|-|_|-|_|---|_|---|_|---|_|-----|_
(i_bus=0->delay TimeD->i_bus=itarget->delay TimeC->i_bus=0->delay TimeD->i_bus=itarget->delay TimeC->i_bus=0->delay TimeD->i_bus=itarget->delay TimeB->i_bus=0->delay TimeD->i_bus=itarget->delay TimeB->i_bus=0->delay TimeD->i_bus=itarget->delay TimeB->i_bus=0->delay TimeD->i_bus=itarget->delay TimeA->i_bus=0->delay TimeD)
*TimeA=500ms *TimeB=300ms *TimeC=TimeD=100ms
my code is:
Code:case(mod)
...
3: begin
if ( V(vtarget) < 2 ) begin //Reset
next1 = $abstime + TimeWDT;
@(timer($abstime , next1)) i_bus = 0;
end
else if ( V(vbus) < ( V(vtarget) - 1 ) ) begin //this part is current wave
repeat( 2 ) begin
i_bus = 0;
next1 = $abstime + TimeD;
next2 = next1 + TimeC;
@(timer(next1 , next2)) i_bus = V(itarget);
end
repeat( 3 ) begin
next1 = $abstime + TimeD;
@(timer($abstime , next1)) i_bus = 0;
next2 = $abstime + TimeB;
@(timer($abstime , next2)) i_bus = V(itarget);
end
next1 = $abstime + TimeD;
@(timer($abstime , next1)) i_bus = 0;
next2 = $abstime + TimeA;
end
else if ( V(vbus) > ( V(vtarget) + 1 ) )begin //this part is another current wave
repeat( 3 ) begin
next1 = $abstime + TimeD;
@(timer($abstime , next1)) i_bus = 0;
next2 = $abstime + TimeB;
@(timer($abstime , next2)) i_bus = V(itarget);
end
repeat( 2 ) begin
next1 = $abstime + TimeD;
@(timer($abstime , next1)) i_bus = 0;
next2 = $abstime + TimeC;
@(timer($abstime , next2)) i_bus = V(itarget);
end
next1 = $abstime + TimeD;
@(timer($abstime , next1)) i_bus = 0;
next2 = $abstime + TimeA;
@(timer($abstime , next2)) i_bus = V(itarget);
end
end
...
I know it is not right, but i don't know how to make delay in the loop.
Please help, Thanks!