我目前正在开发一个开发“记忆游戏”的项目 . 目前我有4个随机LED使用LSFR闪烁 . 我的问题是我需要LED一次闪烁1个,我不确定如何做到这一点 .
如果有人能提供建议我会非常感激!
module Memory_Game
#(parameter BITS = 5)
(clk, rst_n, out);
input clk;
input rst_n;
output reg [3:0] out;
reg [3:0] out_next;
integer count=0;
reg clk_1hz;
reg [3:0] I; //user input is stored here
reg [3:0] R;
initial begin
R <= 4'b0101;
I <= 4'b0000;
out_next <= 4'b0001;
end
always @ (posedge clk) begin // slows our clock from 50mhz to 1hz
if (count<25000000)
count = count +1;
else begin
clk_1hz = ~clk_1hz;
count = 0;
end
end
always @* begin // responsible for determing the blinking of the leds
out_next = out;
repeat(BITS) begin
R <= {R[2:0], R[3] ^ R[0]};
out_next = {out_next[2:0],(out_next[3]^out_next[0])};
end
end
always @(posedge clk_1hz or negedge rst_n) begin
if(!rst_n)
out <= 4'h1f;
else
out <= out_next;
end
endmodule