-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathm_clock.v
More file actions
56 lines (50 loc) · 989 Bytes
/
Copy pathm_clock.v
File metadata and controls
56 lines (50 loc) · 989 Bytes
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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Description: Resampler
//
//
//////////////////////////////////////////////////////////////////////////////////
module m_clock(
input [7:0] port_id,
input [7:0] out_port,
input write_strobe,
input IN,
input ENABLE,
output OUT
);
parameter BASE = 0;
reg [23:0] divider;
reg [23:0] counter;
reg trigger;
always @ (posedge IN)
begin
if (counter == divider)
begin
counter <= 0;
if (counter == 24'hFFFFFF)
begin
trigger <= IN;
end else begin
trigger <= !trigger;
end
end else begin
counter <= counter + 1;
end
end
assign OUT = trigger && ENABLE;
always @ (posedge write_strobe)
begin
if (port_id == BASE + 0)
begin
divider[7:0] <= out_port[7:0];
end
if (port_id == BASE + 1)
begin
divider[15:8] <= out_port[7:0];
end
if (port_id == BASE + 2)
begin
divider[23:16] <= out_port[7:0];
end
end
endmodule