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

Commit

Permalink
Merge branch '0.5.x' into 0.5-release
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkoenig committed Jan 8, 2023
2 parents 06776e7 + 0e81af7 commit 0987d9a
Show file tree
Hide file tree
Showing 10 changed files with 420 additions and 177 deletions.
100 changes: 33 additions & 67 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
push:
branches:
- master
- main
- 0.5.x
- 0.3.x

Expand All @@ -14,15 +14,17 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
scala: [2.12.15, 2.13.7]
jvm: [adopt@1.8, adopt@1.11]
scala: [2.12.17, 2.13.10]
jvm: [8, 11]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Scala
uses: olafurpg/setup-scala@v10
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: ${{ matrix.jvm }}
cache: 'sbt'
- name: Test
run: sbt ++${{ matrix.scala }} "testOnly -- -l RequiresVcs -l RequiresVerilator -l Formal -l RequiresIcarus"

Expand All @@ -31,11 +33,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Scala
uses: olafurpg/setup-scala@v10
with:
java-version: [email protected]
uses: actions/checkout@v3
- name: Test
run: sbt "testOnly -- -l RequiresVcs -l RequiresVerilator -l Formal -l RequiresIcarus"

Expand All @@ -47,7 +45,7 @@ jobs:
os: [ ubuntu-20.04, macos-latest ]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Icarus Verilog for Ubuntu
if: runner.os == 'Linux'
run: |
Expand All @@ -58,32 +56,9 @@ jobs:
run: |
brew install icarus-verilog
iverilog -v || true
- name: Setup Scala
uses: olafurpg/setup-scala@v10
with:
java-version: [email protected]
- name: Test
run: sbt ++${{ matrix.scala }} "testOnly -- -n RequiresIcarus"

verilator-mac:
name: verilator regression on mac
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Tabby OSS Cad Suite (from YosysHQ)
uses: YosysHQ/setup-oss-cad-suite@v1
with:
osscadsuite-version: '2021-11-09'
- name: Print Verilator Version
run: verilator --version
- name: Setup Scala
uses: olafurpg/setup-scala@v10
with:
java-version: [email protected]
- name: Test
run: sbt "testOnly -- -n RequiresVerilator"

verilator:
name: verilator regressions
runs-on: ubuntu-20.04
Expand All @@ -100,11 +75,11 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Verilator Build Dependencies
run: sudo apt-get install -y git make autoconf g++ flex bison libfl2 libfl-dev
- name: Cache Verilator ${{ matrix.version }}
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-verilator
with:
path: verilator-${{ matrix.version }}
Expand All @@ -123,57 +98,50 @@ jobs:
cd verilator-${{ matrix.version }}
sudo make install
verilator --version
- name: Setup Scala
uses: olafurpg/setup-scala@v10
with:
java-version: [email protected]
- name: Test
run: sbt "testOnly -- -n RequiresVerilator"

formal:
name: formal verification tests
runs-on: ${{ matrix.os }}
runs-on: ubuntu-20.04
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
backend: [z3, cvc4, btormc]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Z3 and CVC4 for Ubuntu
uses: actions/checkout@v3
- name: Install Z3 and CVC4
if: runner.os == 'Linux'
run: |
sudo apt-get install -y z3 cvc4
z3 --version
cvc4 --version
- name: Install Z3 and CVC4 for MacOS
if: runner.os == 'macOS'
run: |
brew install z3
brew tap cvc4/cvc4
brew install cvc4/cvc4/cvc4
z3 --version
cvc4 --version
- name: Install Tabby OSS Cad Suite (from YosysHQ)
if: matrix.backend == 'btormc'
uses: YosysHQ/setup-oss-cad-suite@v1
with:
osscadsuite-version: '2021-11-09'
- name: Setup Scala
uses: olafurpg/setup-scala@v10
with:
java-version: [email protected]
osscadsuite-version: '2022-08-18'
- name: Test
run: sbt "testOnly -- -n Formal -Dformal_engine=${{ matrix.backend }}"

formal-mac:
name: formal verification tests on mac
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Z3 for MacOS
run: |
brew install z3
z3 --version
- name: Test
run: sbt "testOnly -- -n Formal -Dformal_engine=z3"

doc:
name: Documentation and Formatting
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Scala
uses: olafurpg/setup-scala@v10
uses: actions/checkout@v3
- name: Documentation
id: doc
run: sbt doc
Expand All @@ -186,7 +154,7 @@ jobs:
# When adding new jobs, please add them to `needs` below
all_tests_passed:
name: "all tests passed"
needs: [test, doc, verilator, verilator-mac, formal, icarus, test-mac]
needs: [test, doc, verilator, formal, formal-mac, icarus, test-mac]
runs-on: ubuntu-latest
steps:
- run: echo Success!
Expand All @@ -200,11 +168,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Scala
uses: olafurpg/setup-scala@v10
with:
java-version: [email protected]
uses: actions/checkout@v3
- name: Setup GPG (for Publish)
uses: olafurpg/setup-gpg@v3
- name: Publish
Expand All @@ -214,3 +178,5 @@ jobs:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}


4 changes: 2 additions & 2 deletions src/main/resources/simulator/vpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class vpi_api_t: public sim_api_t<vpiHandle> {
vpiHandle syscall_handle = vpi_handle(vpiSysTfCall, NULL);
vpiHandle arg_iter = vpi_iterate(vpiArgument, syscall_handle);
// Cache Inputs
if(arg_iter != nullptr) {
if(arg_iter != NULL) {
while (vpiHandle arg_handle = vpi_scan(arg_iter)) {
sim_data.inputs.push_back(arg_handle);
}
Expand All @@ -43,7 +43,7 @@ class vpi_api_t: public sim_api_t<vpiHandle> {
vpiHandle syscall_handle = vpi_handle(vpiSysTfCall, NULL);
vpiHandle arg_iter = vpi_iterate(vpiArgument, syscall_handle);
// Cache Outputs
if(arg_iter != nullptr) {
if(arg_iter != NULL) {
while (vpiHandle arg_handle = vpi_scan(arg_iter)) {
sim_data.outputs.push_back(arg_handle);
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/scala/chiseltest/exceptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ class StopException(message: String) extends Exception(message)

/** Indicates that a Chisel `assert(...)` or `assume(...)` statement has failed. */
class ChiselAssertionError(message: String) extends Exception(message)

/** Indicates that a value used in a poke/expect is not a literal.
* It could be hardware or a DontCare which is only allowed when using pokePartial/expectPartial.
*/
class NonLiteralValueError(val value: chisel3.Data, val signal: chisel3.Data, op: String)
extends Exception(
s"""Value $value for entry $signal is not a literal value!
|You need to fully specify all fields/entries when using $op.
|Maybe try using `${op}Partial` if you only want to use incomplete Vec/Bundle literals.
|""".stripMargin
)
12 changes: 10 additions & 2 deletions src/main/scala/chiseltest/internal/GenericBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import chiseltest.coverage.TestCoverage
import chiseltest.simulator.{SimulatorContext, StepInterrupted, StepOk}
import firrtl.AnnotationSeq

import chiseltest.simulator.ipc.TestApplicationException

import scala.collection.mutable

/** Chiseltest threaded backend using the generic SimulatorContext abstraction from [[chiseltest.simulator]] */
Expand Down Expand Up @@ -202,8 +204,14 @@ class GenericBackend[T <: Module](
thread.thread.interrupt()
}
}

tester.finish() // needed to dump VCDs + terminate any external process
try {
tester.finish() // needed to dump VCDs + terminate any external process
} catch {
case e: TestApplicationException =>
throw new ChiselAssertionError(
s"Simulator exited sooner than expected. See logs for more information about what is assumed to be a Chisel Assertion which failed."
)
}
}
if (tester.sim.supportsCoverage) {
generateTestCoverageAnnotation() +: coverageAnnotations
Expand Down
10 changes: 6 additions & 4 deletions src/main/scala/chiseltest/internal/TestEnvInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ trait TestEnvInterface {
def signalExpectFailure(message: String): Unit = {
val trace = new Throwable
val expectStackDepth = trace.getStackTrace.indexWhere(ste =>
ste.getClassName.startsWith("chiseltest.package$") && ste.getMethodName == "expect"
ste.getClassName.startsWith(
"chiseltest.package$"
) && (ste.getMethodName == "expect" || ste.getMethodName == "expectPartial")
)
require(
expectStackDepth != -1,
s"Failed to find expect in stack trace:\r\n${trace.getStackTrace.mkString("\r\n")}"
)

val trimmedTrace = trace.getStackTrace.drop(expectStackDepth + 2)
val detailedTrace = topFileName.map(getExpectDetailedTrace(trimmedTrace.toSeq, _)).getOrElse("")
val trimmedTrace = trace.getStackTrace.drop(expectStackDepth)
val failureLocation: String = topFileName.map(getExpectDetailedTrace(trimmedTrace.toSeq, _)).getOrElse("")
val stackIndex = expectStackDepth + 1
batchedFailures += new FailedExpectException(message + detailedTrace, stackIndex)
batchedFailures += new FailedExpectException(message + failureLocation, stackIndex)
}

/** If there are any failures, reports them and end the test now.
Expand Down
Loading

0 comments on commit 0987d9a

Please sign in to comment.