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

FireSim x Chipyard Decoupled #1984

Merged
merged 10 commits into from
Aug 22, 2024
Merged

FireSim x Chipyard Decoupled #1984

merged 10 commits into from
Aug 22, 2024

Conversation

abejgonzalez
Copy link
Contributor

@abejgonzalez abejgonzalez commented Aug 9, 2024

Sister PR: firesim/firesim#1791

Originally FireSim and Chipyard were coupled sharing things like (1) Scala sources (and SBT sources) (2) Conda environments (3) Bridges (...) and more. However, this PR decouples FireSim from Chipyard s.t. all "target" (ie. DUT) specific features are located in Chipyard (ie. things like FireSim UART bridges, NIC bridges, etc) and FireSim provides a hook to Chipyard so that I can run the FireSim makefile itself.

This includes the following:

  • Removes existing FireSim CI tests run in chipyard-run-tests.yml (in the past, we directly invoked the FireSim compiler to test simple RISC-V tests) in favor of new CI run during chipyard-full-flow.yml (Scala-based testing moved from FireSim).
  • Adds a firesim-staging simulator area where there is a FireSim symlink that points to FireSim when FireSim is top.
  • In build.sbt abstracts the Scala test dependency
  • Updates common.mk s.t. it points to the right FireSim sources.
  • Separates out the firechip area into 3 SBT projects. core (FireSim top-level harness and target-specific bridges), bridge-interfaces (target bridge interfaces that are copied into FireSim), firesim-only (the FireSim-only side of target-specific bridges).

Chipyard documentation is minimally changed (FireSim documentation needs to be updated).

Related PRs / Issues:

Type of change:

  • Bug fix
  • New feature
  • Other enhancement

Impact:

  • RTL change
  • Software change (RISC-V software)
  • Build system change
  • Other

Contributor Checklist:

  • Did you set main as the base branch?
  • Is this PR's title suitable for inclusion in the changelog and have you added a changelog:<topic> label?
  • Did you state the type-of-change/impact?
  • Did you delete any extraneous prints/debugging code?
  • Did you mark the PR with a changelog: label?
  • (If applicable) Did you update the conda .conda-lock.yml file if you updated the conda requirements file?
  • (If applicable) Did you add documentation for the feature?
  • (If applicable) Did you add a test demonstrating the PR?
  • (If applicable) Did you mark the PR as Please Backport?

build.sbt Outdated Show resolved Hide resolved
build.sbt Show resolved Hide resolved
common.mk Show resolved Hide resolved
.settings(commonSettings)
.settings(chiselSettings)
// TODO: AJG: ^ Fix
Copy link
Contributor Author

@abejgonzalez abejgonzalez Aug 19, 2024

Choose a reason for hiding this comment

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

I'll fix this in another PR.

@abejgonzalez abejgonzalez requested a review from jerryz123 August 19, 2024 19:15
@abejgonzalez abejgonzalez changed the title WIP: FireSim x Chipyard Decoupled FireSim x Chipyard Decoupled Aug 19, 2024
@abejgonzalez abejgonzalez marked this pull request as ready for review August 19, 2024 21:53
@abejgonzalez
Copy link
Contributor Author

This is ready for review (passes all CI except for commit-on-master).

Copy link
Contributor

@jerryz123 jerryz123 left a comment

Choose a reason for hiding this comment

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

I think I understand why bridges are in here - they are target-specific.

It is not as clear to me why the .mk fragments are here. Aren't those core parts of firesim's build system that should remain with firesim? In what ways are they target-specific?

@abejgonzalez
Copy link
Contributor Author

abejgonzalez commented Aug 20, 2024

I think I understand why bridges are in here - they are target-specific.

It is not as clear to me why the .mk fragments are here. Aren't those core parts of firesim's build system that should remain with firesim? In what ways are they target-specific?

You can think of them similarly to vcs.mk or the Verilator Makefile. They are the hooks that FireSim provides to a downstream project (i.e. Chipyard) to configure it's make system to do the right thing. Specifically, they indicate how to regenerate the FIRRTL/annos, define extra target specific simulation flags, define default make flags, point to bridge CC files, define default driver arguments, and more. All of these things are target-specific.

With VCS/Verilator in Chipyard we directly invoke the Makefile in the respective folder which calls the tools. FireSim is a bit different since there is the FireSim manager. The manager call's FireSim's firesim/sim/Makefile which points to the makefrag hooks put here, allowing FireSim to do the right thing.

@jerryz123
Copy link
Contributor

Ok I see, so this is a side-effect of fs's Python manager invoking makefiles that describe construction of target-specific things.

I think a longer-term goal would be to avoid having the interface to firesim be through make fragments, but this arrangement is fine fo rnow.

@abejgonzalez
Copy link
Contributor Author

Ok I see, so this is a side-effect of fs's Python manager invoking makefiles that describe construction of target-specific things.

I think a longer-term goal would be to avoid having the interface to firesim be through make fragments, but this arrangement is fine fo rnow.

I agree. But I think this is sufficient for now (like you said)

@jerryz123
Copy link
Contributor

Separates out the firechip area into 3 SBT projects. core (FireSim top-level harness and target-specific bridges), bridge-interfaces (target bridge interfaces that are copied into FireSim), firesim-only (the FireSim-only side of target-specific bridges).

I'm not sure I'm a fan of firechip.core, I found myself needing to refer to this comment to remind myself that firechip.core contains target-specific things, the "core" throws me off. How about "firechip.target"? Basically everything that used to be firechip is now in here right?

@abejgonzalez
Copy link
Contributor Author

abejgonzalez commented Aug 20, 2024

Separates out the firechip area into 3 SBT projects. core (FireSim top-level harness and target-specific bridges), bridge-interfaces (target bridge interfaces that are copied into FireSim), firesim-only (the FireSim-only side of target-specific bridges).

I'm not sure I'm a fan of firechip.core, I found myself needing to refer to this comment to remind myself that firechip.core contains target-specific things, the "core" throws me off. How about "firechip.target"? Basically everything that used to be firechip is now in here right?

I'm avoiding calling things target because SBT generates the target directory for built Scala classes under what would originally be core (i.e. firechip/target/target for Scala classes rather than firechip/target/src/... for everything else)(assuming you name the subdirectory after the package name). I didn't spend much time thinking of a better name than core to avoid this. Happy to change the package path though if you have another rec. And yes, this core package contains all the old code of FireChip.

@jerryz123
Copy link
Contributor

Ah, that conflict is a very good point.
How about:

  • firechip.chip
  • firechip.bridges.interfaces
  • firechip.bridges.implementations

@abejgonzalez
Copy link
Contributor Author

abejgonzalez commented Aug 20, 2024

How about this instead:

  • firechip.core.firesim -> firechip.chip under folder firechip/chip/src/main/scala/*.scala
  • firechip.core.bridges -> firechip.bridges.implementations (technically these are stubs not implementations since the implementations live on the FireSim-side - I think stubs would be better here) under folder firechip/bridgesimplementations/src/main/scala/*.scala
  • firechip.bridgeinterfaces -> firechip.bridges.interfaces under folder firechip/bridgesinterfaces/src/main/scala/*.scala
  • firechip.firesimonly.bridges -> firechip.firesimonly under folder firechip/firesimonly/src/main/scala/*.scala

The bridge interfaces should be in a separate SBT project / src/main/scala area so that it is easy to symlink in the Makefrags (ideally).

Edit: Can also combine the package path a bit so things are consistent: firechip.bridgesinterfaces and firechip.bridgesimplementations

@joonho3020
Copy link
Contributor

I find the name firesimonly a bit confusing.
What about

firechip.bridges.io: for the IO ports & case classes
firechip.bridges.hooks: for the annotation generator
firechip.bridges.implementations : for the HostBridge RTL implementation

@abejgonzalez
Copy link
Contributor Author

I find the name firesimonly a bit confusing. What about

firechip.bridges.io: for the IO ports & case classes firechip.bridges.hooks: for the annotation generator firechip.bridges.implementations : for the HostBridge RTL implementation

IMO interfaces is better than io since IMO io generally denotes just Chisel IOs. I think hooks is ok (I think it's about as good as stubs). I like keeping firesimonly to strongly tell users "this folder is not compiled with Chipyard" directly from looking at the folder structure. Why do you think its confusing?

@joonho3020
Copy link
Contributor

I would like the name to convey that these are bridge RTL implementations which are elaborated when midas runs. firesim-only doesn't describe what these files are... What about midas-input-impls?

Copy link
Contributor

@jerryz123 jerryz123 left a comment

Choose a reason for hiding this comment

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

Overall this looks fine. Once we resolve the package naming, I think this can be merged

@abejgonzalez
Copy link
Contributor Author

How about this instead:

  • firechip.core.firesim -> firechip.chip under folder firechip/chip/src/main/scala/*.scala
  • firechip.core.bridges -> firechip.bridgeimplementations (technically these are stubs not implementations since the implementations live on the FireSim-side - I think stubs would be better here) under folder firechip/bridgeimplementations/src/main/scala/*.scala
  • firechip.bridgeinterfaces -> firechip.bridgeinterfaces under folder firechip/bridgesinterfaces/src/main/scala/*.scala
  • firechip.firesimonly.bridges -> firechip.goldengateimplementations under folder firechip/goldengateimplementations/src/main/scala/*.scala

Ok @joonho3020 how about this?

@joonho3020
Copy link
Contributor

I don't want to nitpick too much, but now firechip.core.bridges -> firechip.bridgeimplementations is confusing. Can we just use bridgestubs like you mentioned?

@abejgonzalez
Copy link
Contributor Author

Nitpick now or forever hold your peace.

  • firechip.core.firesim -> firechip.chip under folder firechip/chip/src/main/scala/*.scala
  • firechip.core.bridges -> firechip.bridgestubs under folder firechip/bridgestubs/src/main/scala/*.scala
  • firechip.bridgeinterfaces -> firechip.bridgeinterfaces under folder firechip/bridgeinterfaces/src/main/scala/*.scala
  • firechip.firesimonly.bridges -> firechip.goldengateimplementations under folder firechip/goldengateimplementations/src/main/scala/*.scala

How about now?

@joonho3020
Copy link
Contributor

joonho3020 commented Aug 21, 2024

Thanks, I like it

@abejgonzalez
Copy link
Contributor Author

Disabling CI since the latest commit(s) shouldn't affect anything.

@abejgonzalez abejgonzalez merged commit 87edef0 into main Aug 22, 2024
10 of 58 checks passed
@abejgonzalez abejgonzalez mentioned this pull request Aug 26, 2024
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants