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 firrtl tutorial #27

Merged
merged 2 commits into from Aug 27, 2018
Merged

Add firrtl tutorial #27

merged 2 commits into from Aug 27, 2018

Conversation

azidar
Copy link
Member

@azidar azidar commented May 8, 2018

Goes through the AST, how to traverse it, common pass idioms, and a simple Transform. Also bumps the version of Chisel and company.

@azidar azidar requested a review from grebe May 8, 2018 22:08
Copy link
Contributor

@grebe grebe 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 awesome! Overall, things look good to me and I don't have a problem with merging it. I made some small comments and cleaned up some typos.

Some higher level thoughts:

  1. It would be good to connect this to Chisel more, even without having annotations. Something where you run a test on a transformed design would be good.
  2. It might be good to mention your vim syntax highlighting for firrtl
  3. I think we should talk a bit about reading serialized firrtl. Do we ever talk about source locators? GEN* and how they come to be?

"cell_type": "markdown",
"metadata": {},
"source": [
"This is the internal datastructure that holds the FIRRTL AST. It is a tree structure whose root node is **Circuit**, which has 3 children: **@[file.fir@2.0]**, **ArrayBuffer**, and **cmd5WrapperHelperDelayBy2**. The following is the definition of `Circuit`'s actual Scala class that was serialized:<a name=\"circuit\"></a><img src=\"images/circuit.png\" alt=\"Circuit case class\" />\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this should be done in a markdown code block.

"collapsed": true
},
"source": [
"# FIRRTL Node Descriptions\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should also use colors for these headings?

" }\n",
"```\n",
"\n",
"While the traversal ordering is different between these two examples, it makes no difference for this use case (and many others). However, it is an important tool to keep in your back pocket for when the traversal ordering matters."
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever do in-order?

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've never had a need for it.

"We first need to traverse the AST to every Statement and Expression. Then, when we see a DoPrim, we need to add a new DefNode to the module's body and insert a reference to that DefNode in place of the DoPrim. The code below implements this (and preserves the Info token). Note that `Namespace` is a utility function located in (Namespace.scala)[https://github.com/ucb-bar/firrtl/blob/master/src/main/scala/firrtl/Namespace.scala].\n",
"\n",
"```scala\n",
"object Splitter extends Pass {\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want these to be in code blocks?

@azidar azidar merged commit f85e628 into master Aug 27, 2018
@grebe grebe deleted the firrtl branch February 18, 2019 22:29
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.

None yet

2 participants