OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [clock/] [clock_checker.v] - Blame information for rev 34

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
// --------------------------------------------------------------------
2
//
3
// --------------------------------------------------------------------
4
 
5
`timescale 10ps/1ps
6
 
7
module
8
  clock_checker
9
  (
10
    input test_clk
11
  );
12
 
13
 
14
  // --------------------------------------------------------------------
15
  time sim_time;
16
  real freq, freq_mhz;
17
 
18
  task display_freq;
19
    input   real  expected_freq;   // in Mhz
20
    output  time  period;
21
    begin
22
 
23
    @(posedge test_clk);    // delay to ensure a good clock
24
    @(posedge test_clk);
25
 
26
    @(posedge test_clk);
27
    sim_time = $time;
28
 
29
    @(posedge test_clk);
30
    period = $time - sim_time;
31
 
32
    freq      = 1 / ( period * 1e-11);
33
    freq_mhz  = (freq / 1e6);
34
 
35
    $display( "-#- %16.t | display_freq: freq = %0d Mhz | freq = %0e | period (in sim time) = %0t", $time, freq_mhz , freq, period );
36
 
37
    if( expected_freq != 0 )
38
      if( (expected_freq * 1.01 < freq_mhz ) | (expected_freq * 0.99 > freq_mhz ) )
39
        begin
40
          $display( "-!- %16.t | display_freq: ERROR!!! expected %0d Mhz but measured %0d Mhz", $time, expected_freq, freq_mhz );
41
          log.inc_fail_count();
42
        end
43
 
44
 
45
    end
46
  endtask
47
 
48
 
49
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.