Comments (7)
Ahh fixed, you were triggering another clone case escaping the init :D
from spinalhdl.
Btw. as a small note: in usual case we'd recommend to use case class
instead of class
for Bundle
s and Components
which will auto-generate a correct clone
routine.
Just as a note for those that stumble over this question here ;-)
from spinalhdl.
Hi,
That's a bug i just fixed now.
You normaly need to implement clone only for Bundle which aren't case class and have parameters (either explicit or from the scala execution stack)
from spinalhdl.
The commit doesn't fix the NPE given by the example, when clone is not overriden... For Union
we call newElement
in the constructor (not in postInitCallback
)
from spinalhdl.
I tested with :
class Toplevel extends Component{
case class TestUnion() extends Union {
val a = newElement(UInt(4 bits))
val b = newElement(Bits(4 bits))
}
val a = TestUnion()
val b = a.clone.asInstanceOf[TestUnion]
b.a := U(15)
}
Which went well on my side, can you provide a fully self contained case for me to reproduce ?
from spinalhdl.
So the example I have is:
import spinal.core._
case class TestUnion() extends Union {
val a = newElement(UInt(4 bits))
val b = newElement(Bits(4 bits))
}
object TestStreamUnion extends App {
SpinalVerilog(new Component {
val a = TestUnion()
val b = a.clone.asInstanceOf[TestUnion]
b.a := U(3)
})
}
Exception:
[Runtime] SpinalHDL dev git head : 5e40a78aa6a4b5cf8be503eed1f5b084101bbaab
[Runtime] JVM max memory : 16012.0MiB
[Runtime] Current date : 2024.03.04 13:44:47
[Progress] at 0.000 : Elaborate components
ERROR !
A null pointer access has been detected in the JVM.
This could happen when in your SpinalHDL description, you access an signal which is only defined further.
For instance :
val result = Bool()
result := a ^ b //a and b can't be accessed there because they are only defined one line below (Software rule of execution order)
val a,b = Bool()
Exception in thread "main" java.lang.NullPointerException
at spinal.core.UnionElement.$anonfun$get$1(Union.scala:12)
at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:469)
at spinal.core.signalCache$.apply(Misc.scala:169)
at spinal.core.signalCache$.apply(Misc.scala:172)
at spinal.core.UnionElement.get(Union.scala:12)
at spinal.core.UnionElement$.wrapped(Union.scala:8)
at pionic.TestStreamUnion$$anon$1.<init>(TestStreamUnion.scala:14)
at pionic.TestStreamUnion$.$anonfun$new$1(TestStreamUnion.scala:11)
at spinal.core.internals.PhaseCreateComponent.$anonfun$impl$273(Phase.scala:2556)
at spinal.core.fiber.Engine$.$anonfun$create$1(AsyncCtrl.scala:147)
at spinal.core.fiber.AsyncThread.$anonfun$jvmThread$1(AsyncThread.scala:59)
at spinal.core.fiber.EngineContext.$anonfun$newJvmThread$1(AsyncCtrl.scala:39)
at spinal.sim.JvmThread.run(SimManager.scala:51)
from spinalhdl.
I have no idea what that commit ID is; my local branch definitely includes bb24b25 .
from spinalhdl.
Related Issues (20)
- How to use Union in IO port HOT 1
- `assignDontCare` on Bundle element inside Union does not work HOT 14
- StateMachines inside Plugins that have multiple instances have naming clash HOT 2
- `Union` elements cannot be accessed inside SpinalSim properly HOT 1
- [question] Trying to understand simulator wait apis (newbie) HOT 3
- SimMutex locked repeatly crashes the simulation HOT 5
- Checking for unknown values in simulation HOT 1
- JTAG VPI Simulation gets blocked by IO HOT 2
- Dump ports of `Mem` in FST waveforms? HOT 3
- HDElkDiagram generated html could not be convert ed to image using wkhtmltoimage correctly HOT 1
- Qsysify and Axi4: incorrect _hw.tcl generation HOT 1
- Could not load XSI simulation shared library HOT 1
- Blackboxing RAM with one read and one readWrite port HOT 2
- Performance of PriorityMux HOT 18
- Redundant Flow API Calls. HOT 4
- Parallel test execution in SpinalSim? HOT 5
- Are there some bugs in clockDomain.waitSampling() API? HOT 10
- Is there a "DONT_TOUCH" attribute for Components in Spinal ? HOT 2
- Unknown reason for hierarchy violation HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spinalhdl.