[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.

复制代码
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'b0;
        else begin
            if(byteena[0])
                q[7:0]<=d[7:0];
            if(byteena[1])
                q[15:8]<=d[15:8];
        end
    end
endmodule
相关推荐
daxi15015 小时前
Verilog入门实战——第5讲:Testbench 仿真编写 + 波形查看与分析
fpga开发
FPGA的花路19 小时前
UDP协议
fpga开发·以太网·udp协议
简简单单做算法20 小时前
【第2章>第2节】基于FPGA的图像双线性插值实现——理论分析与MATLAB仿真
matlab·fpga·图像双线性插值
LCMICRO-133108477461 天前
长芯微LPS123完全P2P替代ADP123,高性能、低压差的线性稳压器
单片机·嵌入式硬件·fpga开发·硬件工程·dsp开发·线性稳压器
fei_sun1 天前
面经、笔试(持续更新中)
fpga开发·面试
xixixi777771 天前
通信领域的“中国速度”:从5G-A到6G,从地面到星空
人工智能·5g·安全·ai·fpga开发·多模态
Nobody331 天前
Verilog always语句详解:从组合逻辑到时序逻辑
fpga开发
李嘉图Ricado1 天前
FPGA 时序约束与分析
fpga开发
白又白、2 天前
时序优化和上板调试小结
fpga开发
Z22ZHaoGGGG2 天前
verilog实现采样电流有效值的计算
fpga开发