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.

创建 16 D flip-flops。有时只修改一组触发器的一部分很有用。使能字节的输入控制是否应在该周期内写入 16 个寄存器中的每个字节。byteena[1] 控制上字节 d[15:8],而 byteena[0] 控制下字节 d[7:0]。

cs 复制代码
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 <= 0;
            else if(byteena[0])     //从这里开始错误!!!
                q[7:0] <= d[7:0];  
            else if(byteena[1])
                q[15:8] <= d[15:8];  
        end
endmodule
相关推荐
daxi1501 天前
Verilog入门实战——第5讲:Testbench 仿真编写 + 波形查看与分析
fpga开发
FPGA的花路1 天前
UDP协议
fpga开发·以太网·udp协议
LCMICRO-133108477462 天前
长芯微LPS123完全P2P替代ADP123,高性能、低压差的线性稳压器
单片机·嵌入式硬件·fpga开发·硬件工程·dsp开发·线性稳压器
fei_sun2 天前
面经、笔试(持续更新中)
fpga开发·面试
xixixi777772 天前
通信领域的“中国速度”:从5G-A到6G,从地面到星空
人工智能·5g·安全·ai·fpga开发·多模态
Nobody332 天前
Verilog always语句详解:从组合逻辑到时序逻辑
fpga开发
李嘉图Ricado2 天前
FPGA 时序约束与分析
fpga开发
白又白、2 天前
时序优化和上板调试小结
fpga开发
Z22ZHaoGGGG2 天前
verilog实现采样电流有效值的计算
fpga开发
fei_sun2 天前
牛客Verilog刷题篇
fpga开发