Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge branch '1.2.x' into 1.2-release
Browse files Browse the repository at this point in the history
  • Loading branch information
ucbjrl committed Apr 29, 2020
2 parents a24b7dc + f89bf7e commit 35a0e88
Show file tree
Hide file tree
Showing 24 changed files with 429 additions and 102 deletions.
66 changes: 66 additions & 0 deletions .github/scripts/ExtractBuildDependenciesFromPullRequest.gawk
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/^[[:space:]]*"body": / {
# Convert character sequences to character constants
gsub(/\\r/, "")
gsub(/\\n/, "\n")
# Remove trailing punctuation
gsub(/\n*",$/, "")
# Look for the build dependency tag
i=split($0, a, /### Build Dependencies/)
if ( i != 2 ) {
print "no build dependencies"
exit 0
}
# Throw away everything up to the build dependency tag
$0=a[2]
# Grab the specific build dependencies
i=split($0,a,/\nBuild with: /)
delete a[1]
# Format the individual dependencies
errLines = 0
depLines = 0
for (i in a) {
# Remove trailing text
gsub(/\n.*$/, "", a[i])
n=split(a[i], d, /\s+/)
switch (d[1]) {
case /maven-version/ :
if (n != 3) {
err[errLines++]="unrecognized maven-version stanza: " a[i] "(" n ")"
}
break

case /git-clone/ :
if (n != 4) {
err[errLines++]="unrecognized git-clone stanza: " a[i] "(" n ")"
}
break

default:
err[errLines++]="unrecognized build type: " d[1] " - " a[i]
break

}
# If we don't have any errors, format this dependency line and add it
# to the list of dependency lines.
if (errLines == 0) {
sep=""
line=""
for (n in d) {
line=line sep d[n]
sep=" "
}
dep[depLines++]=line
}
}
# Print either errors (to stderr) or the dependency lines (to stdout)
if (errLines == 0) {
for (n in dep) {
print dep[n]
}
} else {
for (n in err) {
print err[n] > "/dev/stderr"
}
exit 1
}
}
29 changes: 29 additions & 0 deletions .github/scripts/generateGitClones.gawk
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generate commands to:
# - clone, build, and publish dependencies, (on stdout)
# - fetch corresponding shas ( on fd 3)
# Specify "-v verbose=1" on the command line for verbose output (to stderr)
/#/ {
# Strip comments
gsub(/#.*$/,"")
}
/git-clone/ {
project=$2
repo=$3
tag=$4
if (verbose) {
print "writing clone and build commands to stdout." > "/dev/stderr"
}
# Generate commands to do a shallow fetch of all branches, checkout the desired ref/sha, and build and publish the jars.
printf "git clone --no-single-branch --no-checkout --depth 5 %s %s && (cd %s && git checkout %s && sbt +publishLocal)\n",repo,project,project,tag
# If the tag looks like a SHA, assume it is and generate a command to just echo it,
# otherwise, generate a string to fetch the sha from the remote.
# In either case, write the output to fd 3.
if (verbose) {
print "writing sha generation commands to fd 3." > "/dev/stderr"
}
if ( tag ~ /^[[:xdigit:]]+$/ ) {
printf "echo %s\n", tag > "/dev/fd/3"
} else {
printf "git ls-remote --tags --heads %s %s", repo, tag > "/dev/fd/3"
}
}
21 changes: 21 additions & 0 deletions .github/scripts/generateVersionOverrides.gawk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generate suitable definitions for sbt to override default dependency
# specifications in the associated build.sbt, assuming the latter has
# been structured to support this. It should contain something like:
#
# // Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
# val defaultVersions = Seq(
# "chisel3" -> "3.3-SNAPSHOT",
# "treadle" -> "1.2-SNAPSHOT"
# )
#
# libraryDependencies ++= defaultVersions.map { case (dep, ver) =>
# "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", ver) }

/#/ {
# Strip comments
gsub(/#.*$/,"")
}
/maven-version/ {
# Print a series of "-DfooVersion=xxx" to override the default chisel versions in build.sbt
printf "%s-D%sVersion=%s", sep, $2, $3; sep = " "
}
106 changes: 106 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Test

on: [pull_request]

jobs:
build:
name: ci
runs-on: ubuntu-latest
container:
image: ucbbar/chisel3-tools
options: --user github --entrypoint /bin/bash
env:
CHISEL3_REF: master
FIRRTL_REF: master
FIRRTL_INTERPRETER_REF: master
TREADLE_REF: master
CONTAINER_HOME: /home/github

steps:
- name: id
id: id
run: |
uid=$(id -u)
echo ::set-env name=CONTAINER_HOME::$(if [ "$uid" = "0" ]; then echo "/root"; else echo "/home/github"; fi)
printenv
whoami
git --version
pwd
# Currently, sbt seems to either ignore (or doesn't see) $HOME inside the container,
# and insists on using /home/<user> (i.e., /home/github).
# Set up symbolic links so /home/gitsub/.{sbt,cache} (inside the container) are links to
# the equivalent directories in $HOME (i.e, /github/home)
- name: link-caches
id: link-caches
run: |
echo "Link $CONTAINER_HOME caches to $HOME"
echo mkdir -p $HOME/.cache $HOME/.ivy2 $HOME/.sbt
mkdir -p $HOME/.cache $HOME/.ivy2 $HOME/.sbt
echo ln -s $HOME/.cache $HOME/.ivy2 $HOME/.sbt $CONTAINER_HOME
ln -s $HOME/.cache $HOME/.ivy2 $HOME/.sbt $CONTAINER_HOME
echo ls -la $HOME . $CONTAINER_HOME
ls -la $HOME . $CONTAINER_HOME
- name: checkout
uses: actions/checkout@v2
with:
path: repo
- name: cache-sbt
uses: actions/cache@v1
env:
cache-name: cache-sbt
with:
path: ~/.sbt
key: build-${{ env.cache-name }}-v1
restore-keys: |
build-${{ env.cache-name }}-
- name: cache-coursier
uses: actions/cache@v1
env:
cache-name: cache-coursier
with:
path: ~/.cache
key: build-${{ env.cache-name }}-v1
restore-keys: |
build-${{ env.cache-name }}-
- name: list
id: list
run: |
echo ls -la . repo ~/.sbt ~/.cache /home/github /home/github/.??*
ls -la . repo ~/.sbt ~/.cache /home/github /home/github/.??*
- name: env
id: env
run: |
echo "cat $GITHUB_EVENT_PATH"
cat $GITHUB_EVENT_PATH
- name: gawk
id: gawk
run: |
gawk -f repo/.github/scripts/ExtractBuildDependenciesFromPullRequest.gawk $GITHUB_EVENT_PATH > deps
ls -l deps
cat deps
gawk -f repo/.github/scripts/generateGitClones.gawk deps > clones.sh 3> shas.sh
cat shas.sh
bash shas.sh > shas
- name: cache-dependencies
id: cache-dependencies
uses: actions/cache@v1
env:
cache-name: cache-dependencies
with:
path: ~/.ivy2/local
key: build-${{ env.cache-name }}-v1-${{ hashFiles('shas') }}
- name: clone-deps
id: clone-deps
run: |
cat clones.sh
bash clones.sh
if: steps.cache-dependencies.outputs.cache-hit != 'true'
- name: version-deps
id: version-deps
run: |
versionDeps=$(gawk -f repo/.github/scripts/generateVersionOverrides.gawk deps)
echo "versonDeps: $versionDeps"
- name: test
id: test
run: cat /dev/null | sbt $versionDeps +test
working-directory: ./repo
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Treadle -- A Chisel/Firrtl Execution Engine
==================

---

[![Join the chat at https://gitter.im/freechipsproject/firrtl](https://badges.gitter.im/freechipsproject/firrtl.svg)](https://gitter.im/freechipsproject/firrtl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Test](https://github.com/freechipsproject/treadle/workflows/Test/badge.svg)

**Treadle** is an experimental circuit simulator that executes low Firrtl IR.
It is based on earlier work on the [firrtl_interpreter](https://github.com/freechipsproject/firrtl-interpreter)
It will be one of the standard back-ends available as part of
Expand Down
8 changes: 7 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,20 @@ publishTo := {
//
scalacOptions in Compile ++= Seq(
"-deprecation",
"-unchecked"
"-unchecked",
"-language:reflectiveCalls",
"-language:existentials",
"-language:implicitConversions",
"-Ywarn-unused-import" // required by `RemoveUnused` rule
)

//
// This is for doc building
//
scalacOptions in Compile in doc ++= Seq(
"-deprecation",
"-Xfatal-warnings",
"-feature",
"-diagrams",
"-diagrams-max-classes", "25",
"-doc-version", version.value,
Expand Down
4 changes: 3 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ trait CommonModule extends CrossUnRootedSbtModule with PublishModule {
override def scalacOptions = Seq(
"-deprecation",
"-explaintypes",
"-feature", "-language:reflectiveCalls",
"-Xfatal-warnings",
"-feature",
"-language:reflectiveCalls",
"-unchecked",
"-Xcheckinit",
"-Xlint:infer-any",
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/treadle/ScalaBlackBox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package treadle

import firrtl.ir.{Param, Type}
import treadle.executable.{DataStore, Symbol, Transition}
import treadle.executable.Transition

import scala.collection._

Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/treadle/TreadleOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ object TreadleFirrtlFormHint extends HasShellOptions {
case class TreadleTesterAnnotation(tester: TreadleTester) extends NoTargetAnnotation with TreadleOption

/**
* Factory for [[FirrtlSourceAnnotation]], this is an alias for FirrtlCli
* Factory for FirrtlSourceAnnotation, this is an alias for FirrtlCli
*/
object TreadleFirrtlString extends HasShellOptions {
val options: Seq[ShellOption[_]] = Seq(
Expand All @@ -296,7 +296,7 @@ object TreadleFirrtlString extends HasShellOptions {
}

/**
* Factory for [[FirrtlFileAnnotation]] annotation, this is an alias for Firrtl Cli
* Factory for FirrtlFileAnnotation annotation, this is an alias for Firrtl Cli
*/
object TreadleFirrtlFile extends HasShellOptions {
val options: Seq[ShellOption[_]] = Seq(
Expand All @@ -315,7 +315,7 @@ case class BlackBoxFactoriesAnnotation(blackBoxFactories: Seq[ScalaBlackBoxFacto

/**
* Using this annotation allows external users of a TreadleTester to supply their own custom
* [[DataStorePlugin]]s. See that code for examples of use.
* [[treadle.executable.DataStorePlugin]]s. See that code for examples of use.
*
* @note this annotation cannot be generated from the command line
* @param name A unique name for this plugin
Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/treadle/TreadleTester.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ package treadle
import java.io.PrintWriter
import java.util.Calendar

import firrtl.{AnnotationSeq, ChirrtlForm, CircuitForm}
import firrtl.options.StageOptions
import firrtl.options.Viewer.view
import firrtl.stage.{FirrtlSourceAnnotation, OutputFileAnnotation}
import firrtl.{AnnotationSeq, ChirrtlForm, CircuitForm}
import treadle.chronometry.UTC
import treadle.executable._
import treadle.stage.{TreadleCompatibilityPhase, TreadleTesterPhase}
import treadle.vcd.VCD

//TODO: Indirect assignments to external modules input is possibly not handled correctly
//TODO: Force values should work with multi-slot symbols
Expand Down Expand Up @@ -117,7 +116,7 @@ class TreadleTester(annotationSeq: AnnotationSeq) {
}

/**
* Advance time in ticks of the [[UTC]] wallTime, the default is picoseconds, but can be
* Advance time in ticks of the [[treadle.chronometry.UTC]] wallTime, the default is picoseconds, but can be
* read by the scaleName of the wallTime. One should probably be advancing by some simple factor
* of a clock period. The clockInfoList of the options should define this (could be more than one).
* @param interval units are in units of the [[wallTime]] scale.
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/treadle/executable/DataStorePlugIn.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ limitations under the License.

package treadle.executable

import firrtl.annotations.NoTargetAnnotation
import firrtl.options.Unserializable
import treadle.vcd.VCD

import scala.collection.mutable

abstract class DataStorePlugin {
Expand Down
Loading

0 comments on commit 35a0e88

Please sign in to comment.