其他分享
首页 > 其他分享> > HDLbits刷题笔记—shift4

HDLbits刷题笔记—shift4

作者:互联网

Description:

Build a 4-bit shift register (right shift), with asynchronous reset, synchronous load, and enable.

If both the load and ena inputs are asserted (1), the load input has higher priority.

module top_module(
    input clk,
    input areset,  // async active-high reset to zero
    input load,
    input ena,
    input [3:0] data,
    output reg [3:0] q); 
    always@(posedge clk or posedge areset)begin
        if(areset)
            q<=0;
        else begin
            case({ena,load})
                2'b00:q<=q;
                2'b01:q<=data;
                2'b10:q<=q>>1;
                2'b11:q<=data;
            endcase
        end
    end

endmodule

 

标签:load,HDLbits,shift,register,areset,zero,shift4,input,刷题
来源: https://www.cnblogs.com/tao1997/p/15518546.html