【HDLBits刷题】Exams/2014 q4a.

Consider the n-bit shift register circuit shown below:

Write a Verilog module named top_module for one stage of this circuit, including both the flip-flop and multiplexers.

1、第一种方法是通过抽象方法,从电路最后面看,写出Q输出:

module top_module (
    input clk,
    input w, R, E, L,
    output Q
);

    wire temp1, temp2;

    assign temp1 = E ? w:Q; 
    assign temp2 = L ? R:temp1;
    //与上题类似,不做赘述

    always @ (posedge clk)
        begin
           Q <= temp2; 
        end

endmodule


// 下面一样的
****************************************

module top_module (
    input clk,
    input w, R, E, L,
    output Q
);
    always @(posedge clk)begin
        if(E==0&&L==0)
            Q <=Q;
        else if(L==1)
            Q <= R;
        else
            Q <= w;
    end
endmodule

 2、第二种是写单个模块,然后用结构型建模把子模块都连接起来

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值