Implement the following circuit:
前言
三个输入,包括一个时钟clk,一个高电平有效的异步置位信号ar,一个信号输入d;一个输出信号q。
代码
module top_module (
input clk,
input d,
input ar,
output q);
always@(posedge clk or posedge ar)begin
if(ar) q<= 1'b0;
else q<= d;
end
endmodule
总结
同步/异步置位信号的区别在于always后面列表的写法上,如果是同步置位那么敏感列表只有时钟,置位与时钟同步;但如果是异步置位,则敏感列表必须添上置位信号,时钟未触发但置位触发时,发生有效置位。