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

adding a Plusargs Bridge, with unit tests and TutorialSuite tests #1291

Merged
merged 21 commits into from
Nov 21, 2022

Conversation

sifive-benjamin-morse
Copy link
Contributor

@sifive-benjamin-morse sifive-benjamin-morse commented Nov 3, 2022

Adding a Plusargs Brige. Currently only the %d format is supported.

Related PRs / Issues

UI / API Impact

Verilog / AGFI Compatibility

This shouldn't change any existing code, but adds compatibilty with

Contributor Checklist

  • Is this PR's title suitable for inclusion in the changelog and have you added a changelog:<topic> label?
  • Did you add Scaladoc/docstring/doxygen to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous prints/debugging code?
  • Did you state the UI / API impact?
  • Did you specify the Verilog / AGFI compatibility impact?
  • If applicable, did you regenerate and publicly share default AGFIs?
  • If applicable, did you apply the ci:fpga-deploy label?
  • If applicable, did you apply the Please Backport label?

Reviewer Checklist (only modified by reviewer)

Note: to run CI on PRs from forks, comment @Mergifyio copy main and manage the change from the new PR.

  • Is the title suitable for inclusion in the changelog and does the PR have a changelog:<topic> label?
  • Did you mark the proper release milestone?
  • Did you check whether all relevant Contributor checkboxes have been checked?

@sifive-benjamin-morse sifive-benjamin-morse added the changelog:added Put PR title in 'Added' section of changelog label Nov 3, 2022
std::string name = name_orig;

// remove all leading white space
while (name.at(0) == ' ') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Breaking from convention, would it be possible to do such argument parsing outside the bridge constructor? Not necessarily in this PR, but maybe in the future. If exceptions will be disabled, there will be no way to report errors from constructors without exiting right away.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that makes a ton of sense. The whole +arg managements needs a rework (better scoping, better discoverability etc...) and pulling the parsing out of the bridge constructor would play nicely into that.

sim/midas/src/main/cc/bridges/plusargs.cc Outdated Show resolved Hide resolved
sim/midas/src/main/cc/bridges/plusargs.cc Outdated Show resolved Hide resolved
sim/midas/src/main/cc/bridges/plusargs.cc Outdated Show resolved Hide resolved
sim/src/main/cc/midasexamples/PlusargsModule.h Outdated Show resolved Hide resolved
sim/src/test/scala/midasexamples/TutorialSuite.scala Outdated Show resolved Hide resolved
Copy link
Contributor

@davidbiancolin davidbiancolin left a comment

Choose a reason for hiding this comment

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

The scala bridge code looks great -- i mostly have nits. My main concern is with the ScalaTests for the target-side of the bridge which could be cleaned up some and made dry-er.

sim/midas/src/main/cc/bridges/plusargs.h Outdated Show resolved Hide resolved
sim/midas/src/main/cc/bridges/plusargs.h Outdated Show resolved Hide resolved
sim/midas/src/main/cc/bridges/plusargs.cc Outdated Show resolved Hide resolved
sim/src/main/cc/midasexamples/PlusargsModule.h Outdated Show resolved Hide resolved
sim/src/test/scala/midasexamples/TutorialSuite.scala Outdated Show resolved Hide resolved
Copy link
Contributor

@davidbiancolin davidbiancolin left a comment

Choose a reason for hiding this comment

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

This is really shaping up!

Mostly just nits now

@@ -67,7 +74,7 @@ class SimUtilsSpec extends AnyFlatSpec {
portIntRef.copy(component = Seq(TargetToken.Field("bits")))
),
)
require(data.typeEquivalent(UInt(32.W)))
require(DataMirror.checkTypeEquivalence(data, UInt(32.W)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you have to change these? I feel like nandor got them already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed these by grabbing from nandor's commit directly because his commit was waiting to be merge to master. I could have waited and rebased instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want, I can rebase before we merge. However because I pulled the files exactly the squash merge should identify the files as same and not generate any conflicts

*/
class PlusArgsDUT(implicit val p: Parameters) extends Module {

def testGroup0(): PlusArgsBridgeParams = {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the future you could use an enum-like thing to capture more semantic information about each test in the type itself.

e.g.:


sealed trait PlusArgTest { def params: PlusArgsBridgeParams}
case object WidePlusArgTest extends PlusArgTest { def params = PlusArgsBridgeParams(name = "plusar_v=%d", default = BigInt("276783146634859761135"), width = 68)} 
...
case object PlusArgsTestTypeKey extends Field[PlusArgTest]

etc...

sim/src/main/scala/midasexamples/PlusArgsModule.scala Outdated Show resolved Hide resolved
Benjamin Morse and others added 2 commits November 17, 2022 02:03
Co-authored-by: David Biancolin <david.biancolin@sifive.com>
Copy link
Contributor

@davidbiancolin davidbiancolin left a comment

Choose a reason for hiding this comment

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

One final thing -- you probably want to add a few instantiations to firesim_top.cc

Otherwise ship it!

@sifive-benjamin-morse sifive-benjamin-morse merged commit 7aa7ee2 into main Nov 21, 2022
@sifive-benjamin-morse sifive-benjamin-morse deleted the bmorse/plusargs-squash branch November 21, 2022 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:added Put PR title in 'Added' section of changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants