我需要修改这个环形计数器以从最高有效位转移到最低有效位,然后重置回最高有效位。输出应如下所示:
100000
010000
001000
000100
000010
000001
100000
环形计数器
module ringcounter(clk, rst, count);
input clk, rst;
output [5:0] count;
wire clk, rst;
reg [5:0] count = 6'b1;
// Respond to the positive-going pulse edge
always @ ( posedge clk )
begin
if ( ~rst )
begin
count <= count << 1;
count[0] <= count[5];
end
end
// Respond to the positive-going reset signal
always @ ( posedge rst )
begin
count <= 6'b1;
end
endmodule
环形计数器测试台
module ringcounter_tb();
reg clk = 0, rst = 0;
wire [5:0] count;
always #1 clk = !clk; // Create a clock pulse
initial begin
$monitor("At time %4t, count = %b", $time, count );
#20 rst = 1;
#1 rst = 0;
#20 $finish;
end
ringcounter cntr01 ( .clk(clk), .rst(rst), .count(count) );
endmodule
我对数字逻辑还是很陌生,所以请多多包涵。我对如何修改这个环形计数器有点困惑。任何形式的帮助或解释这将如何工作,将不胜感激。