-
Notifications
You must be signed in to change notification settings - Fork 678
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1379a82
commit 628f47f
Showing
5 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
First Verilog Build | ||
=================== | ||
|
||
This tutorial guides you through setting up Chipyard for the first time and building Verilog (specifically a Rocket core SoC). | ||
|
||
.. code-block:: shell | ||
cd $CHIPYARD_DIR | ||
.. only:: replace-code-above | ||
|
||
cd $CHIPYARD_DIR | ||
export MAKEFLAGS="-j32" | ||
|
||
.. code-block:: shell | ||
./build-setup.sh | ||
.. only:: replace-code-above | ||
|
||
./build-setup.sh -f -v | ||
|
||
.. code-block:: shell | ||
source env.sh | ||
.. code-block:: shell | ||
cd sims/verilator | ||
make verilog | ||
.. code-block:: shell | ||
make | ||
.. code-block:: shell | ||
ls -alh generated-src | ||
ls -alh simulator* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Tutorials | ||
================ | ||
|
||
This section holds various tutorials for specific features, workflows, and more within Chipyard. | ||
Each requires you to checkout the Chipyard repo and set the ``CHIPYARD_DIR`` environment variable before continuing on. | ||
|
||
.. Warning:: Tutorials are only guaranteed to work on released versions of Chipyard. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Tutorials: | ||
|
||
First-Verilog-Build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ Table of Contents | |
|
||
Prototyping/index | ||
|
||
Tutorials/index | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
# $1 - rst file to parse | ||
# $2 - output bash file to write | ||
|
||
if len(sys.argv) != 3: | ||
sys.exit("[ERROR] Incorrect # of args.") | ||
|
||
rstFile = sys.argv[1] | ||
bashFile = sys.argv[2] | ||
|
||
codeBlocks = [] # ordered list of blocks, each block is (type: String, lines: List[Strings]) | ||
|
||
with open(rstFile, 'r') as rstF: | ||
inBlock = False | ||
skipEmpty = False | ||
curBlockType = "" | ||
curBlockLines = [] | ||
for line in rstF.readlines(): | ||
if inBlock: | ||
if len(line) == 1 and line == '\n': | ||
# empty line | ||
if not skipEmpty: | ||
# empty line (done with block) | ||
inBlock = False | ||
codeBlocks.append((curBlockType, curBlockLines)) | ||
curBlockType = "" | ||
curBlockLines = [] | ||
skipEmpty = False | ||
else: | ||
assert (line[0:4] == ' ' * 4), "Must only strip whitespace (ensure RST only has 4 spaces before code lines)" | ||
curBlockLines.append(line[4:]) # strip the first 4 spaces (indent) | ||
else: | ||
if ".. code-block:: shell" in line: | ||
inBlock = True | ||
curBlockType = "code-block" | ||
skipEmpty = True | ||
elif ".. only:: replace-code-above" in line: | ||
inBlock = True | ||
curBlockType = "replace-above" | ||
skipEmpty = True | ||
|
||
idxToDelete = [] | ||
for idx, cb in enumerate(codeBlocks): | ||
if cb[0] == "replace-above": | ||
idxToDelete.append(idx) | ||
|
||
# TODO: could check that replace-code-above directives cannot follow one another | ||
|
||
idxToDelete.reverse() | ||
for idx in idxToDelete: | ||
assert idx - 1 >= 0, "replace-code-above directives must come after a code-block directive" | ||
codeBlocks.pop(idx - 1) | ||
|
||
with open(bashFile, 'w') as bashF: | ||
header = """#!/usr/bin/env bash | ||
# exit script if any command fails | ||
set -e | ||
set -o pipefail | ||
# $CHIPYARD_DIR should be defined and pointing to the top-level folder in Chipyard | ||
if [[ -z "${CHIPYARD_DIR}" ]]; then | ||
echo "Environment variable \$CHIPYARD_DIR is undefined. Unable to run script." | ||
exit 1 | ||
fi | ||
""" | ||
bashF.writelines([header, '\n']) | ||
for cb in codeBlocks: | ||
bashF.writelines(cb[1]) |