Confusion about the diplomacy tutorial in the rocket chip repo

45 views
Skip to first unread message

Jerry Ho

unread,
Oct 28, 2020, 9:26:31 AM10/28/20
to RISC-V HW Dev
Hey everyone, I followed the adder tutorial of diplomacy inside the rocket chip repo, https://github.com/chipsalliance/rocket-chip/blob/master/docs/src/diplomacy/adder_tutorial.md
there are two requires(require(dps.forall(dp => dp.width ==dps.head), "inward, downward adder widths must be equivalent") and  require(ups.forall(dp => dp.width == ups.head), "outward, upward adder width must be equivalent")inside  the definition of the  Adder class(the LazyModule which has a nexusNode embeded in), if I keep the require, sbt run will complain the following:
[info] [0.004] Elaborating design...
the width of the UpwardParam(4) in 4
[error] java.lang.IllegalArgumentException: requirement failed: outward, upward adder width must be equivalent
[error] ...
[error] at adder_diplomacy_example.Adder.$anonfun$node$5(Adder.scala:98)
[error] at freechips.rocketchip.diplomacy.MixedNexusNode.mapParamsU(Nodes.scala:1566)
[error] at freechips.rocketchip.diplomacy.MixedNode.liftedTree3$1(Nodes.scala:1178)
[error] at freechips.rocketchip.diplomacy.MixedNode.uiParams$lzycompute(Nodes.scala:1175)
[error] at freechips.rocketchip.diplomacy.MixedNode.uiParams(Nodes.scala:1174)
[error] at freechips.rocketchip.diplomacy.MixedNode.edgesIn$lzycompute(Nodes.scala:1197)
[error] at freechips.rocketchip.diplomacy.MixedNode.edgesIn(Nodes.scala:1197)
[error] at freechips.rocketchip.diplomacy.MixedNode.$anonfun$bundleIn$1(Nodes.scala:1216)
[error] at chisel3.internal.prefix$.apply(prefix.scala:47)
[error] at freechips.rocketchip.diplomacy.MixedNode.bundleIn$lzycompute(Nodes.scala:1216)
[error] at freechips.rocketchip.diplomacy.MixedNode.bundleIn(Nodes.scala:1216)
[error] at freechips.rocketchip.diplomacy.MixedNode.in(Nodes.scala:1255)
[error] at freechips.rocketchip.diplomacy.MixedNode.instantiate(Nodes.scala:1266)
[error] at freechips.rocketchip.diplomacy.LazyModuleImpLike.$anonfun$instantiate$3(LazyModule.scala:287)
[error] at scala.collection.immutable.List.flatMap(List.scala:338)
[error] at freechips.rocketchip.diplomacy.LazyModuleImpLike.instantiate(LazyModule.scala:287)
[error] at freechips.rocketchip.diplomacy.LazyModuleImpLike.instantiate$(LazyModule.scala:273)
[error] at freechips.rocketchip.diplomacy.LazyModuleImp.instantiate(LazyModule.scala:348)
[error] at freechips.rocketchip.diplomacy.LazyModuleImp.<init>(LazyModule.scala:350)
[error] at adder_diplomacy_example.Adder$$anon$1.<init>(Adder.scala:103)
[error] at adder_diplomacy_example.Adder.module$lzycompute(Adder.scala:103)
[error] at adder_diplomacy_example.Adder.module(Adder.scala:103)
[error] at adder_diplomacy_example.Adder.module(Adder.scala:87)
[error] at freechips.rocketchip.diplomacy.LazyModuleImpLike.$anonfun$instantiate$2(LazyModule.scala:280)
[error] at chisel3.Module$.do_apply(Module.scala:54)
[error] at freechips.rocketchip.diplomacy.LazyModuleImpLike.$anonfun$instantiate$1(LazyModule.scala:280)
[error] at scala.collection.immutable.List.flatMap(List.scala:338)
[error] at freechips.rocketchip.diplomacy.LazyModuleImpLike.instantiate(LazyModule.scala:278)
[error] at freechips.rocketchip.diplomacy.LazyModuleImpLike.instantiate$(LazyModule.scala:273)
[error] at freechips.rocketchip.diplomacy.LazyModuleImp.instantiate(LazyModule.scala:348)
[error] at freechips.rocketchip.diplomacy.LazyModuleImp.<init>(LazyModule.scala:350)
[error] at adder_diplomacy_example.AdderTestHarness$$anon$5.<init>(Adder.scala:163)
[error] at adder_diplomacy_example.AdderTestHarness.module$lzycompute(Adder.scala:163)
[error] at adder_diplomacy_example.AdderTestHarness.module(Adder.scala:163)
[error] at adder_diplomacy_example.diplomacyExample$.$anonfun$verilog$1(Adder.scala:173)
[error] ... (Stack trace trimmed to user code only, rerun with --full-stacktrace if you wish to see the full stack trace)
Exception in thread "main" firrtl.options.StageError: 
at chisel3.stage.ChiselStage.run(ChiselStage.scala:58)
at firrtl.options.Stage$$anon$1.transform(Stage.scala:43)
at firrtl.options.Stage$$anon$1.transform(Stage.scala:43)
at firrtl.options.phases.DeletedWrapper.internalTransform(DeletedWrapper.scala:38)
at firrtl.options.phases.DeletedWrapper.internalTransform(DeletedWrapper.scala:15)
at firrtl.options.Translator.transform(Phase.scala:248)
at firrtl.options.Translator.transform$(Phase.scala:248)
at firrtl.options.phases.DeletedWrapper.transform(DeletedWrapper.scala:15)
at firrtl.options.Stage.$anonfun$transform$5(Stage.scala:47)
at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:126)
at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:122)
at scala.collection.immutable.List.foldLeft(List.scala:89)
at firrtl.options.Stage.$anonfun$transform$3(Stage.scala:47)
at logger.Logger$.$anonfun$makeScope$2(Logger.scala:166)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at logger.Logger$.makeScope(Logger.scala:164)
at firrtl.options.Stage.transform(Stage.scala:47)
at firrtl.options.Stage.execute(Stage.scala:58)
at chisel3.stage.ChiselStage.emitVerilog(ChiselStage.scala:115)
at adder_diplomacy_example.diplomacyExample$.delayedEndpoint$adder_diplomacy_example$diplomacyExample$1(Adder.scala:173)
at adder_diplomacy_example.diplomacyExample$delayedInit$body.apply(Adder.scala:172)
at scala.Function0.apply$mcV$sp(Function0.scala:39)
at scala.Function0.apply$mcV$sp$(Function0.scala:39)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
at scala.App.$anonfun$main$1$adapted(App.scala:80)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.App.main(App.scala:80)
at scala.App.main$(App.scala:78)
at adder_diplomacy_example.diplomacyExample$.main(Adder.scala:172)
at adder_diplomacy_example.diplomacyExample.main(Adder.scala)
Caused by: chisel3.internal.ChiselException: Exception thrown when elaborating ChiselGeneratorAnnotation
at chisel3.stage.ChiselGeneratorAnnotation.elaborate(ChiselAnnotations.scala:65)
at chisel3.stage.phases.Elaborate.$anonfun$transform$1(Elaborate.scala:24)
at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245)
at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242)
at scala.collection.immutable.List.flatMap(List.scala:355)
at chisel3.stage.phases.Elaborate.transform(Elaborate.scala:23)
at chisel3.stage.phases.Elaborate.transform(Elaborate.scala:16)
at firrtl.options.phases.DeletedWrapper.internalTransform(DeletedWrapper.scala:38)
at firrtl.options.phases.DeletedWrapper.internalTransform(DeletedWrapper.scala:15)
at firrtl.options.Translator.transform(Phase.scala:248)
at firrtl.options.Translator.transform$(Phase.scala:248)
at firrtl.options.phases.DeletedWrapper.transform(DeletedWrapper.scala:15)
at firrtl.options.DependencyManager.$anonfun$transform$3(DependencyManager.scala:278)
at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:126)
at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:122)
at scala.collection.immutable.List.foldLeft(List.scala:89)
at firrtl.options.DependencyManager.transform(DependencyManager.scala:269)
at firrtl.options.DependencyManager.transform$(DependencyManager.scala:255)
at firrtl.options.PhaseManager.transform(DependencyManager.scala:436)
at chisel3.stage.ChiselStage.run(ChiselStage.scala:44)
... 29 more
Caused by: java.lang.IllegalArgumentException: requirement failed: outward, upward adder width must be equivalent
at scala.Predef$.require(Predef.scala:281)
at adder_diplomacy_example.Adder.$anonfun$node$5(Adder.scala:98)
at freechips.rocketchip.diplomacy.MixedNexusNode.mapParamsU(Nodes.scala:1566)
at freechips.rocketchip.diplomacy.MixedNode.liftedTree3$1(Nodes.scala:1178)
at freechips.rocketchip.diplomacy.MixedNode.uiParams$lzycompute(Nodes.scala:1175)
at freechips.rocketchip.diplomacy.MixedNode.uiParams(Nodes.scala:1174)
at freechips.rocketchip.diplomacy.MixedNode.edgesIn$lzycompute(Nodes.scala:1197)
at freechips.rocketchip.diplomacy.MixedNode.edgesIn(Nodes.scala:1197)
at freechips.rocketchip.diplomacy.MixedNode.$anonfun$bundleIn$1(Nodes.scala:1216)
at chisel3.internal.prefix$.apply(prefix.scala:47)
at freechips.rocketchip.diplomacy.MixedNode.bundleIn$lzycompute(Nodes.scala:1216)
at freechips.rocketchip.diplomacy.MixedNode.bundleIn(Nodes.scala:1216)
at freechips.rocketchip.diplomacy.MixedNode.instantiate(Nodes.scala:1266)
at freechips.rocketchip.diplomacy.LazyModuleImpLike.$anonfun$instantiate$3(LazyModule.scala:287)
at scala.collection.immutable.List.flatMap(List.scala:338)
at freechips.rocketchip.diplomacy.LazyModuleImpLike.instantiate(LazyModule.scala:287)
at freechips.rocketchip.diplomacy.LazyModuleImpLike.instantiate$(LazyModule.scala:273)
at freechips.rocketchip.diplomacy.LazyModuleImp.instantiate(LazyModule.scala:348)
at freechips.rocketchip.diplomacy.LazyModuleImp.<init>(LazyModule.scala:350)
at adder_diplomacy_example.Adder$$anon$1.<init>(Adder.scala:103)
at adder_diplomacy_example.Adder.module$lzycompute(Adder.scala:103)
at adder_diplomacy_example.Adder.module(Adder.scala:103)
at adder_diplomacy_example.Adder.module(Adder.scala:87)
at freechips.rocketchip.diplomacy.LazyModuleImpLike.$anonfun$instantiate$2(LazyModule.scala:280)
at chisel3.Module$.do_apply(Module.scala:54)
at freechips.rocketchip.diplomacy.LazyModuleImpLike.$anonfun$instantiate$1(LazyModule.scala:280)
at scala.collection.immutable.List.flatMap(List.scala:338)
at freechips.rocketchip.diplomacy.LazyModuleImpLike.instantiate(LazyModule.scala:278)
at freechips.rocketchip.diplomacy.LazyModuleImpLike.instantiate$(LazyModule.scala:273)
at freechips.rocketchip.diplomacy.LazyModuleImp.instantiate(LazyModule.scala:348)
at freechips.rocketchip.diplomacy.LazyModuleImp.<init>(LazyModule.scala:350)
at adder_diplomacy_example.AdderTestHarness$$anon$5.<init>(Adder.scala:163)
at adder_diplomacy_example.AdderTestHarness.module$lzycompute(Adder.scala:163)
at adder_diplomacy_example.AdderTestHarness.module(Adder.scala:163)
at adder_diplomacy_example.diplomacyExample$.$anonfun$verilog$1(Adder.scala:173)
at chisel3.Module$.do_apply(Module.scala:54)
at chisel3.stage.ChiselGeneratorAnnotation.$anonfun$elaborate$1(ChiselAnnotations.scala:60)
at chisel3.internal.Builder$.$anonfun$build$1(Builder.scala:625)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at chisel3.internal.Builder$.build(Builder.scala:622)
at chisel3.stage.ChiselGeneratorAnnotation.elaborate(ChiselAnnotations.scala:60)
... 50 more

I comment the two requires code and there is no error(with the verilog generated),  then I add some println to print the dps and ups, I think the require should pass, I have no idea why this is wrong, and why you guys add the require there.


I have another confusion that why you use SimpleNodeImp as the Node implementation to conduct the param negotiation in this tutorial. The comment of the SimpleNodeImp says that A NodeImp where the inward and outward edge parameters are of the same type. But apparently there is no inward edge for a SourceNode, but a SourceNode can stll use the SimpleNodeImp as the Node implementation right?

In your API, every Node should  have a node implementation as their class variable, but I feel like Node Implementation should go above node,  can a sourceNode and  the correspondingly paired sinknode have different Node Implementations? If yes, why? I thought the job of  NodeImplementation is setting up the Edge param according to the up and down params, so the Node Implementation instance of the two paired node should be exactly the same.
Any help will be great, Thanks!

Jerry Ho

unread,
Oct 28, 2020, 10:20:12 AM10/28/20
to RISC-V HW Dev, Jerry Ho
Sorry, I found the cause, I  carelessly forgot to call the .width property of the dps.head. It should be "dps.forall(dp => dp.width ==dps.head.width", the tutorial is right. Sorry to waste ur time, But I still wanna know the following:


I have another confusion that why you use SimpleNodeImp as the Node implementation to conduct the param negotiation in this tutorial. The comment of the SimpleNodeImp says that A NodeImp where the inward and outward edge parameters are of the same type. But apparently there is no inward edge for a SourceNode, but a SourceNode can stll use the SimpleNodeImp as the Node implementation right?

In your API, every Node should  have a node implementation as their class variable, but I feel like Node Implementation should go above node,  can a sourceNode and  the correspondingly paired sinknode have different Node Implementations? If yes, why? I thought the job of  NodeImplementation is setting up the Edge param according to the up and down params, so the Node Implementation instance of the two paired node should be exactly the same.
Any help will be great, Thanks!
Reply all
Reply to author
Forward
0 new messages