go-board-code/simon.v

104 lines
2.2 KiB
Coq
Raw Normal View History

2024-07-06 18:51:29 +00:00
module Simon(
input i_Clk,
input i_Switch_1,
input i_Switch_2,
input i_Switch_3,
input i_Switch_4,
output o_LED_1,
output o_LED_2,
output o_LED_3,
output o_LED_4,
output o_Segment2_A,
output o_Segment2_B,
output o_Segment2_C,
output o_Segment2_D,
output o_Segment2_E,
output o_Segment2_F,
output o_Segment2_G
);
localparam GAME_LIMIT = 7;
localparam CLKS_PER_SECOND = 25000000;
localparam integer DEBOUNCE_LIMIT = CLKS_PER_SECOND * 0.001;
wire w_Switch_1, w_Switch_2, w_Switch_3, w_Switch_4;
wire [3:0] w_Score;
wire w_Segment2_A,
w_Segment2_B,
w_Segment2_C,
w_Segment2_D,
w_Segment2_E,
w_Segment2_F,
w_Segment2_G;
Debounce_Filter #(
.DEBOUNCE_LIMIT(DEBOUNCE_LIMIT)
) Debounce_Switch_1 (
.i_Clk(i_Clk),
.i_Bouncy(i_Switch_1),
.o_Debounced(w_Switch_1)
);
Debounce_Filter #(
.DEBOUNCE_LIMIT(DEBOUNCE_LIMIT)
) Debounce_Switch_2 (
.i_Clk(i_Clk),
.i_Bouncy(i_Switch_2),
.o_Debounced(w_Switch_2)
);
Debounce_Filter #(
.DEBOUNCE_LIMIT(DEBOUNCE_LIMIT)
) Debounce_Switch_3 (
.i_Clk(i_Clk),
.i_Bouncy(i_Switch_3),
.o_Debounced(w_Switch_3)
);
Debounce_Filter #(
.DEBOUNCE_LIMIT(DEBOUNCE_LIMIT)
) Debounce_Switch_4 (
.i_Clk(i_Clk),
.i_Bouncy(i_Switch_4),
.o_Debounced(w_Switch_4)
);
Simon_Game #(
.CLKS_PER_SECOND(CLKS_PER_SECOND),
.GAME_LIMIT(GAME_LIMIT)
) Simon_Game_Instance (
.i_Clk(i_Clk),
.i_Switch_1(w_Switch_1),
.i_Switch_2(w_Switch_2),
.i_Switch_3(w_Switch_3),
.i_Switch_4(w_Switch_4),
.o_Score(w_Score),
.o_LED_1(o_LED_1),
.o_LED_2(o_LED_2),
.o_LED_3(o_LED_3),
.o_LED_4(o_LED_4)
);
Binary_to_7_Segment Scoreboard (
.i_Clk(i_Clk),
.i_Number(w_Score),
.o_SegA(w_Segment2_A),
.o_SegB(w_Segment2_B),
.o_SegC(w_Segment2_C),
.o_SegD(w_Segment2_D),
.o_SegE(w_Segment2_E),
.o_SegF(w_Segment2_F),
.o_SegG(w_Segment2_G)
);
assign o_Segment2_A = !w_Segment2_A;
assign o_Segment2_B = !w_Segment2_B;
assign o_Segment2_C = !w_Segment2_C;
assign o_Segment2_D = !w_Segment2_D;
assign o_Segment2_E = !w_Segment2_E;
assign o_Segment2_F = !w_Segment2_F;
assign o_Segment2_G = !w_Segment2_G;
endmodule