Chisel-3.2 RC2がリリースされている。いくつかの新機能が加わっているが、気になるのはAsynchronous Resetのサポートだ。
これだけ見ても良く分からないので、ChiselリポジトリのPull Requestを見て何となく使い方を調べてみた。
テストする前に、build.sbt
のChiselのバージョンを上げておく。
build.sbt
// Provide a managed dependency on X if -DXVersion="" is supplied on the command line. val defaultVersions = Map( "chisel3" -> "3.2.0-RC2", "chisel-iotesters" -> "1.2.+", "dsptools" -> "1.1.+" )
テスト回路を書いてみる。
package async_reset import chisel3._ import chisel3.util._ import chisel3.Bool class AsyncResetTest extends Module { val io = IO(new Bundle { val asyncReset: AsyncReset = Input(AsyncReset()) val in = Input(UInt(32.W)) val out = Output(UInt(32.W)) }) val ff = withReset(io.asyncReset) { RegInit(0.U(32.W)) } ff := io.in io.out := ff } object main extends App { chisel3.Driver.emitVerilog(new AsyncResetTest()) }
ポイントとしてはwithReset
でasyncReset
信号を使用しており、これで入力信号asyncReset
に応じて非同期リセットがかけられるようになるらしい。
上記のff
は非同期リセットになっている。
sbt 'runMain async_reset.main
生成されるVerilogは以下となる。これ、Negative Edgeにはできないのかな?FIRRTLのソースコードをみて、Negativeにする方法がないか調べてみよう。
module AsyncResetTest( input clock, input reset, input io_asyncReset, input [31:0] io_in, output [31:0] io_out ); .. always @(posedge clock or posedge io_asyncReset) begin if (io_asyncReset) begin ff <= 32'h0; end else begin ff <= io_in; end end endmodule