The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 16th, 2024, 8:53am
Pages: 1
Send Topic Print
problem with detecting falling edge (Read 2362 times)
mowiehowie
Junior Member
**
Offline



Posts: 26

problem with detecting falling edge
Jul 22nd, 2010, 7:00am
 
hi all.
i need to detect a falling edge in order to count it and generate a signal. i've made a code like this:
analog begin

     @(initial_step) begin

           cycle = 0;
           carrega = 0;
           k = 0;
           serial = 0;
           vth = 0.9*V(dvdd,dgnd);
     end

     @(cross(V(clk)-vth, 1)) begin


           if (cycle < 71)      cycle = cycle + 1; $strobe(cycle);
           if (cycle <= 70) serial = $table_model(cycle, "testvector.dat", "D");
           if (cycle == 71) cycle = 0;

     end

     @(cross(V(clk)-vth, -1)) begin

           if (k < 71) k = k + 1;  $strobe(k);
           if (k == 71) carrega = 1; k = 0;


     end


     V(out_d,dgnd) <+ serial*V(dvdd,dgnd);
     V(load,dgnd) <+ carrega*V(dvdd,dgnd);

end

endmodule
in fact, i can see that the rising edge is detected properly but the falling edge is not. k only reaches '1'. it doesnt increase anymore.

what might be going on?
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: problem with detecting falling edge
Reply #1 - Jul 22nd, 2010, 12:12pm
 
A stupid trick for checking this might be to change
@(cross(V(clk)-vth, -1)) begin
to this:
@(cross(vth-V(clk), 1)) begin
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.