The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Apr 19th, 2024, 5:57am
Pages: 1
Send Topic Print
Detecting "immediately" if pulse period is larger than tmax (Read 3253 times)
Zorro
Community Member
***
Offline



Posts: 63

Detecting "immediately" if pulse period is larger than tmax
Aug 26th, 2016, 2:54am
 
Hi All,

I have a question and I hope somebody can give me a hint to solve the problem.

I need to generate a reset signal "b" if the period of input signal xcn is larger than tmax.

The signal xcn is actually electrical but using "Digital Sensitivity to Analog Events" the signal is discretized inside the model. This is done like this:


`timescale 1ns/1ps      // `timescale (time unit)/(time precision)
`define tick 1e9      // `define tick 1/(time unit)
...
reg                  xcn_dig;
...

     always @(above(V(xcn, vss)-thr_high)) begin
           xcn_dig = 1;
     end

     always @(above(thr_low-V(xcn, vss))) begin
           xcn_dig = 0;
     end      

     
From now on the code continues working with the digital signal xcn_dig.

Below the code that I am trying to use for pulse width detection.

     parameter real        tmax                  = 210n;

     always @(posedge xcn_dig) begin

           b <= 1'b0;
           b <= #(tmax*`tick) 1'b1;  
           
     end

     
Scenario 1
Lets assume that xcn_dig has a period which is larger than tmax=210ns.
In this case a reset signal must be generated.
In this example the period of xcn_dig is 216.931ns, larger than tmax=210ns and therefore a reset pulse should be generated 210ns after the rising edge of xcn_dig.
See picture 1.
-> The code is working well to detect pulses that are bigger than tmax.


Scenario 2
Lets assume that xcn_dig has a period which is smaller than tmax=210ns.
In this case the reset signal should remain low.
In this example the period of xcn_dig is 171.414ns, smaller than tmax=210ns and therefore no reset pulse should be generated 210ns after the rising edge of xcn_dig.
See picture 2.
However, with this code, the reset pulse is being generated.
-> The code is not working well to detect pulses that are smaller than tmax.
Can somebody helpe me to improve this?
I actually need that if the second positive edge of xcn_dig occurs in the expected time <tmax then the generation of the reset should be canceled.

Thank you very much!
Zorro.
Back to top
 
 
View Profile   IP Logged
Zorro
Community Member
***
Offline



Posts: 63

Re: Detecting "immediately" if pulse period is larger than tmax
Reply #1 - Aug 26th, 2016, 3:01am
 
picture 1
Back to top
 

pict_01.png
View Profile   IP Logged
Zorro
Community Member
***
Offline



Posts: 63

Re: Detecting "immediately" if pulse period is larger than tmax
Reply #2 - Aug 26th, 2016, 3:01am
 
picture 2
Back to top
 

pict_02.png
View Profile   IP Logged
Narasimhan
New Member
*
Offline



Posts: 3

Re: Detecting "immediately" if pulse period is larger than tmax
Reply #3 - Aug 26th, 2016, 4:14am
 
The code for detection will always assign 1 to b whenever posedge of xcn_dig occurs irrespective of the period. You can make use of the inbuilt function $abstime or $realtime to get the time stamp when the posedge of xcd_dig occurs and compare it with the next posedge timestamp.


Code:
real curr_timestamp, prev_timestamp;

always @(posedge xcn_dig)
begin
curr_timestamp = $abstime;
b = (curr_timestamp > (prev_timestamp + tmax));
prev_timestamp = curr_timestamp;
end
 



note that you need to use blocking assignments(=) for the above code to work
Back to top
 
 
View Profile   IP Logged
Zorro
Community Member
***
Offline



Posts: 63

Re: Detecting "immediately" if pulse period is larger than tmax
Reply #4 - Aug 26th, 2016, 5:02am
 
Hi Narasimhan,

thank you for your reply. I had tried something similar using the frequency/period measurement code.

The problem is that the code that you posted  and the code of the "frequency/period measurement block" have to wait for the next positive edge of xcn_dig to generate (or not) the reset signal.

As I wrote in the subject the detection must be "immediate".

Example
Imagine that xcn_dig goes high and if tmax time after this event occur we don't have a new rising edge of xcn_dig then reset should go high immediately and not wait until the next positive edge of xcn_dig to go high.
What if there is no new positive edge of xcn_dig (let's say xcn_dig remains high or low)? then no reset would be generated at all.

The output using your code is reset1.
See picture 3 below.
Thank you.
Back to top
 

pict03.png
View Profile   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.