HDLbits——Exams/m2014 q4k

//四级移位寄存器
module top_module (
    input clk,
    input resetn,   // synchronous reset
    input in,
    output reg out);
    reg [2:0] Q;
    always @(posedge clk)begin
        if(~resetn)begin
            {Q,out} <= 4'b0;
        end
        else begin
            Q[2] <= in;
            Q[1] <= Q[2];
            Q[0] <= Q[1];
            out <= Q[0];
        end
    end

endmodule

posted @ 2021-09-06 14:21  冰峰漫步  阅读(445)  评论(0编辑  收藏  举报