1 //电子表的设计包括正常计时模块,LED显示模块,定时报警模块,校时模块,秒表模块。 2 //(1)正常计时模块clock 3 module clock(clk,rst,clock_en,second,minute,hour); 4 input clk,rst,clock_en; 5 output[5:0]second,minute,hour; 6 reg[5:0]second,minute,hour; 7 always@(posedge clk or negedge rst or posedge clock_en) 8 if(!rst) 9 begin 10 second<=0; minute<=0; hour<=0; 11 end 12 else if(clock_en) 13 begin 14 if(second==59) 15 begin 16 minute<=minute+1; 17 second<=0; 18 end 19 else if(minute==59) 20 begin 21 hour<=hour+1; 22 minute<=0; 23 end 24 else if(hour==23) 25 hour<=0; 26 else 27 second<=second+1; 28 end 29 endmodule
30 //(2)LED显示模块LED_display 31 module LED_display(data,high,low); 32 input[5:0]data; 33 output[7:0]high,low; 34 reg[7:0]high,low; 35 reg[3:0]out_h,out_l; 36 always@(data) 37 begin 38 out_h<=data/10; 39 out_l<=data; 40 end 41 always@(out_l) 42 case(out_l) 43 4'b0000:low<=8'b00000000; 44 4'b0001:low<=8'b01100000; 45 4'b0010:low<=8'b11011010; 46 4'b0011:low<=8'b11110010; 47 4'b0100:low<=8'b01100110; 48 4'b0101:low<=8'b10110110; 49 4'b0110:low<=8'b10111110; 50 4'b0111:low<=8'b11100000; 51 4'b1000:low<=8'b11111110; 52 4'b1001:low<=8'b11110110; 53 default:low<=8'b00000000; 54 endcase 55 56 always@(out_h) 57 case(out_h) 58 4'b0000:high<=8'b00000000; 59 4'b0001:high<=8'b01100000; 60 4'b0010:high<=8'b11011010; 61
电子表verilog
最新推荐文章于 2023-10-19 22:05:57 发布
本文详细介绍了如何使用Verilog硬件描述语言设计并实现一个电子表的功能,包括时间显示、定时器设置等模块,同时探讨了时序逻辑和组合逻辑在设计中的应用。
摘要由CSDN通过智能技术生成