-
-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin deadlock in circular dependency on Handle #1331
Comments
Hi, the Plugin1.logic and Plugin2.logic content can only be accessed form the outside once they completted. An alternative to your workaround is : class Plugin2 extends FiberPlugin {
val const = during setup Bool()
val logic = during build new Area {
val o = out(Bool())
o := host[Plugin1].logic.int
}
} or class Plugin2 extends FiberPlugin {
val api = during setup new Area{
val const = Bool()
}
val logic = during build new Area {
val o = out(Bool())
o := host[Plugin1].logic.int
}
} |
Great! Unrelated to the deadlock, I noticed that both approaches are a bit weird with naming: for example if you do val MyKey = NamedType(Bool()) MyKey would actually get a |
Hi,
That is done on purpose. So, there is one fondamental thing about the Plugin thing which is very different from Component / Module, is that the idea, is that the Plugin are themself parameters, so they may can come nameless, from the outside. Here is an example : class VexiiRiscv extends Component {
val host = new PluginHost
}
SpinalVerilog{
val toplevel = new VexiiRiscv
//Now let's parametrize the CPU with some plugins
toplevel.host.asHostOf(List(
new PluginA(),
new PluginB(),
new PluginC(),
new PluginD()
))
toplevel
} But i just pushed a change which allow you so use it your way : class PluginX extends FiberPlugin {
val logic = during setup new Area {
val x = True
}
}
class PluginY extends FiberPlugin {
val logic = during setup new Area {
val Y = True
}
}
class VexiiRiscv extends Component {
val host = new PluginHost
val plugX = new PluginX()
host.asHostOf(plugX)
}
SpinalVerilog{
val toplevel = new VexiiRiscv()
//Now let's parametrize the CPU with some plugins
toplevel.host.asHostOf(List(
new PluginY()
))
toplevel
} =>
About the dead lock thing, i'm working on it, got it to report error on dead lock circular chain inside each phase (not working yet when the chain cross phase) For instance that : object PlayComposablePlugin2 extends App {
import spinal.lib.misc.pipeline._
class PluginA extends FiberPlugin {
val retainer = Retainer()
val logic = during setup new Area{
val b = host[PluginB]
val bRetainer = retains(b.retainer)
awaitBuild()
retainer.await()
}
}
class PluginB extends FiberPlugin {
val retainer = Retainer()
val logic = during setup new Area {
val c = host[PluginC]
val cRetainer = retains(c.retainer)
awaitBuild()
retainer.await()
}
}
class PluginC extends FiberPlugin {
val retainer = Retainer()
val logic = during setup new Area {
val a = host[PluginA]
val aRetainer = retains(a.retainer)
awaitBuild()
retainer.await()
}
}
class VexiiRiscv extends Component {
val host = new PluginHost
}
SpinalVerilog{
val toplevel = new VexiiRiscv()
//Now let's parametrize the CPU with some plugins
toplevel.host.asHostOf(List(
new PluginA(),
new PluginB(),
new PluginC()
))
toplevel
}
} Now report
It also report when a plugin thread retains something, but finished without releasing it We can do a call to talk about all the API :D |
Thanks for the clarification! I'm working with a global profiler and the keys would represent timestamps for phases in the design; this should be global. I think your example shows it nicely, I'll see if I can adapt. Let's arrange the call about API designs on LinkedIn :) |
Yes sure ^^ Pushed changes to improve the error reporting on your case :
|
I'm trying out the plugin framework and encountered some deadlock issue:
Elaboration failed with a rather cryptic error message:
My understanding is that since
Plugin1.logic.int
andPlugin2.logic.o
are in different phases (setup and build), there should not be a real loop here. An ugly workaround is to have a null-initializedconst
outside of the logic block:But with this workaround
const
loses its name inside the area. Is there a better way to specify this type of dependency?Also, it would save a lot of headaches if the error message is improved / documentation is updated.
The text was updated successfully, but these errors were encountered: