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

Standardize Tile Instantiation and Attachment #2504

Merged
merged 15 commits into from
Jun 18, 2020

Conversation

hcook
Copy link
Member

@hcook hcook commented Jun 5, 2020

HasTiles is refactored to eagerly instantiate tiles of all types by pulling instances of CanAttachTile out of a new Field named TilesLocated.

This change has the following benefits:

  • Any class <: BaseTile can be Config-urably instantiated inside a design without needing to mix in additional traits to the subsystem class hierarchy.
  • Various subsystem user code that would like to operate over the tiles list (e.g. nTiles) does not have to jump through hoops to ensure that it doesn't get called before all tile-adding traits are mixed in, because those traits no longer exist.

In order to make a tile instantiate-able via the new field, you must supply a class like this one:

case class RocketTileAttachParams(
  tileParams: RocketTileParams,
  crossingParams: RocketCrossingParams,
  lookup: LookupByHartIdImpl
) extends CanAttachTile { type TileType = RocketTile }

where

  • tileParams satisfies the new base class InstantiableTileParams[TileType] (you provide a function that instantiates an instance of your TileType)
  • crossingParams satisfies TileCrossingParamsLike, for which you could just use the example RocketCrossingParams.

Backwards compatibility:

  • Tiles can still be instantiated and attached manually via traits:
trait HasMyTiles extends HasTiles {
  val myTiles: Seq[MyTile] = p(MyTileField).map { ... }
  override val tiles = myTiles ++ super[HasTiles].tiles
  • However, if you do so, be aware that you will have to also manually connect your tiles.
  • The Fields RocketTilesKey and RocketCrossingKey are maintained for backwards compatibility and LegacyTileFieldHelper is applied to TilesLocated in BaseConfig to ensure that Config alterations that manipulate these fields continue to function
  • BaseTile now extends HasLogicalTreeNode, but a GenericLogicalTreeNode() is supplied, which can be overridden.

Type of change: other enhancement

Impact: API modification

Development Phase: implementation

Release Notes
val tiles in trait HasTiles is now populated eagerly via the TilesLocated Field.

@hcook hcook added the WIP label Jun 5, 2020
@hcook hcook force-pushed the instantiate-all-tiles-before-connecting branch 2 times, most recently from 2a7ddf1 to bcb294a Compare June 8, 2020 21:55
@hcook hcook removed the WIP label Jun 8, 2020
Copy link
Member

@aswaterman aswaterman left a comment

Choose a reason for hiding this comment

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

Seems like a good direction API-wise (but I didn't do a code review).

@@ -41,6 +41,8 @@ class BaseSubsystemConfig extends Config ((site, here, up) => {
case DebugModuleKey => Some(DefaultDebugModuleParams(site(XLen)))
case CLINTKey => Some(CLINTParams())
case PLICKey => Some(PLICParams())
case TilesLocated(InSubsystem) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Will there be an example for what direct manipulation of the TilesLocated pattern looks like? (Not using the LegacyTileFieldHelper)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion, will do

Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up doing this example in WithTraceGen for the TraceGenTile subtype. I'm not very keen to mess too much with the existing RocketTilesKey Config alterations since it it seems hard to change them while remaining backwards compatibly with external alterations of RocketTilesKey. Check out WithTraceGen and HeterogeneousTileExampleConfig and let me know if that is sufficiently helpful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, this is pretty clear.

I noticed that manipulation of core parameters is more verbose without direct access through CoreTilesKey, since the type of the core must be matched, and since AttachParams adds another layer of case-class nesting. Given that manipulating tile-level parameters is the common use-case of the core-specific TilesKey s, it may be worth defining a generic macro to modify the TileParams matching some desired Tile type.

Copy link
Member Author

Choose a reason for hiding this comment

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

if you can figure out a good pattern for applying a "lens" to nested case classes in Config alterations I will buy you a beer

Copy link
Member Author

Choose a reason for hiding this comment

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

But yes something specific to this particular use case is probably also possible

@hcook hcook force-pushed the instantiate-all-tiles-before-connecting branch 3 times, most recently from b1d2bb1 to e5b737e Compare June 15, 2020 16:41
@hcook hcook force-pushed the instantiate-all-tiles-before-connecting branch from e5b737e to 0286604 Compare June 16, 2020 20:53
@hcook hcook merged commit 1cec6e6 into master Jun 18, 2020
@hcook hcook deleted the instantiate-all-tiles-before-connecting branch September 3, 2020 19:08
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.

3 participants