black box and parameters

243 views
Skip to first unread message

Martin Schoeberl

unread,
Feb 13, 2016, 9:03:13 PM2/13/16
to chisel...@googlegroups.com
Hi all,

is there a way to provide parameters with a black box? Something done with defparam in Verilog or generic in VHDL.

Cheers,
Martin

Schuyler Eldridge

unread,
Feb 14, 2016, 1:38:17 PM2/14/16
to chisel-users
Take a look at hcl.scala (https://github.com/ucb-bar/chisel/blob/master/src/main/scala/hcl.scala). For a blackbox you can establish parameters with the VerilogParameters class and then apply the parameters to the blackbox with setVerilogParameters. There's a short example in hcl.scala of how to do this.

Note, you can alternatively do this directly with setVerilogParameters, but that is really just a way to append a string after the Verilog module name. A short example of the latter is below from a generic SRAM module that I use: 

class SRAM (
  val dataWidth
: Int = 8,
  val sramDepth
: Int = 64
) extends BlackBox {
  setVerilogParameters
(
   
"#(.WIDTH(" + dataWidth + ")," +
     
".DEPTH(" + sramDepth + ")," +
     
".LG_DEPTH(" + log2Up(sramDepth) + "))\n ")
  setName
("sram")
// ...
}

Schuyler Eldridge

unread,
Feb 14, 2016, 1:42:56 PM2/14/16
to chisel-users
Alternatively, Yaman has an example using VerilogParameters here (https://github.com/maltanar/fpga-tidbits/blob/master/on-chip-memory/DualPortBRAM.scala) which interfaces to a backend Verilog BRAM here (https://github.com/maltanar/fpga-tidbits/blob/master/on-chip-memory/DualPortBRAM.v).

Martin Schoeberl

unread,
Feb 16, 2016, 2:24:55 AM2/16/16
to chisel...@googlegroups.com
Hi Schuyler,

thanks, that worked out nicely.

Cheers,
Martin
> --
> You received this message because you are subscribed to the Google Groups "chisel-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chisel-users...@googlegroups.com.
> To post to this group, send email to chisel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/79135252-0014-41f1-9fdc-78dd1d6b6d1e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages