When declaring a new Module's io I got the following error:
[error] (run-main-e) chisel3.core.Binding$RebindingException: Attempted reassignment of binding to chisel3.core.UInt@29a
[error] chisel3.core.Binding$RebindingException: Attempted reassignment of binding to chisel3.core.UInt@29a
[error] at chisel3.core.Data.binding_$eq(Data.scala:250)
[error] at chisel3.core.Element.bind(Bits.scala:22)
[error] at chisel3.core.Aggregate$$anonfun$bind$1.apply(Aggregate.scala:23)
[error] at chisel3.core.Aggregate$$anonfun$bind$1.apply(Aggregate.scala:22)
[error] at scala.collection.Iterator$class.foreach(Iterator.scala:891)
[error] at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
[error] at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[error] at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[error] at chisel3.core.Aggregate.bind(Aggregate.scala:22)
[error] at chisel3.core.Aggregate$$anonfun$bind$1.apply(Aggregate.scala:23)
[error] at chisel3.core.Aggregate$$anonfun$bind$1.apply(Aggregate.scala:22)
[error] at scala.collection.Iterator$class.foreach(Iterator.scala:891)
[error] at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
[error] at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[error] at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[error] at chisel3.core.Aggregate.bind(Aggregate.scala:22)
[error] at chisel3.core.Aggregate$$anonfun$bind$1.apply(Aggregate.scala:23)
[error] at chisel3.core.Aggregate$$anonfun$bind$1.apply(Aggregate.scala:22)
[error] at scala.collection.Iterator$class.foreach(Iterator.scala:891)
[error] at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
[error] at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[error] at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
[error] at chisel3.core.Aggregate.bind(Aggregate.scala:22)
[error] at chisel3.core.BaseModule._bindIoInPlace(Module.scala:249)
[error] at chisel3.core.BaseModule.IO(Module.scala:282)
[error] at RayIntersect.LeafIntersect.<init>(PrimIntersect.scala:71)
[error] at RayIntersect.MyTopLevelVerilog$$anonfun$1.apply(RayIntersectTest.scala:11)
[error] at RayIntersect.MyTopLevelVerilog$$anonfun$1.apply(RayIntersectTest.scala:11)
[error] at chisel3.core.Module$.do_apply(Module.scala:49)
[error] at chisel3.Driver$$anonfun$elaborate$1.apply(Driver.scala:93)
[error] at chisel3.Driver$$anonfun$elaborate$1.apply(Driver.scala:93)
[error] at chisel3.internal.Builder$$anonfun$build$1.apply(Builder.scala:297)
[error] at chisel3.internal.Builder$$anonfun$build$1.apply(Builder.scala:295)
[error] at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
[error] at chisel3.internal.Builder$.build(Builder.scala:295)
[error] at chisel3.Driver$.elaborate(Driver.scala:93)
[error] at chisel3.Driver$.execute(Driver.scala:140)
[error] at chisel3.Driver$.execute(Driver.scala:202)
[error] at RayIntersect.MyTopLevelVerilog$.delayedEndpoint$RayIntersect$MyTopLevelVerilog$1(RayIntersectTest.scala:11)
[error] at RayIntersect.MyTopLevelVerilog$delayedInit$body.apply(RayIntersectTest.scala:5)
[error] at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
[error] at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error] at scala.App$$anonfun$main$1.apply(App.scala:76)
[error] at scala.App$$anonfun$main$1.apply(App.scala:76)
[error] at scala.collection.immutable.List.foreach(List.scala:392)
[error] at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
[error] at scala.App$class.main(App.scala:76)
[error] at RayIntersect.MyTopLevelVerilog$.main(RayIntersectTest.scala:5)
[error] at RayIntersect.MyTopLevelVerilog.main(RayIntersectTest.scala)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] at sbt.Run.invokeMain(Run.scala:93)
[error] at sbt.Run.run0(Run.scala:87)
[error] at sbt.Run.execute$1(Run.scala:65)
[error] at sbt.Run.$anonfun$run$4(Run.scala:77)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
[error] at sbt.TrapExit$App.run(TrapExit.scala:252)
[error] at java.lang.Thread.run(Thread.java:745)
Where the line that's being referenced in the error (line 71 of RayIntersect.LeafIntersect) is the following:
val io = IO(new Bundle {
Here's the rest of the io declaration if it helps:
val io = IO(new Bundle {
val rayNodeStackIn = Flipped(DecoupledIO(new RayBVHNodeStackIdx(id_width, index_width)))
val shadow = Input(Bool())
val rayNodeOut = DecoupledIO(new RayBVHNode(id_width, index_width))
val dataOut = DecoupledIO(new Bundle {
val foundInt = Bool()
val f = UInt(index_width.W)
val its = new Intersection()
})
//Memory system interface
val addrOut = DecoupledIO(new Bundle {
val id = UInt(id_width.W)
val trIdx = UInt(prim_id_width.W)
}
val dataIn = Flipped(DecoupledIO(new Bundle {
val id = UInt(id_width.W)
val data = UInt((new Triangle()).getWidth)
}))
})
Here's the code for the used Bundles:
class Triangle() extends Bundle {
val p0 = Vec(3, UInt(32.W))
val p1 = Vec(3, UInt(32.W))
val p2 = Vec(3, UInt(32.W))
val idx = UInt(32.W)
val meshAddr = UInt(32.W)
}
class BVHNode() extends Bundle {
val data = UInt(64.W)
val bbox = new Bundle {
val min = Vec(3, UInt(32.W))
val max = Vec(3, UInt(32.W))
}
def rightChild: UInt = (data << 32)
def leafStart : UInt = (data << 32)
def leafSize : UInt = (data << 1) & 0xFFFFFFFE.U
def start : UInt = leafStart
def end : UInt = leafStart + leafSize
def isLeaf : Bool = data(0)
override def cloneType = (new BVHNode()).asInstanceOf[this.type]
}
class Ray(sid_width : Int) extends Bundle {
val origin = Vec(3, UInt(32.W))
val dir = Vec(3, UInt(32.W))
val dRcp = Vec(3, UInt(32.W)) //Componentwise reciprocals of the ray direction
val minT = UInt(32.W)
val maxT = UInt(32.W)
val id = UInt(32.W)
override def cloneType = (new Ray(sid_width)).asInstanceOf[this.type]
}
class RayBVHNodeStackIdx(id_width: Int, index_width: Int) extends Bundle {
val ray = new Ray(id_width)
val node = new BVHNode()
val nodeIdx = UInt(index_width.W)
val stackIdx = UInt(index_width.W)
override def cloneType = (new RayBVHNodeStackIdx(id_width, index_width)).asInstanceOf[this.type]
}
class RayBVHNode(id_width: Int, index_width : Int) extends Bundle {
val ray = new Ray(id_width)
val node = new BVHNode()
val nodeIdx = UInt(index_width.W)
override def cloneType = (new RayBVHNode(id_width, index_width)).asInstanceOf[this.type]
}
class Intersection() extends Bundle {
val t = UInt(32.W) //Unoccluded distance along the ray
val u = UInt(32.W) //UV coordinate, if any
val v = UInt(32.W) //Other UV coordinate
val mesh = UInt(32.W) //pointer to the intersected mesh
}
From what I've read, this error usually happens when trying to use a bare Chisel type as Hardware, however I really don't get why the error is coming from the io declaration...
Has anyone else ever encountered this problem in their implementation and, if so, would you know by any chance how to fix it?
I was able to run this code just fine with one minor modification. I added a .W
to val data = UInt((new Triangle()).getWidth.W)
:
val dataIn = Flipped(DecoupledIO(new Bundle {
val id = UInt(id_width.W)
val data = UInt((new Triangle()).getWidth)
}))
becomes
val dataIn = Flipped(DecoupledIO(new Bundle {
val id = UInt(id_width.W)
val data = UInt((new Triangle()).getWidth.W)
}))
Judging by the stack trace and error message, this looks like an older version of Chisel. Prior to Chisel 3.2.0
, UInt(someInt)
created a literal, the same as someInt.U
(it was deprecated since Chisel 3.0.0
though). I was able to reproduce the reported error using Chisel 3.1.8
. The error I received running this code with 3.2.2
pinpointed the problem making it an easy fix!
I would suggest keeping up to date with the newest version of Chisel possible (as of Jan 13, 2020 that's 3.2.2
). You can keep an eye on the "releases" page of the repo to see new versions: https://github.com/freechipsproject/chisel3/releases.