The following snippet of code illustrates my top level clocking and reset strategy. I opt to use LazyRawModuleImp and explicitly specify the clocks and reset.
class LazyTop(implicit p: Parameters) extends LazyModule { lazy val module = new LazyRawModuleImp(this) { val io = IO(new Bundle { val ref_clk_p = Input(Clock()) val rst_sw_n = Input(Bool()) // async reset, debounced on board? val led_n = Output(Bits(8.W)) }) val GSR_INST = Module(new GSR()) // this is blackbox module GSR_INST.io.GSR := io.rst_sw_n val global_reset = Wire(Bool()) val global_reset_n = Wire(Bool()) global_reset_n := GSR_INST.io.GSR // appears GSR is active low global_reset := !GSR_INST.io.GSR // use active high clock withClockAndReset(ref_clk_p, global_reset) { io.led_n := RegNext("h5A".asUInt(8.W), init = 0.U) } } }
Module GSR is a Chisel BlackBox for my FPGA's GSR (global set reset) library cell.
class GSR extends BlackBox { val io = IO(new Bundle { val GSR = Input(Bool()) }) }
No comments:
Post a Comment