Skip to content
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

PRCI: use new RecordMap API to name signals #2487

Closed

Conversation

mwachs5
Copy link
Contributor

@mwachs5 mwachs5 commented May 26, 2020

Related issue: This builds on top of #2486 and will be rebased on top of it as that API changes.

This demonstrates the use of the new RecordListMap. API to get better names for clock group signals

In the comments I'll include a diff before and after this change.

Type of change:feature request

Impact: API modification

(Generated RTL will have different output)

Development Phase: implementation

Release Notes

I/O and internal signals in the clock related modules (ClockSource, ClockGroup, etc) will have more meaninguful I/O names vs simply indexed names.

@mwachs5 mwachs5 requested a review from hcook May 26, 2020 18:27
@@ -73,7 +73,7 @@ object ClockSourceNode
object ClockGroupImp extends SimpleNodeImp[ClockGroupSourceParameters, ClockGroupSinkParameters, ClockGroupEdgeParameters, ClockGroupBundle]
{
def edge(pd: ClockGroupSourceParameters, pu: ClockGroupSinkParameters, p: Parameters, sourceInfo: SourceInfo) = ClockGroupEdgeParameters(pd, pu, p, sourceInfo)
def bundle(e: ClockGroupEdgeParameters) = new ClockGroupBundle(e.bundle)
def bundle(e: ClockGroupEdgeParameters) = new ClockGroupBundle(e.bundle, Some(e.bundle.members.zipWithIndex.map{ case (_, i) => s"${e.sink.name}_${i}"}))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hcook I am right that only the sink has a name, right? there is no source so I can't do something like "source_to_sink" right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, though such functionality would be an argument for adding such a parameter. The source-side parameters are very underdeveloped. We could also think about adding the NodePath functionality that some of the other protocols have, then lieu of a parameterized name you might be able to get the ValName of the source node or the module name of it's parent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But even just knowing the sink is useful IMO

@mwachs5
Copy link
Contributor Author

mwachs5 commented May 26, 2020

attaching the diff for DefaultConfig:
diff.txt

For example, old:

module ClockGroupAggregator_1( // @[:freechips.rocketchip.system.DefaultConfig.fir@28996.2]
  input   auto_in_member_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@28997.4]
  input   auto_in_member_0_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@28997.4]
  output  auto_out_member_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@28997.4]
  output  auto_out_member_0_reset // @[:freechips.rocketchip.system.DefaultConfig.fir@28997.4]
);

new:

module ClockGroupAggregator( // @[:freechips.rocketchip.system.DefaultConfig.fir@44.2]
  input   auto_in_member_subsystem_sbus_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_subsystem_sbus_0_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_0_member_subsystem_sbus_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_0_member_subsystem_sbus_0_reset // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
);

@mwachs5
Copy link
Contributor Author

mwachs5 commented May 26, 2020

old:

module ClockGroupAggregator( // @[:freechips.rocketchip.system.DefaultConfig.fir@44.2]
  input   auto_in_member_5_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_5_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_4_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_4_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_3_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_3_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_2_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_2_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_1_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_1_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  input   auto_in_member_0_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_3_member_1_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_3_member_1_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_3_member_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_3_member_0_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_2_member_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_2_member_0_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_1_member_1_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_1_member_1_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_1_member_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_1_member_0_reset, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_0_member_0_clock, // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
  output  auto_out_0_member_0_reset // @[:freechips.rocketchip.system.DefaultConfig.fir@45.4]
);

new:

...? Actually not sure what happened to this one in the new world.

@mwachs5
Copy link
Contributor Author

mwachs5 commented May 26, 2020

so maybe I screwed something up here...

@mwachs5 mwachs5 force-pushed the prci-use-heterogeneous-bag-api branch from 4754f0c to 148a159 Compare June 1, 2020 09:45
@mwachs5 mwachs5 changed the title PRCI: use new HeterogeneousBag API to name signals PRCI: use new RecordListMap API to name signals Jun 1, 2020
implicit val pp = p
val ioClockGroupSourceNode = ClockGroupSourceNode(List.fill(num) { ClockGroupSourceParameters() })
groups :*= ioClockGroupSourceNode
InModuleBody { ioClockGroupSourceNode.makeIOs()(vn) }
InModuleBody {
val bundlesAndEdges = ioClockGroupSourceNode.out
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is basically a rewrite of makeIOs from diplomacy.Nodes, which assumes Heterogeneous Bag

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah in a follow up PR we should just entirely replace that use of HeterogeneousBag with RecordListMap, I think. Will require sed/updating a moderate amount of boilerplate closed source code to change arguments like "io: HeterogeneousBag" to "io: Record" though

@mwachs5 mwachs5 force-pushed the prci-use-heterogeneous-bag-api branch from 5f15496 to 4304966 Compare June 6, 2020 13:29
@mwachs5
Copy link
Contributor Author

mwachs5 commented Jun 6, 2020

This is currently giving me a compile error (just running make verilog) that I don't understand (and also seems weirdly formatted):

info] [0.001] Elaborating design...
[error] java.lang.ClassCastException: freechips.rocketchip.prci.ClockBundle cannot be cast to scala.runtime.Nothing$
[error] 	...
[error] ocketchiat freechips.rocketchip.util.RecordMap.$anonfun$elements$1(RecordMap.scala:22)
[error] 	at scala.collection.MapLike$MappedValues.$anonfun$foreach$3(MapLike.scala:256)
[error] 	at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:877)

@mwachs5 mwachs5 changed the title PRCI: use new RecordListMap API to name signals PRCI: use new RecordMap API to name signals Jun 15, 2020
@mwachs5 mwachs5 force-pushed the prci-use-heterogeneous-bag-api branch from 4734b39 to 38d2be8 Compare June 15, 2020 21:28
@mwachs5
Copy link
Contributor Author

mwachs5 commented Jun 15, 2020

Here's the current example of what this creates:

Screen Shot 2020-06-15 at 3 37 47 PM

I am still a little confused why we end up with only one output instead of 6 in the SimpleClockGroupSource, I think I am checking for duplicates in the wrong place in RecordMap (does a ListMap already not allow duplicates?)

Screen Shot 2020-06-15 at 3 42 13 PM

@mwachs5
Copy link
Contributor Author

mwachs5 commented Jun 19, 2020

Just as an update I'm still very weirded out by the before-and-after diff. If I look at the fir that comes out, the diff looks as I expect: all the same wires and I/Os are there, they just have better names ("member.sbus_0.clock" vs "member.0.clock" and so on). But in the verilog most of the signals are removed including entire modules. I am going to do a run with the split-trace on to see when they diverge.

@mwachs5
Copy link
Contributor Author

mwachs5 commented Jun 21, 2020

I think I figured out what was wrong /different with this.

In the original, this line does something:
https://github.com/chipsalliance/rocket-chip/blob/master/src/main/scala/diplomacy/LazyModule.scala#L292

In this new version, that is tied off to 1'b0:
Screen Shot 2020-06-21 at 2 46 13 PM

Which may be why things get constant-propped away. Still looking at the FIRRTL intermediate to see where things diverge

@mwachs5 mwachs5 closed this Jun 21, 2020
@mwachs5 mwachs5 force-pushed the prci-use-heterogeneous-bag-api branch from 38d2be8 to 1cec6e6 Compare June 21, 2020 22:06
@mwachs5
Copy link
Contributor Author

mwachs5 commented Jun 22, 2020

im not sure why this PR is closed but also says "merged and closed". Something is weird in github-land. Anyway, I have a suspicion what is wrong here... somewhere I am combining HeterogeneousBags of ClockGroupBundles whose names don't match up. I think the auto-bundle-zipping of diplomacy (:=) is then not matching them up. In other words, somewhere I am trying to attach a HeterogenousBag[ClockGroupBundle] := HeterogeneousBag[ClockGroupBundle] and since the two ClockGroupBundles have different RecordMap parameters, the signals don't just magically get zipped together. Need to figure out where this is happening and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants