Skip to content

Commit

Permalink
Split FireSim from Chipyard (and vice versa)
Browse files Browse the repository at this point in the history
  • Loading branch information
abejgonzalez committed Aug 19, 2024
1 parent 0f3498e commit 27da7c2
Show file tree
Hide file tree
Showing 105 changed files with 8,543 additions and 212 deletions.
2 changes: 0 additions & 2 deletions .github/scripts/defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ mapping["chipyard-shuttlevector"]=" CONFIG=GENV256D128ShuttleConfig"
mapping["chipyard-shuttleara"]=" CONFIG=V4096Ara2LaneShuttleConfig USE_ARA=1 verilog"

mapping["constellation"]=" SUB_PROJECT=constellation"
mapping["firesim"]="TARGET_CONFIG=WithNIC_DDR3FRFCFSLLC4MB_FireSimRocketConfig"
mapping["fireboom"]="TARGET_CONFIG=DDR3FRFCFSLLC4MB_FireSimLargeBoomConfig"
mapping["icenet"]="SUB_PROJECT=icenet"
mapping["testchipip"]="SUB_PROJECT=testchipip"
mapping["rocketchip-amba"]="SUB_PROJECT=rocketchip CONFIG=AMBAUnitTestConfig"
Expand Down
20 changes: 0 additions & 20 deletions .github/scripts/remote-run-firesim-scala-tests.sh

This file was deleted.

28 changes: 26 additions & 2 deletions .github/workflows/chipyard-full-flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ jobs:
source env.sh
cd sims/verilator
make verilog
- name: VLSI test
run: |
cd ${{ env.REMOTE_WORK_DIR }}
Expand Down Expand Up @@ -167,7 +166,32 @@ jobs:
# make redo-par HAMMER_EXTRA_ARGS="--start_before_step extraction"
# make drc
# make lvs
- name: Run FireChip bridge tests
run: |
cd ${{ env.REMOTE_WORK_DIR }}
eval "$(conda shell.bash hook)"
source env.sh
pushd sims/firesim
source sourceme-manager.sh --skip-ssh-setup
popd
cd sims/firesim-staging
ls -alh
ls -alh firesim-symlink
ls -alh firesim-symlink/.
export TEST_DISABLE_VERILATOR=1
export TEST_DISABLE_VIVADO=1
make launch-sbt SBT_COMMAND=";project firechip; testOnly firechip.test.core.bridges.BridgeTests"
- name: Run FireChip FireSim target tests
run: |
cd ${{ env.REMOTE_WORK_DIR }}
eval "$(conda shell.bash hook)"
source env.sh
pushd sims/firesim
source sourceme-manager.sh --skip-ssh-setup
popd
cd sims/firesim-staging
export TEST_MINIMAL_BENCHMARKS=1 # seems like dhrystone is the longest so this doesn't affect runtime much
make launch-sbt SBT_COMMAND=";project firechip; testOnly firechip.test.core.firesim.CITests"
cleanup:
name: cleanup
Expand Down
52 changes: 1 addition & 51 deletions .github/workflows/chipyard-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1170,55 +1170,6 @@ jobs:
group-key: "group-constellation"
project-key: "chipyard-constellation"


firesim-run-tests:
name: firesim-run-tests
needs: setup-complete
runs-on: as4
steps:
- name: Delete old checkout
run: |
ls -alh .
rm -rf ${{ github.workspace }}/* || true
rm -rf ${{ github.workspace }}/.* || true
ls -alh .
- name: Checkout
uses: actions/checkout@v4
- name: Git workaround
uses: ./.github/actions/git-workaround
- name: Create conda env
uses: ./.github/actions/create-conda-env
- name: Run tests on self-hosted
uses: ./.github/actions/run-tests
with:
group-key: "extra-tests"
project-key: "firesim"
run-script: "remote-run-firesim-scala-tests.sh"

fireboom-run-tests:
name: fireboom-run-tests
needs: setup-complete
runs-on: as4
steps:
- name: Delete old checkout
run: |
ls -alh .
rm -rf ${{ github.workspace }}/* || true
rm -rf ${{ github.workspace }}/.* || true
ls -alh .
- name: Checkout
uses: actions/checkout@v4
- name: Git workaround
uses: ./.github/actions/git-workaround
- name: Create conda env
uses: ./.github/actions/create-conda-env
- name: Run tests on self-hosted
uses: ./.github/actions/run-tests
with:
group-key: "extra-tests"
project-key: "fireboom"
run-script: "remote-run-firesim-scala-tests.sh"

# Sentinel job to simplify how we specify which checks need to pass in branch
# protection and in Mergify
#
Expand Down Expand Up @@ -1259,8 +1210,7 @@ jobs:
testchipip-run-tests,
rocketchip-run-tests,
constellation-run-tests,
prepare-chipyard-fpga, # firesim-run-tests,
fireboom-run-tests]
prepare-chipyard-fpga]
runs-on: ubuntu-latest
steps:
- run: echo Success!
106 changes: 61 additions & 45 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ lazy val commonSettings = Seq(

val rocketChipDir = file("generators/rocket-chip")

lazy val firesimAsLibrary = sys.env.get("FIRESIM_STANDALONE") == None
lazy val firesimDir = if (firesimAsLibrary) {
file("sims/firesim/sim/")
} else {
file("../../sim")
}

/**
* It has been a struggle for us to override settings in subprojects.
* An example would be adding a dependency to rocketchip on midas's targetutils library,
Expand Down Expand Up @@ -111,6 +104,12 @@ lazy val chiselSettings = (if (chisel6) chisel6Settings else chisel3Settings) ++
)
)

lazy val scalaTestSettings = Seq(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.+" % "test"
)
)


// Subproject definitions begin

Expand All @@ -119,19 +118,12 @@ lazy val chiselSettings = (if (chisel6) chisel6Settings else chisel3Settings) ++
lazy val hardfloat = freshProject("hardfloat", file("generators/hardfloat/hardfloat"))
.settings(chiselSettings)
.settings(commonSettings)
.dependsOn(if (chisel6) midasStandaloneTargetUtils else midasTargetUtils)
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.0" % "test"
)
)
.dependsOn(if (chisel6) midas_standalone_target_utils else midas_target_utils)
.settings(scalaTestSettings)

lazy val rocketMacros = (project in rocketChipDir / "macros")
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
)
)
.settings(scalaTestSettings)

lazy val diplomacy = freshProject("diplomacy", file("generators/diplomacy/diplomacy"))
.dependsOn(cde)
Expand All @@ -143,11 +135,11 @@ lazy val rocketchip = freshProject("rocketchip", rocketChipDir)
.dependsOn(hardfloat, rocketMacros, diplomacy, cde)
.settings(commonSettings)
.settings(chiselSettings)
.settings(scalaTestSettings)
.settings(
libraryDependencies ++= Seq(
"com.lihaoyi" %% "mainargs" % "0.5.0",
"org.json4s" %% "json4s-jackson" % "4.0.5",
"org.scalatest" %% "scalatest" % "3.2.0" % "test",
"org.scala-graph" %% "graph-core" % "1.13.5"
)
)
Expand All @@ -156,15 +148,6 @@ lazy val rocketLibDeps = (rocketchip / Keys.libraryDependencies)

// -- Chipyard-managed External Projects --

// Contains annotations & firrtl passes you may wish to use in rocket-chip without
// introducing a circular dependency between RC and MIDAS
lazy val midasTargetUtils = (project in file ("sims/firesim/sim/midas/targetutils"))
.settings(commonSettings)
.settings(chiselSettings)
lazy val midasStandaloneTargetUtils = (project in file("tools/midas-targetutils"))
.settings(commonSettings)
.settings(chiselSettings)

lazy val testchipip = (project in file("generators/testchipip"))
.dependsOn(rocketchip, rocketchip_blocks)
.settings(libraryDependencies ++= rocketLibDeps.value)
Expand Down Expand Up @@ -298,9 +281,9 @@ lazy val dsptools = freshProject("dsptools", file(dsptoolsDir))
.settings(
chiselSettings,
commonSettings,
scalaTestSettings,
libraryDependencies ++= Seq(
"edu.berkeley.cs" %% "chiseltest" % chiselTestVersion,
"org.scalatest" %% "scalatest" % "3.2.+" % "test",
"org.typelevel" %% "spire" % "0.18.0",
"org.scalanlp" %% "breeze" % "2.1.0",
"junit" % "junit" % "4.13" % "test",
Expand Down Expand Up @@ -328,32 +311,65 @@ lazy val rocketchip_inclusive_cache = (project in file("generators/rocket-chip-i
.dependsOn(rocketchip)
.settings(libraryDependencies ++= rocketLibDeps.value)

// Library components of FireSim
lazy val midas = (project in file ("sims/firesim/sim/midas"))
.dependsOn(rocketchip, midasTargetUtils)
.settings(libraryDependencies ++= Seq(
"org.scalatestplus" %% "scalacheck-1-14" % "3.1.3.0" % "test"))
lazy val fpga_shells = (project in file("./fpga/fpga-shells"))
.dependsOn(rocketchip, rocketchip_blocks)
.settings(libraryDependencies ++= rocketLibDeps.value)
.settings(commonSettings)

lazy val chipyard_fpga = (project in file("./fpga"))
.dependsOn(chipyard, fpga_shells)
.settings(commonSettings)

// Components of FireSim

lazy val firesimAsLibrary = sys.env.get("FIRESIM_STANDALONE") == None
lazy val firesimDir = if(firesimAsLibrary) {
file("sims/firesim")
} else {
file("sims/firesim-staging/firesim-symlink")
}

// TODO: AJG: Fix
// Contains annotations & firrtl passes you may wish to use in rocket-chip without
// introducing a circular dependency between RC and MIDAS
// this should be minimally dependent on firesim
lazy val midas_target_utils = (project in firesimDir / "sim/midas/targetutils")
.settings(commonSettings)
.settings(chiselSettings)

// compiles with chisel6 (only the APIs)
lazy val midas_standalone_target_utils = (project in file("tools/midas-targetutils"))
.settings(commonSettings)
.settings(chiselSettings)
// TODO: AJG: ^ Fix

lazy val firesimLib = (project in file("sims/firesim/sim/firesim-lib"))
.dependsOn(midas, icenet, testchipip, rocketchip_blocks)
// Provides API for bridges to be created in the target.
// Includes target-side of FireSim-provided bridges and their interfaces that are shared
// between FireSim and the target. Minimal in scope (should only depend on Chisel/Firrtl2)
lazy val firesim_lib = (project in firesimDir / "sim/firesim-lib")
.dependsOn(midas_target_utils)
.settings(commonSettings)
.settings(chiselSettings)
.settings(scalaTestSettings)

lazy val firechip = (project in file("generators/firechip"))
.dependsOn(chipyard, midasTargetUtils, midas, firesimLib % "test->test;compile->compile")
// Interfaces for target-specific bridges shared with FireSim.
// Minimal in scope (should only depend on Chisel/Firrtl2).
// This is copied to FireSim's midas compiler.
lazy val firechip_bridge_interfaces = (project in file("generators/firechip/bridge-interfaces"))
.settings(
chiselSettings,
commonSettings,
)

// FireSim top-level project.
// Includes, FireSim harness, target-specific bridges, etc.
// It's tests also depend on firesim_lib's test sources.
lazy val firechip = (project in file("generators/firechip/core"))
.dependsOn(chipyard, firesim_lib % "compile->compile;test->test", firechip_bridge_interfaces)
.settings(
chiselSettings,
commonSettings,
Test / testGrouping := isolateAllTests( (Test / definedTests).value ),
Test / testOptions += Tests.Argument("-oF")
)
lazy val fpga_shells = (project in file("./fpga/fpga-shells"))
.dependsOn(rocketchip, rocketchip_blocks)
.settings(libraryDependencies ++= rocketLibDeps.value)
.settings(commonSettings)

lazy val chipyard_fpga = (project in file("./fpga"))
.dependsOn(chipyard, fpga_shells)
.settings(commonSettings)
.settings(scalaTestSettings)
7 changes: 5 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ CHECK_SUBMODULES_COMMAND = echo "Checking all submodules in generators/ are init

SCALA_EXT = scala
VLOG_EXT = sv v
CHIPYARD_SOURCE_DIRS = $(addprefix $(base_dir)/,generators sims/firesim/sim/src sims/firesim/sim/firesim-lib sims/firesim/sim/midas fpga/fpga-shells fpga/src tools/stage tools/stage-chisel3)
FIRESIM_DIR = $(if $(FIRESIM_STANDALONE),sims/firesim-staging/firesim-symlink,sims/firesim)
FIRESIM_SOURCE_DIRS = $(addprefix $(FIRESIM_DIR)/,sim/firesim-lib sim/midas/targetutils) $(addprefix generators/firechip/,core bridge-interfaces)
CHIPYARD_SOURCE_DIRS = \
$(filter-out $(base_dir)/generators/firechip,$(wildcard $(addprefix $(base_dir)/,generators/* fpga/fpga-shells fpga/src tools/stage tools/stage-chisel3))) \
$(addprefix $(base_dir)/,$(FIRESIM_SOURCE_DIRS))
CHIPYARD_SCALA_SOURCES = $(call lookup_srcs_by_multiple_type,$(CHIPYARD_SOURCE_DIRS),$(SCALA_EXT))
CHIPYARD_VLOG_SOURCES = $(call lookup_srcs_by_multiple_type,$(CHIPYARD_SOURCE_DIRS),$(VLOG_EXT))
TAPEOUT_SOURCE_DIRS = $(addprefix $(base_dir)/,tools/tapeout)
Expand All @@ -97,7 +101,6 @@ TAPEOUT_VLOG_SOURCES = $(call lookup_srcs_by_multiple_type,$(TAPEOUT_SOURCE_DIRS
SBT_SOURCE_DIRS = $(addprefix $(base_dir)/,generators tools)
SBT_SOURCES = $(call lookup_srcs,$(SBT_SOURCE_DIRS),sbt) $(base_dir)/build.sbt $(base_dir)/project/plugins.sbt $(base_dir)/project/build.properties


#########################################################################################
# copy over bootrom files
#########################################################################################
Expand Down
13 changes: 5 additions & 8 deletions docs/Simulation/FPGA-Accelerated-Simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,24 @@ and proceed with the rest of the tutorial.
Running your Design in FireSim
------------------------------
Converting a Chipyard config (one in ``chipyard/src/main/scala`` to run in FireSim is simple, and can be done either through the traditional configuration system or through FireSim's build-recipes scheme.
Converting a Chipyard config (one in ``generators/chipyard/src/main/scala`` to run in FireSim is simple, and can be done either through the traditional configuration system or through FireSim's build-recipes scheme.
A FireSim simulation requires 3 additional config fragments:
A FireSim simulation requires 2 additional config fragments:
* ``WithFireSimConfigTweaks`` modifies your design to better fit the FireSim usage model. This is composed of multiple smaller config fragments. For example, the removal of clock-gating (using the ``WithoutClockGating`` config fragment) which is required for correct functioning of the compiler. This config fragment also includes other config fragments such as the inclusion of UART in the design, which although may technically be optional,is *strongly* recommended.
* ``WithDefaultMemModel`` provides a default configuration for FASED memory models in the FireSim simulation. See the FireSim documentation for details. This config fragment is currently included by default within ``WithFireSimConfigTweaks``, so it isn't neccessary to add in separately, but it is required if you choose not to use ``WithFireSimConfigTweaks``.
* ``WithDefaultFireSimBridges`` sets the ``IOBinders`` key to use FireSim's Bridge system, which can drive target IOs with software bridge models running on the simulation host. See the FireSim documentation for details.
The simplest method to add this config fragments to your custom Chipyard config is through FireSim's build recipe scheme.
After your FireSim environment is setup, you will define your custom build recipe in ``sims/firesim/deploy/config_build_recipes.yaml``. By prepending the FireSim config fragments (separated by ``_``) to your Chipyard configuration, these config fragments will be added to your custom configuration as if they were listed in a custom Chisel config class definition. For example, if you would like to convert the Chipyard ``LargeBoomV3Config`` to a FireSim simulation with a DDR3 memory model, the appropriate FireSim ``TARGET_CONFIG`` would be ``DDR3FRFCFSLLC4MB_WithDefaultFireSimBridges_WithFireSimConfigTweaks_chipyard.LargeBoomV3Config``. Note that the FireSim config fragments are part of the ``firesim.firesim`` scala package and therefore there do not need to be prefixed with the full package name as opposed to the Chipyard config fragments which need to be prefixed with the chipyard package name.
An alternative method to prepending the FireSim config fragments in the FireSim build recipe is to create a new "permanent" FireChip custom configuration, which includes the FireSim config fragments.
We are using the same target (top) RTL, and only need to specify a new set of connection behaviors for the IOs of that module. Simply create a matching config within ``generators/firechip/src/main/scala/TargetConfigs`` that inherits your config defined in ``chipyard``.
We are using the same target (top) RTL, and only need to specify a new set of connection behaviors for the IOs of that module. Simply create a matching config within ``generators/firechip/core/src/main/scala/firesim/TargetConfigs.scala`` that inherits your config defined in ``chipyard``.
.. literalinclude:: ../../generators/firechip/src/main/scala/TargetConfigs.scala
.. literalinclude:: ../../generators/firechip/core/src/main/scala/firesim/TargetConfigs.scala
:language: scala
:start-after: DOC include start: firesimconfig
:end-before: DOC include end: firesimconfig
While this option seems to require the maintenance of additional configuration code, it has the benefit of allowing for the inclusion of more complex config fragments which also accept custom arguments (for example, ``WithDefaultMemModel`` can take an optional argument``)
While this option seems to require the maintenance of additional configuration code, it has the benefit of allowing for the inclusion of more complex config fragments which also accept custom arguments.
For more information on how to build your own hardware design on FireSim, please refer to :fsim_doc:`FireSim Docs <Getting-Started-Guides/AWS-EC2-F1-Getting-Started/Building-a-FireSim-AFI.html#building-your-own-hardware-designs-firesim-amazon-fpga-images>`.
Empty file.
Loading

0 comments on commit 27da7c2

Please sign in to comment.