-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.v
70 lines (56 loc) · 1.08 KB
/
clock.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module clock(output reg clock);
initial
clock = 1'b0;
always
#10 clock = ~clock;
//shutdown after 1k cycles
//initial
// #1000 $finish;
endmodule
// uses the clock module to output trigger signals for the instr_clock and
// mem_clock
// reset_bar when low holds the instr clock high and the mem clock low
module Multi_Clock (
output reg instr_clock,
output reg mem_clock,
input reset_bar
);
reg clk, hold;
clock base_clk(clk);
initial
begin
instr_clock = 1'b1;
mem_clock = 1'b0;
hold = 1'b1;
end
always @(posedge clk)
begin
instr_clock = clk;
if (reset_bar) // Don't go high if in reset, wait for negedge to start output
if (!hold)
mem_clock = #5 clk;
end
always @(negedge clk)
begin
mem_clock = clk;
if (reset_bar) // Don't go low if in reset
begin
instr_clock = #5 clk;
hold = 1'b0; // clear hold if not in reset, ready for mem_clock
end
else
hold = 1'b1; // set hold if in reset
end
endmodule
/* test
module test_clock;
wire clk;
clock clk1(clk);
initial
begin
$dumpfile("test.vcd");
$dumpvars;
$monitor($time, "clock level = %b", clk);
end
endmodule
*/