Please design an alarm clock. Your clock should have the following functionality:
(1) Show hh:mm in your 7-Segment LED.
(2) Show second flashing in one of the discrete LED.
(3) User can set the time.
(4) User can set the time of alarm.
(5) One of the discrete LED will be flashing when alarm is triggered.
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: CYCU_EE Department
// Engineer:
//
// Create Date: 08:43:23 05/12/2017
// Design Name: YK Lai
// Module Name: small_clock
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module small_clock(
input clk,
input reset,
input enable,
output [5:0] second,
output [5:0] minute,
output [4:0] hour
);
reg [5:0] counter_s, counter_m;
reg adv_s, adv_m;
assign second=counter_s;
assign minute=counter_m;
always@(posedge clk)
if (reset) begin
counter_s<=6'd0;
adv_s<=1'b0;
end
else if (counter_s==6'd59) begin
counter_s<=6'd0;
adv_s<=1'b1;
end
else begin
counter_s<=counter_s+1'd1;
adv_s<=1'b0;
end
always@(posedge clk)
if (reset) begin
counter_m<=6'd0;
adv_m<=1'b0;
end
else if (counter_m==6'd59) begin
counter_m<=6'd0;
adv_m<=1'b1;
end
else if (adv_m) begin
counter_m<=counter_m+1'd1;
adv_m<=1'b0;
end
endmodule