-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathclock_beat.v
31 lines (24 loc) · 862 Bytes
/
clock_beat.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
//--------------------------------------------------------------------------------------------------------
// Module : clock_beat
// Type : synthesizable, FPGA's top, IP's example design
// Standard: Verilog 2001 (IEEE1364-2001)
// Function: When clk runs, beat signal will blink
//--------------------------------------------------------------------------------------------------------
module clock_beat # (
parameter CLK_FREQ = 50000000, // Unit:Hz
parameter BEAT_FREQ = 5 // Unit:Hz
) (
input wire clk,
output reg beat
);
localparam CYCLES = (CLK_FREQ / 2 / BEAT_FREQ);
reg [31:0] count = 0;
initial beat = 1'b0;
always @ (posedge clk)
if ( count < (CYCLES-1) ) begin
count <= count + 1;
end else begin
count <= 0;
beat <= ~beat;
end
endmodule