embedded - PISO 寄存器输出不如预期
问题描述
我在 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代码没问题,应该可以正常工作。
解决方案
您希望Qout
信号成为移位寄存器 ( Q
) 的输出而不是输入,以便输出切换而不是保持为 1。更改:
Qout <= d[3];
至:
Qout <= Q[3];
推荐阅读
- python - len() 函数显示 45 个值,而不是它应该显示的 90 个值,我做错了什么?
- mysql - 左连接重复并计算所有行
- git - 使用 .gitignore 从 git repo 中排除文件夹
- php - 如何用正则表达式 php 替换 URL 的多个参数
- php - 如何使用 iptables 模拟 mysql 不监听端口?
- c++11 - 解决:无锁队列多生产者多消费者——内存损坏
- angular - angular6:如何显示表单的值
- architecture - 根据我的情况推荐最佳方法(多租户与使用 abp 的单租户)
- java - 如何使用 Snake YAML Java 加载多个 yaml 文件?
- ios - 文本字段在 IOS carplay 中没有接受任何输入