Consider the n-bit shift register circuit shown below:
Write a Verilog module named top_module for one stage of this circuit, including both the flip-flop and multiplexers.
前言
五个输入,包括一个时钟clk,一个一级二路选择器1端的输入信号w,一个一级二路选择器的控制信号E,一个二级二路选择器1端的输入信号R,一个二级二路选择器的控制信号L;一个输出信号Q。
代码
module top_module (
input clk,
input w, R, E, L,
output Q
);
always@(posedge clk)begin
Q<=L?R:E?w:Q;
end
endmodule
总结
对于判断语句的复用,注意靠近问号的为真。