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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [tb/] [tb_base.sv] - Blame information for rev 50

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3 50 qaztronic
//// Copyright (C) 2019 Authors and OPENCORES.ORG                 ////
4 34 qaztronic
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
module
29
  tb_base
30
  #(
31 50 qaztronic
    N = 1,
32
    realtime PERIODS[N],
33
    realtime ASSERT_TIME = (PERIODS[0] * 5) + (PERIODS[0] / 3)
34 34 qaztronic
  )
35
  (
36 50 qaztronic
    output bit tb_clk[N],
37
    output bit tb_aresetn,
38
    output bit tb_reset[N]
39 34 qaztronic
  );
40 50 qaztronic
  timeunit 1ns;
41
  timeprecision 100ps;
42 34 qaztronic
 
43
  // --------------------------------------------------------------------
44 50 qaztronic
  function void assert_reset(realtime reset_assert=ASSERT_TIME);
45
    fork
46
      begin
47
      tb_aresetn = 0;
48
      #reset_assert;
49
      tb_aresetn = 1;
50
      end
51
    join_none
52
  endfunction
53 34 qaztronic
 
54 50 qaztronic
  // --------------------------------------------------------------------
55
  bit disable_clks[N];
56 34 qaztronic
 
57 50 qaztronic
  generate
58
    for(genvar j = 0; j < N; j++) begin
59
      always
60
        if(disable_clks[j])
61
          tb_clk[j] = 0;
62
        else
63
          #(PERIODS[j]/2) tb_clk[j] = ~tb_clk[j];
64
    end
65
  endgenerate
66 34 qaztronic
 
67
  // --------------------------------------------------------------------
68 50 qaztronic
  generate
69
    for(genvar j = 0; j < N; j++) begin
70
      bit reset = 1;
71
      assign tb_reset[j] = reset;
72 34 qaztronic
 
73 50 qaztronic
      always @(posedge tb_clk[j] or negedge tb_aresetn)
74
        if(~tb_aresetn)
75
          reset = 1;
76
        else
77
          reset = 0;
78
    end
79
  endgenerate
80 34 qaztronic
 
81
  // --------------------------------------------------------------------
82
  initial
83 50 qaztronic
    assert_reset();
84 34 qaztronic
 
85 50 qaztronic
// --------------------------------------------------------------------
86 34 qaztronic
endmodule

powered by: WebSVN 2.1.0

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