Open
Description
Thanks for yesterdays live debugging session.
We found our mistake in the usage of Axi4Manager and Axi4Memory.
The frequency of the OSVVM verification components was not matching the period of our testbench clocks.
We have 2 suggestions to prevent others from doing the same mistake:
- Don't set a default value to
tperiod_Clk
, so users are forced to map a clock period. - Measure the clock period in the model.
=> We would prefer this method.
How can the latter be implemented in a save and reliable way?
- Measure the clock period on
Clk
and save it in a local variable/signal. - When reset is done (
rising_edge(nReset)
, assigntperiod_Clk
.
What does this method achieve?
- No need for a generic / no dependency to the parent instance.
- Clock period can be changed in the testbench, while reset is high or retriggered.
- Anyhow, clock must be stable before reset is released and it can't change frequency afterwards unless reset is asserted again.
- When reset is deasserted,
tperiod_Clk
can be used immediately.
Sketch of the solution:
architecture a of e is
signal tperiod_Clk : time := -1 ns;
begin
process(Clk, nReset)
variable LastRise : time := 0 ns;
variable Period : time := -1 ns;
begin
if rising_edge(nReset) then
tperiod_Clk <= Period;
end if;
if rising_edge(Clk) then
Period := now - LastRise;
LastRise := now;
end if;
end process;
-- ...
end architecture;
Note:
- negative times are intended, so simulation fails on uninitialized / unmeasured clocks.
/cc @stefanunrein
Metadata
Metadata
Assignees
Labels
No labels