-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtrigger_gen.v
More file actions
28 lines (24 loc) · 779 Bytes
/
Copy pathtrigger_gen.v
File metadata and controls
28 lines (24 loc) · 779 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
// Infinite counter that signals each time it's empty.
// Please note that parameter M should be power of 2, because the internal
// counter underflows after the first time it's emtpy.
//
// Inputs: clk. Clock for shifting
// Outputs: trigger. Parallel output
module triggerM(input wire clk, output trigger);
// Counter's default value
parameter M = 512;
reg trigger = 0;
// Number of bits needed to store the counter value (M)
localparam N = $clog2(M);
// Register for storing the counter's value
reg [N-1:0] divcounter = M;
// Infinite counter (starts over when divcounter underflows)
always @(posedge clk)
begin
divcounter <= divcounter - 1;
if (divcounter == 0)
trigger <= 1;
else
trigger <= 0;
end
endmodule