我是靠谱客的博主 烂漫烧鹅,这篇文章主要介绍HDLBits练习——Dff16e前言代码总结,现在分享给大家,希望可以做个参考。

Create 16 D flip-flops. It’s sometimes useful to only modify parts of a group of flip-flops. The byte-enable inputs control whether each byte of the 16 registers should be written to on that cycle. byteena[1] controls the upper byte d[15:8], while byteena[0] controls the lower byte d[7:0].

resetn is a synchronous, active-low reset.

All DFFs should be triggered by the positive edge of clk.


前言

四个输入,包括一个时钟clk,一个低电平有效的同步置位信号resetn,一个控制字节能否输出的信号byteena,一个信号输入d;一个输出信号q。

代码

module top_module (
    input clk,
    input resetn,
    input [1:0] byteena,
    input [15:0] d,
    output [15:0] q
);
    always@(posedge clk)begin
        if(!resetn) q<=16'h0000;
        else begin
            if (&byteena[1:0]) q<=d;
            else if (byteena[1]) q[15:8]<=d[15:8];
            else if (byteena[0]) q[7:0]<=d[7:0];
            else q<=q;
        end
    end
endmodule

总结

对于byteena控制信号而言,其对输出信号的影响仅为在该个时间上升沿触发时,能否将新的d值写入,如果不能则q值保持原样,因此else部分q非阻塞赋值为q。

最后

以上就是烂漫烧鹅最近收集整理的关于HDLBits练习——Dff16e前言代码总结的全部内容,更多相关HDLBits练习——Dff16e前言代码总结内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部