forked from C-L-G/public_atom_modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock_rst.sv
64 lines (55 loc) · 1.25 KB
/
clock_rst.sv
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
/*******************************************************
______________ ___ __ __ ______________
______________\ / | |__} | | |\ | ______________
______________ \/ | | \ |__| | \| ______________
--Module Name:clock_rst
--Project Name:tmp_avalon
--Chinese Description:
--English Description:
--Version:
--Data modified:
--author:
--E-mail: [email protected]
--Data created:2013/12/18 15:12:37
________________________________________________________
********************************************************/
`timescale 1ns/1ps
module clock_rst(
output bit clock,
output bit rst
);
parameter bit ACTIVE = 1;
int clk_i = 0;
int rst_i = 0;
longint period_cnt = 0;
bit clk_pause = 1;
int rst_hold = 10;
real clk_period = 5;
task run(
input int reset_hold = 10,
input real period = 5,
input longint period_count = 0
);
begin
clk_pause = 1;
clk_i = 0;
rst_i = 0;
rst = ACTIVE;
rst_hold = reset_hold;
clk_period = period/2;
period_cnt = period_count;
// $stop;
repeat(3) #(period*3);
clk_pause = 0;
repeat(rst_hold) @(posedge clock);
rst = !ACTIVE;
end
endtask
always #clk_period begin
if(clk_pause == 0 && (period_cnt == 0 || clk_i<period_cnt))begin
clock = ~clock;
end else begin
clock = clock;
end
end
endmodule