verilog滚动显示日期20170427
时间: 2023-09-12 14:08:36 浏览: 32
以下是一个基于 Verilog 的滚动显示日期20170427的代码示例:
```
module date_display(
input clk,
input reset,
output reg [31:0] display
);
reg [3:0] year;
reg [1:0] month;
reg [4:0] day;
reg [31:0] counter;
reg [31:0] shift_reg;
reg [3:0] shift_cnt;
always @(posedge clk or posedge reset) begin
if (reset) begin
year <= 7'b0000000;
month <= 2'b00;
day <= 5'b00000;
counter <= 0;
shift_reg <= 0;
shift_cnt <= 4'b0000;
end else begin
if (counter == 0) begin
year <= 7'b0000000;
year[3:0] <= 7'b0011111; // 2017
month <= 2'b01; // 04
day <= 5'b11011; // 27
end
if (counter == 50000000) begin // every 1 second
counter <= 0;
if (day == 5'b11111) begin
day <= 5'b00001;
if (month == 2'b11) begin
month <= 2'b00;
if (year[3:0] == 7'b1111) begin
year[3:0] <= 7'b0000;
year[7] <= ~year[7];
end else begin
year[3:0] <= year[3:0] + 1;
end
end else begin
month <= month + 1;
end
end else begin
day <= day + 1;
end
end else begin
counter <= counter + 1;
end
if (shift_cnt == 4'b1111) begin
shift_cnt <= 4'b0000;
end else begin
shift_cnt <= shift_cnt + 1;
end
shift_reg <= {shift_reg[27:0], day, month, year};
end
end
assign display = {shift_reg[31:28], shift_reg[23:20], shift_reg[19:15], shift_reg[14:0][shift_cnt]};
endmodule
```
该模块包括一个时钟输入,一个复位输入和一个32位输出,用于显示滚动日期20170427。在每秒钟的计时器触发下,该模块更新日期寄存器,并将其存储在移位寄存器中,以便将其滚动显示。输出显示值是从移位寄存器中选择的特定位。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)