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

Add explanation for Class and Object, with examples. #3880

Merged
merged 4 commits into from
Feb 29, 2024

Conversation

mikeurbach
Copy link
Contributor

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • Documentation or website-related

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference).

Release Notes

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
    • Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

@mikeurbach mikeurbach added the Documentation Only changing documentation label Feb 27, 2024
@mikeurbach mikeurbach added this to the 6.x milestone Feb 27, 2024
@mikeurbach mikeurbach force-pushed the mikeurbach/class-object-explanation branch from 007f5f1 to e05c0b9 Compare February 27, 2024 20:42
Copy link
Contributor

@tymcauley tymcauley left a comment

Choose a reason for hiding this comment

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

Thanks so much for putting together this documentation! It's really great to see how some of these new features are intended to be used.

docs/src/explanations/properties.md Outdated Show resolved Hide resolved
Comment on lines +200 to +204
val identifier = IO(Output(Property[String]()))
// An output Property describing the CSR.
val description = IO(Output(Property[String]()))
// An output Property indicating the CSR width.
val width = IO(Output(Property[Int]()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be annotated with @public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, maybe they should. Nothing in the example accesses them at Chisel time, but they'd need to be @public if so.

Copy link
Contributor

Choose a reason for hiding this comment

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

is it important to show the @INSTANTIABLE and @public in this simple example...? It seems to be mixing concepts. The important thing here is that it is an IO(Output(Property...)), right?

Maybe the @instantiable/@public could be a follow-on example that says this stuff works with D/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.

Yeah, there is a tension here between the simplest example, and making something that is safe. We have safe and unsafe APIs for creating objects. The unsafe API is useful if you don't know the fields a-priori, like if you're generating the classes/objects from some other data structure. The safe API is literally just Instance, and we declare some helper methods on Instance[T <: Class] using an implicit class. I wanted the first example to show the safe APIs, but that does mean we need @public on at least the input ports to be able to connect to them on the Instance.

Co-authored-by: Tynan McAuley <tynan@niobiummicrosystems.com>
Copy link
Member

@sequencer sequencer left a comment

Choose a reason for hiding this comment

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

Thanks for the clear documentation. LGTM, I'll propose a end-to-end demonstration recently.

docs/src/explanations/properties.md Show resolved Hide resolved
docs/src/explanations/properties.md Show resolved Hide resolved

To understand the `Object` graph that is constructed, we will consider an
entrypoint to elaboration, and then show a hypothetical JSON representation of
the `Object` graph. The details of how we go from IR to an `Object` graph are
Copy link
Member

Choose a reason for hiding this comment

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

Currently, we don't have the API to get the hypothetical JSON representation. we can demo it in the panamaom framework.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that would be great. I will update the wording here slightly, since panamaom isn't an "external tool". Maybe we can add an example in this section of the doc showing a concrete use of panamaom with this IR. It could traverse the descriptions and print something out, so we could show the code snippet and the expected output, or something like that.

@mikeurbach mikeurbach enabled auto-merge (squash) February 29, 2024 16:55
Copy link
Member

@sequencer sequencer left a comment

Choose a reason for hiding this comment

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

Thanks for @mikeurbach's work! Ask @SpriteOvO to copy&paste the examples to scala-cli test, so we can use the binding framework testing it.

@mikeurbach mikeurbach merged commit 036dd5e into main Feb 29, 2024
13 checks passed
@mikeurbach mikeurbach deleted the mikeurbach/class-object-explanation branch February 29, 2024 17:09
@mergify mergify bot added the Backported This PR has been backported label Feb 29, 2024
mergify bot pushed a commit that referenced this pull request Feb 29, 2024
chiselbot pushed a commit that referenced this pull request Feb 29, 2024
(cherry picked from commit 036dd5e)

Co-authored-by: Mike Urbach <mike.urbach@sifive.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported This PR has been backported Documentation Only changing documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants