ucb-bar / chisel2-deprecated

chisel.eecs.berkeley.edu
387 stars 89 forks source link

Redo type nodes #590

Open da-steve101 opened 8 years ago

da-steve101 commented 8 years ago

When creating a node literal such as:

val tmp = UInt(0, 4)
val tmpReg = RegInit(UInt(0, 4))
tmp := tmpReg

Gives "Real node required here, but 'type' node found"

class SubMod[T <: Bits](genType : T) extends Module {
  val io = new Bundle {
     val a = genType.cloneType.asInput
     val b = genType.cloneType.asOutput
  }
  io.b := RegNext(io.a)
}
val sub = Module(new SubMod[UInt](UInt(0, 4)) ) // causes error
val sub = Module(new SubMod[UInt](UInt(width = 4)) ) // allowed

Where as it cannot be used as a type to clone from giving "Could not elaborate code due to uninferred width" I think the first case should be allowed by creating it as a node with a default value rather than a type node. The second example should be allowed via cloneType creating a new type node if genType is not a type node (with the proposal that UInt(0, 4) not be a type node but UInt(width = 4) is). Maybe add a getType() method to Node to make things easy? Thoughts/Comments?