[RTLLM-p029] Control/Counter/ring_counter 的題解


記住 在沒有思路時使用題解,不要從它複製貼上程式碼。請尊重題目和題解的作者。
在真正解決題目之前提交題解的程式碼是可以封禁的罪行。

作者: m1145505

module ring_counter (
    input wire clk,
    input wire reset,
    output reg [7:0] out
);


reg [7:0] state;

// State initialization
always @ (posedge clk or posedge reset)
begin
    if (reset)
        state <= 8'b0000_0001; 
    else
        state <= {state[6:0], state[7]}; 
end

assign out = state;

endmodule

評論

目前沒有評論。