forked from open-logic/open-logic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quartus_tutorial.sv
70 lines (62 loc) · 1.49 KB
/
quartus_tutorial.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
65
66
67
68
69
70
module quartus_tutorial (
input wire Clk,
input wire [1:0] Buttons,
input wire [3:0] Switches,
output wire [3:0] Led
);
// Signal Declarations
wire [1:0] Buttons_Sync;
wire [3:0] Switches_Sync;
reg [1:0] RisingEdges;
reg [1:0] Buttons_Last;
wire Rst;
// Assert reset after power up
olo_base_reset_gen i_reset (
.Clk(Clk),
.RstOut(Rst)
);
// Debounce Buttons
olo_intf_debounce #(
.ClkFrequency_g(50.0e6),
.DebounceTime_g(25.0e-3),
.Width_g(2)
) i_buttons (
.Clk(Clk),
.Rst(Rst),
.DataAsync(Buttons),
.DataOut(Buttons_Sync)
);
// Debounce Buttons
olo_intf_debounce #(
.ClkFrequency_g(50.0e6),
.DebounceTime_g(25.0e-3),
.Width_g(4)
) i_switches (
.Clk(Clk),
.Rst(Rst),
.DataAsync(Switches),
.DataOut(Switches_Sync)
);
// -- Edge Detection
always @(posedge Clk) begin
if (Rst) begin
Buttons_Last <= 2'b00;
RisingEdges <= 2'b00;
end else begin
RisingEdges <= Buttons_Sync & ~Buttons_Last;
Buttons_Last <= Buttons_Sync;
end
end
// FIFO
olo_base_fifo_sync #(
.Width_g(4),
.Depth_g(4096)
) i_fifo (
.Clk(Clk),
.Rst(Rst),
.In_Data(Switches_Sync),
.In_Valid(RisingEdges[0]),
.Out_Data(Led),
.Out_Ready(RisingEdges[1])
);
endmodule