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

Subversion Repositories i2c_to_wb

[/] [i2c_to_wb/] [trunk/] [sim/] [models/] [glitch_generator.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
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 2 qaztronic
 
28
 
29
`timescale 1ns/10ps
30
 
31
 
32
module
33
  glitch_generator
34
  #(
35
    parameter ENABLE = 0,
36
    parameter MAX_FREQ = 10000,
37
    parameter MAX_WIDTH = 120
38
  )
39
  (
40
    output out
41
  );
42
 
43
 
44
  // --------------------------------------------------------------------
45
  //  wires & regs
46
  reg glitch_generator_en;
47
  reg glitch;
48
  reg glitch_en;
49
 
50
 
51
  // --------------------------------------------------------------------
52
  //  init 
53
  initial
54
    begin
55
      glitch_generator_en <= ENABLE;
56
      glitch              <= 1'b0;
57
      glitch_en           <= 1'b0;
58
 
59
      forever
60
        begin: glitch_loop
61
 
62
          #({$random} % MAX_FREQ);
63
 
64
          if( ~glitch_generator_en )
65
            disable glitch_loop;
66
 
67
          glitch_en = 1'b1;
68
          #({$random} % MAX_WIDTH);
69
 
70
          glitch = ~glitch;
71
          #({$random} % MAX_WIDTH);
72
 
73
          glitch_en = 1'b0;
74
 
75
        end
76
    end
77
 
78
 
79
  // --------------------------------------------------------------------
80
  //  enable_glitch_generator
81
  task enable_glitch_generator;
82
    begin
83
 
84
    glitch_generator_en <= 1'b1;
85
 
86
    end
87
  endtask
88
 
89
 
90
  // --------------------------------------------------------------------
91
  //  disable_glitch_generator
92
  task disable_glitch_generator;
93
    begin
94
 
95
    glitch_generator_en <= 1'b0;
96
 
97
    end
98
  endtask
99
 
100
 
101
  // --------------------------------------------------------------------
102
  //  outputs   
103
 
104
  assign (supply1, supply0) out = glitch_en ? glitch : 1'bz;
105
 
106
endmodule
107
 

powered by: WebSVN 2.1.0

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