Digital stopwatch/timer (countdown) function verilog code ego1 development board vivado

Name: Digital stopwatch/timer (countdown) function verilog code ego1 development board vivado

Software: VIVADO

Language: Verilog

Code function:

Digital stopwatch, timer

1. It has timing function and stopwatch function. The two functions can be switched by switch.

2. The stopwatch function includes start, pause and reset functions.

3. Stopwatch function: timing accuracy 10ms (0.01 second)

4. Stopwatch function: digital tube displays minutes, seconds and milliseconds (10ms)

5. Timing function: hours, minutes and seconds can be set by pressing the buttons

6. Timing function: After setting the time, press the start button to start the countdown until the countdown reaches 0 and the LED prompt is output.

This code has been verified on the ego1 development board. The development board is as follows. Other development boards can modify the pin adaptation:

ego1 development board.png

Code download:Digital stopwatch/timer (countdown) function verilog code ego1 development board vivadoName: digital stopwatch/timer (countdown) ) Function verilog code ego1 development board vivado (code is downloaded at the end of the article) Software: VIVADO Language: Verilog code function: digital stopwatch, timer 1. With timing function and stopwatch function, the two functions are switched through the switch 2. Stopwatch function, specifically It has start, pause, and reset functions 3. Stopwatch function: timing accuracy 10ms (0.01 second) 4. Stopwatch function: digital tube displays minutes, seconds, and milliseconds (10ms) 5. Timing function: hours, minutes, and seconds can be set through buttons 6 , timing functionicon-default.png?t=N7T8http://www.hdlcode.com/index.php?m=home&c=View&a=index&aid=325

1. Project documents

2. Program files

3. Program compilation

4. Pin assignment

5. RTL diagram

6. modelsim simulation

Overall simulation diagram

Frequency division module

Button debounce module

Stopwatch control module

display decoding module

Part of the code display:

module Digital_clock(
input clk_in,
input mode_SW,//Mode control switch
input key_1,//stopwatch start, pause
input key_2,//reset stopwatch
input set_time_key_in,//Set time
input confirm_key_in,//confirm
input change_time_key_in,//Set hours, minutes and seconds
output LED,
output [7:0] dig_led_1,
output [3:0] wei_led_1,
output [7:0] dig_led_2,
output [3:0] wei_led_2
);
wire [7:0] stopwatch_Millisecond;//10 milliseconds
wire [7:0] stopwatch_second;//second
wire [7:0] stopwatch_minute;//minute
wire key_1_negedge;
wire key_2_negedge;
wire clk_1Hz;
wire clk_100Hz;
wire set_time_key;//Set time
wire confirm_key;//confirm
wire change_time_key;//Set hours, minutes and seconds
wire [7:0] countdown_hour_time;//hour
wire [7:0] countdown_minute_time;//minute
wire [7:0] countdown_second_time;//seconds
//Frequency division module
fenping fenping_Hz(
. clk_in(clk_in),
. clk_1Hz(clk_1Hz),
. clk_100Hz(clk_100Hz)//Divide the frequency to 100Hz
);
//Button 1 anti-bounce module
key_jitter key_1_jitter(
. clkin(clk_in),     
.key_in(key_1),
.key_posedge(key_1_negedge)
);
//Button 2 anti-bounce module
key_jitter key_2_jitter(
. clkin(clk_in),     
.key_in(key_2),
.key_posedge(key_2_negedge)
);
//Button debounce module
key_jitter key_3_jitter(
. clkin(clk_in),     
.key_in(set_time_key_in),
.key_posedge(set_time_key)
);
//Button debounce module
key_jitter key_4_jitter(
. clkin(clk_in),     
.key_in(confirm_key_in),
.key_posedge(confirm_key)
);
//Button debounce module
key_jitter key_5_jitter(
. clkin(clk_in),     
.key_in(change_time_key_in),
.key_posedge(change_time_key)
);
//Stopwatch control module
stopwatch i_stopwatch(
. clk_in(clk_in),
. clk_100Hz(clk_100Hz),//100Hz--corresponds to 10ms
.start_key(key_1_negedge),//start//pause
.reset_key(key_2_negedge),//reset
. stopwatch_Millisecond(stopwatch_Millisecond),//10 milliseconds
. stopwatch_second(stopwatch_second),//second
. stopwatch_minute(stopwatch_minute)//minute
);
//Timing module
timing i_timing(
. clk_in(clk_in),
. clk_1Hz(clk_1Hz),//1Hz
.mode_SW(mode_SW),//Mode control switch
.set_time_key(set_time_key),//Set time
.confirm_key(confirm_key),//confirm
. change_time_key(change_time_key),//Set hours, minutes and seconds
.LED(LED),
.countdown_hour_time(countdown_hour_time),//hour
.countdown_minute_time(countdown_minute_time),//minute
. countdown_second_time(countdown_second_time)//秒
);
//显示模块
display i_display(
. clk(clk_in),
. watch_minute(stopwatch_minute),//分
. watch_second(stopwatch_second),//秒
. watch_milsecond(stopwatch_Millisecond),//10毫秒
. countdown_hour_time(countdown_hour_time),//时
. countdown_minute_time(countdown_minute_time),//分
. countdown_second_time(countdown_second_time),//秒
. dig_led_1(dig_led_1),
. wei_led_1(wei_led_1),
. dig_led_2(dig_led_2),
. wei_led_2(wei_led_2)
);
endmodule

Guess you like

Origin blog.csdn.net/diaojiangxue/article/details/134796308