noglitch - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

205


62
 
1
// Example of delay issues
2
`default_nettype none
3
4
module delayinv(input a, output reg z);
5
6
  always @(a)
7
    z<=#5 ~a;
8
9
endmodule
10
11
module delayand(input a, input b, output reg z);
12
  always @(a,b)
13
     z<=#5 a&b;
14
endmodule
15
16
17
18
module test;
19
20
reg a, b;
21
wire anot, z;
22
23
24
reg aff, bff, zff;
25
reg clk;
26
27
  delayinv gate1(aff,anot);
28
  delayand gate2(anot,bff,z);
29
30
always 
31
  #10 clk=~clk;
32
33
// input flip flop A
34
  always @(posedge clk)
35
     aff<=a;
36
37
// input flip flop B
38
  always @(posedge clk)
39
    bff<=b;
40
41
// output flip flop
42
  always @(posedge clk)
43
   zff<=z;
44
45
initial
46
  begin
47
    // Dump waves
48
    $dumpfile("dump.vcd");
49
    $dumpvars(1);
50
    a=1'b0;
51
    b=1'b0; 
52
    clk=1'b0;
53
54
#15  b=1'b1;
55
    a=1'b1;
56
#145 b=1'b0;
57
    $finish;
58
  end
59
60
61
endmodule
62
xxxxxxxxxx
1
 
1
// Code your design here
2
266 views and 0 likes     
A short description will be helpful for you to remember your playground's details
 
100:0