Chisel始终生成只有灵敏度列表中的时钟的块:
always @posedge(clk) begin
[...]
end
是否可以将Module配置为使用异步复位并生成这样的always块?
always @(posedge clk or posedge reset) begin
[...]
end
答案 0 :(得分:4)
看起来这个问题已在其他地方的互联网上被问过......答案是Chisel本身并没有内置这个功能。
看起来在Chisel中执行此操作的方法是使用同步重置:
always @posedge(clk) begin
if (reset) begin
[...]
end
else
[...]
end
end
有关该主题的更多讨论: https://groups.google.com/forum/#!topic/chisel-users/4cc4SyB5mk8
答案 1 :(得分:2)
自Chisel 3.2.0起,支持同步,异步和抽象重置类型。根据显式指定或推断的重置类型,您将获得规范的同步或异步Verilog输出。
要尝试更全面地显示此内容,请考虑以下MultiIOModule
,该重置具有三个重置:
reset
输入syncReset
类型(这是“同步重置”)的显式Bool
输入asyncReset
类型(这是“异步重置”)的显式AsyncReset
输入使用withReset
,然后可以将特定的复位连接用于设计中的不同寄存器:
import chisel3._
import chisel3.stage.ChiselStage
class Foo extends MultiIOModule {
val syncReset = IO(Input(Bool() ))
val asyncReset = IO(Input(AsyncReset()))
val in = IO(Input( Bool()))
val outAbstract = IO(Output(Bool()))
val outSync = IO(Output(Bool()))
val outAsync = IO(Output(Bool()))
val regAbstract = RegNext(in, init=0.U)
val regSync = withReset(syncReset) { RegNext(in, init=0.U) }
val regAsync = withReset(asyncReset) { RegNext(in, init=0.U) }
outAbstract := regAbstract
outSync := regSync
outAsync := regAsync
}
然后使用(new ChiselStage).emitVerilog(new Foo)
编译时,将产生以下Verilog:
module Foo(
input clock,
input reset,
input syncReset,
input asyncReset,
input in,
output outAbstract,
output outSync,
output outAsync
);
reg regAbstract;
reg regSync;
reg regAsync;
assign outAbstract = regAbstract;
assign outSync = regSync;
assign outAsync = regAsync;
always @(posedge clock) begin
if (reset) begin
regAbstract <= 1'h0;
end else begin
regAbstract <= in;
end
if (syncReset) begin
regSync <= 1'h0;
end else begin
regSync <= in;
end
end
always @(posedge clock or posedge asyncReset) begin
if (asyncReset) begin
regAsync <= 1'h0;
end else begin
regAsync <= in;
end
end
endmodule
注意:在Chisel 3.2中,顶层抽象重置将始终设置为同步重置。在Chisel 3.3.0中,添加了两个特征:RequireSyncReset
和RequireAsyncReset
。这些可用于将连接到regAbstract
的寄存器的重置类型从同步更改为异步。使用(new ChiselStage).emitVerilog(new Foo with RequireAsyncReset)
重新编译设计,将regAbstract
逻辑更改为
always @(posedge clock or posedge reset) begin
if (reset) begin
regAbstract <= 1'h0;
end else begin
regAbstract <= in;
end
end