在编写 Chisel 代码时如何在生成的 Verilog 代码中将复位信号添加到灵敏度列表中,例如下面的 D 触发器代码:
val x = Reg(init = UInt(0, width = 1))
x := io.D
io.Q := x
将生成一个 Verilog 代码,如下所示:
always @(posedge clk) begin
if(reset) begin
x <= 1'h0;
end else begin
x <= io_D;
end
end
如所见,重置与时钟同步,如何编写 Chisel 代码以生成如下内容:
always @(posedge clk or posedge reset) begin
if(reset) begin
x <= 1'h0;
end else begin
x <= io_D;
end
end
其中复位信号在灵敏度列表中,因此是异步的。