A Self-reset Ring Counter realized using Verilog HDL
题目来自《Digital Design:Principles and Practices》。
This problem is from Digital Design:Principles and Practices
This problem is from Digital Design:Principles and Practices
8.56.写出状态为1111 1110,1111 1101, 1111 1011, 1111 0111, ……, 0111 1111, 1111 1110, ……的8位自校正计数器的VHDL或Verilog程序。要求计数器具有复位输入和时能输入,当复位信号有效是计数器回到初始状态,只有当时能信号有效是才计数。
本设计选择使用Verilog硬件描述语言,选择Altera Quartus II 软件作为编译工具。
在下边的代码中,复位端子RST和使能端子ENA均为高电平有效,均为同步输入端。
本设计选择使用Verilog硬件描述语言,选择Altera Quartus II 软件作为编译工具。
在下边的代码中,复位端子RST和使能端子ENA均为高电平有效,均为同步输入端。
The following code snippet is hosted on Github Gist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DDPP8_56(CLK, RST, ENA, DIGI); | |
input CLK, RST, ENA; | |
output [7:0] DIGI; | |
reg [7:0] DIGI; | |
wire tmp; | |
assign tmp = {DIGI[6:0]==7'b1111111}?0:1; | |
always @(posedge CLK) | |
begin | |
if (RST) DIGI <= 8'b11111110; | |
else | |
case (ENA) | |
1: DIGI <= {DIGI[6:0],tmp}; | |
0: DIGI <= DIGI; | |
endcase | |
end | |
endmodule |
没有评论:
发表评论