EmbDev.net

Forum: FPGA, VHDL & Verilog Vhdl time window


Author: Luca M. (thieulam)
Posted on:

Rate this post
0 useful
not useful
How is it possible in vhdl to implement a control in a time window 
referred to a clock?

For example, define a time window that starts 4 ns before the clock and 
ends 2 ns before the clock.

Or a window that starts 2 ns before the clock and ends 1 ns after the 
clock.

Or a window that starts 2 ns after the clock and ends 5 ns after the 
clock.

Then determine if in this time window a data line has remained stable 
(no transitions).

Regards

Author: Lothar M. (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Luca M. wrote:
> How is it possible in vhdl to implement a control in a time window
> referred to a clock?
Usually such measurements are done by a high speed oscilloscope...

One way would be to implement a TDC (time to digital converter) and then 
compare the both inputs (clock and signal) to check the phase of those 
two signals.

But given those tight timings (1 ns range) you must consider the input 
delay of a FPGA pad and later on the internal routing also. Because it 
may be that the timing at the pin is totally correct, but inside the 
FPGA there is a slack on the data line and at the actual flipflop it is 
delayed by 3ns. Here you must work with timing constraints on the signal 
line to be sure the routing is done properly.

BTW: to control a signal is totally different than simply measure or 
to check a signal. Why do you need such a check?

Author: Luca M. (thieulam)
Posted on:

Rate this post
0 useful
not useful
Tnx Lothar.
Sorry, i need check, not control.
But i need only a simulation vhdl code for this. Not a Real misure with 
oscilloscope!
I need simulate a flop with T setup and T hold.
Case 1:  tsetup and thold  positive (  es 5ns, 1ns).
Case 2 : setup positive and thold negative.
Case 3: setup negative and hold positive.

I need to check in this temporals windows if a data is  stable.  Vhdl 
code.

: Edited by User
Author: C. A. Rotwang (Guest)
Posted on:

Rate this post
0 useful
not useful

Author: Lothar M. (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Luca M. wrote:
> I need to check in this temporals windows if a data is  stable. Vhdl code.
One question more: do you have to implement that in real hardware for 
real life signals or just simply for simulation?

If the first:
This cannot be done by "VHDL code" solely. You must have a very, very 
close look at the particular datasheet of your particular FPGA and 
figure out how you can implement a delay line for a TDC.

If the second:
Where does the input stimuli of your test bench come from? Do you 
perform a timing simulation? If so: why? I didn't do that since the last 
millenium. A proper synchronous design strategy together with proper 
timing constraints gets your design running easily.

And all in all:
Lothar M. wrote:
> Why do you need such a check?
And for what? Is it a real application or just homework?

: Edited by Moderator
Author: Schlumpf (Guest)
Posted on:

Rate this post
0 useful
not useful
There is no direct way to check.
But you can write this checker with VHDL Attributes and Asserts:

https://www.csee.umbc.edu/portal/help/VHDL/attribute.html

Author: Schlumpf (Guest)
Posted on:

Rate this post
0 useful
not useful
Example:

SETUP_TIME: Time before the rising edge of clk where data must be stable
HOLD_TIME: Time after the rising edge of clk  where data must be stable

Checker for Setup-Time:
tsu_checker: process
begin 
  wait until rising_edge(clk);
  assert data'stable(SETUP_TIME) report "Setup violation!!" severity error;
end process;

Checker for Hold-Time:
thd_checker: process
begin 
  wait until data'event;
  if clk = '1' then
    assert clk'stable(HOLD_TIME) report "Hold violation!!" severity error;
  end if;
end process;  

This is only one of many possible ways to solve the problem

Author: Luca M. (thieulam)
Posted on:

Rate this post
0 useful
not useful
For Shclumpf:
Right.. I need this!
But in your example the thold and setup are positive values.
I need check the violation if the thold is positive and tsetup is 
negative also.
I need check the violation if the tsetup  is positive and thold is 
negative also.

Author: Schlumpf (Guest)
Posted on:

Rate this post
0 useful
not useful
Did you understand the principle of the given examples?

Author: Schlumpf (Guest)
Posted on:

Rate this post
0 useful
not useful
Another option is the keyword 'now'.
It represents the current simulation time.
You can store the timestamp of any event and calculate with the values.

Author: Lothar M. (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Luca M. wrote:
> I need check
Again: in real life on real hardware or just for simulation?

And: think about my other questions also. Try to answer them, as I try 
to help you...

Author: Luca M. (thieulam)
Posted on:

Rate this post
0 useful
not useful
Schlumpf wrote:
> Did you understand the principle of the given examples?

Yes.. but  the setup and old Times can to be negative in complex 
hardware.
Normally are positive in simple flop.

Author: Luca M. (thieulam)
Posted on:

Rate this post
0 useful
not useful
Lothar M. wrote:
> Luca M. wrote:
>> I need check
> Again: in real life on real hardware or just for simulation?
>
> And: think about my other questions also. Try to answer them, as I try
> to help you...

Just simulation

Author: Schlumpf (Guest)
Posted on:

Rate this post
0 useful
not useful
If you understood the principle it should be easy for you to adapt the 
examples to negative values.

Or use the keyword now.

If you have different cases dependent of positive or negative values you 
can use the keyword 'if' :)

But anyway:
What is the sense of that all?
Du you want to simulate a backannotated design?
As Lothar said: it doesn't make sense..

Author: Luca M. (thieulam)
Posted on:

Rate this post
0 useful
not useful
Schlumpf wrote:
> If you understood the principle it should be easy for you to adapt the
> examples to negative values.
>
> Or use the keyword now.
>
> If you have different cases dependent of positive or negative values you
> can use the keyword 'if' :)
>
> But anyway:
> What is the sense of that all?
> Du you want to simulate a backannotated design?
> As Lothar said: it doesn't make sense..

Yes. With a model of complex flop i can simulate my fpga design to 
ensure  set_output_delay is right.

Author: Schlumpf (Guest)
Posted on:

Rate this post
0 useful
not useful
If the design is synchronous or if the clocks of different domains are 
in a fixed and known phase relation you can use constraints.
If there are asynchronous paths you can report and check the delay of 
these paths after PaR.

There is no need to simulate.

And even if you simulate you have to make a simulation for all possible 
phases between the clocks. And the number of these is infinite..

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig