Dff8ar 习题笔记

该模块描述了一个使用Verilog编写的8位D触发器阵列,每个触发器都具有活动高异步复位功能。在时钟的正沿触发时,如果复位信号为高,则触发器的输出被清零;否则,输出跟随输入数据d变化。敏感列表中包含posedgeclk和posedgereset,即使reset是电平触发,这样设计也能确保在复位信号变为高时有效复位。
摘要由CSDN通过智能技术生成

Create 8 D flip-flops with active high asynchronous reset. All DFFs should be triggered by the positive edge of clk.

module top_module(
    input clk,
    input [7:0] d,
    input areset,
    output reg [7:0] q);
    
    // The only difference in code compared to synchronous reset is in the sensitivity list.
    always @(posedge clk, posedge areset)
        if (areset)
            q <= 0;
        else
            q <= d;


    // In Verilog, the sensitivity list looks strange. The FF's reset is sensitive to the
    // *level* of areset, so why does using "posedge areset" work?
    // To see why it works, consider the truth table for all events that change the input 
    // signals, assuming clk and areset do not switch at precisely the same time:
    
    //  clk        areset        output
    //   x         0->1        q <= 0; (because areset = 1)
    //   x         1->0        no change (always block not triggered)
    //  0->1       0        q <= d; (not resetting)
    //  0->1       1        q <= 0; (still resetting, q was 0 before too)
    //  1->0       x        no change (always block not triggered)
    
endmodule
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值