Implement the following circuit:
前言
三个输入,包括一个时钟clk,一个低电平有效的同步置位信号resetn,一个输入信号in;一个输出信号out。
代码
module top_module (
input clk,
input resetn,
input in,
output out);
reg out1,out2,out3;
always@(posedge clk)begin
if(!resetn) {out1,out2,out3,out}<=4'b0;
else {out1,out2,out3,out}<={in,out1,out2,out3};
end
endmodule
总结
out输出不是直接写入的,是通过三次时钟触发后写入的,构造三个传递的中间值,通过数据右移3个bit得到out值。