【问题标题】:PISO register output is not as expectedPISO 寄存器输出不如预期
【发布时间】:2020-12-06 19:01:07
【问题描述】:

我的 PISO verilog 寄存器有问题。 下面是我的代码

`timescale 1ns / 1ps
module PISO(
    input clk,
    input load, 
    input [3:0] d,
    output reg Qout);  

reg [3 : 0]Q;  


always @ (posedge clk)
begin

if ( load  ) 
  Q <= d;
else
begin 
  Qout <= d[3];
  Q<= { Q[2:0] , 1'b0 };
  end
end
endmodule

和我的测试台

`timescale 1ns / 1ps
module PISO_tb();

PISO uut(clk,load,d,Qout);
reg clk;
reg load;
reg [3:0]d;
wire Qout;

initial begin
clk=0;
forever #5 clk = ~clk;
end

initial begin

load = 1;
d[0] = 1'b0;
d[1] = 1'b1;
d[2] = 1'b0;
d[3] = 1'b1;
#6 load = 0;

end
endmodule

它不能正常工作,请帮我测试一下吧?因为我觉得verilog代码没问题,应该可以正常工作。

【问题讨论】:

    标签: embedded verilog fpga


    【解决方案1】:

    您希望Qout 信号成为移位寄存器 (Q) 的输出而不是输入,以便输出切换而不是保持为 1。更改:

    Qout <= d[3];
    

    到:

    Qout <= Q[3];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多