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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [src/] [clock/] [tb_programmable_clk.v] - Blame information for rev 48

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
// --------------------------------------------------------------------
2
//
3
// --------------------------------------------------------------------
4
 
5
`timescale 10ps/1ps
6
 
7
 
8
module
9
  tb_programmable_clk
10
  (
11
    output reg clock
12
  );
13
 
14
 
15
  // --------------------------------------------------------------------
16
  //  
17
  integer clk_duty_cycle = 50;
18
 
19
  task set_clk_duty_cycle;
20
  input integer duty_cycle;
21
    begin
22
 
23
      clk_duty_cycle = duty_cycle;
24
 
25
    end
26
  endtask
27
 
28
 
29
  // --------------------------------------------------------------------
30
  //  
31
  integer clk_period = 1515;
32
 
33
  task set_clk_period;
34
  input integer period;
35
    begin
36
 
37
      clk_period = period;
38
 
39
    end
40
  endtask
41
 
42
 
43
  // --------------------------------------------------------------------
44
  //  
45
  initial
46
    clock <= 1'b1;
47
 
48
  always
49
    if(clk_duty_cycle == 50)
50
      #(clk_period/2) clock <= ~clock;
51
    else
52
      if(clock)
53
        #(clk_period * (clk_duty_cycle/100)) clock <= ~clock;
54
      else
55
        #(clk_period * ( (100 - clk_duty_cycle)/100 ) ) clock <= ~clock;
56
 
57
 
58
endmodule
59
 

powered by: WebSVN 2.1.0

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