Skip to content

Commit

Permalink
[binder] Fix outputs of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO committed Sep 3, 2024
1 parent 4f07cea commit 341e87a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 86 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,19 @@ jobs:
with:
version: ${{ steps.circt-version.outputs.version }}
github-token: ${{ github.token }}
- name: Set CIRCT Path Env
run: echo "CIRCT_INSTALL_PATH=$(pwd)/circt" >> $GITHUB_ENV
- name: Install Lit
run: pip install lit
- name: Compile Mill
run: ./mill __.compile
- name: Setup Scala-cli
run: |
export CIRCT_INSTALL_PATH="$(pwd)/circt"
./mill __.compile
curl -fL https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux.gz | gzip -d > scala-cli
chmod +x scala-cli
sudo mv scala-cli /usr/local/bin/scala-cli
- name: Run Lit Tests
run: ./mill -i lit[${{ inputs.scala }}].run

doc:
name: Formatting
Expand Down
92 changes: 13 additions & 79 deletions lit/tests/Converter/Module.sc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: scala-cli --server=false --java-home=%JAVAHOME --extra-jars=%RUNCLASSPATH --scala-version=%SCALAVERSION --scala-option="-Xplugin:%SCALAPLUGINJARS" --java-opt="--enable-native-access=ALL-UNNAMED" --java-opt="--enable-preview" --java-opt="-Djava.library.path=%JAVALIBRARYPATH" %s | FileCheck %s -check-prefix=FIRRTL
// RUN: scala-cli --server=false --java-home=%JAVAHOME --extra-jars=%RUNCLASSPATH --scala-version=%SCALAVERSION --scala-option="-Xplugin:%SCALAPLUGINJARS" --java-opt="--enable-native-access=ALL-UNNAMED" --java-opt="--enable-preview" --java-opt="-Djava.library.path=%JAVALIBRARYPATH" %s | FileCheck %s -check-prefix=FIRRTL -check-prefix=VERILOG
// SPDX-License-Identifier: Apache-2.0

import chisel3._
Expand Down Expand Up @@ -96,91 +96,25 @@ class Mem extends Module {

println(lit.utility.panamaconverter.firrtlString(new Mem))

// FIRRTL-LABEL: public module Sram :
// FIRRTL-NEXT: input clock : Clock
// FIRRTL-NEXT: input reset : UInt<1>
class Sram extends Module {
// FIRRTL: wire mem
// FIRRTL: mem mem_sram
// FIRRTL: connect mem_sram.R0.addr, mem.readPorts[0].address
// FIRRTL-NEXT: connect mem_sram.R0.clk, clock
// FIRRTL-NEXT: connect mem.readPorts[0].data, mem_sram.R0.data
// FIRRTL-NEXT: connect mem_sram.R0.en, mem.readPorts[0].enable
// FIRRTL-NEXT: connect mem_sram.R1.addr, mem.readPorts[1].address
// FIRRTL-NEXT: connect mem_sram.R1.clk, clock
// FIRRTL-NEXT: connect mem.readPorts[1].data, mem_sram.R1.data
// FIRRTL-NEXT: connect mem_sram.R1.en, mem.readPorts[1].enable
// FIRRTL-NEXT: connect mem_sram.W0.addr, mem.writePorts[0].address
// FIRRTL-NEXT: connect mem_sram.W0.clk, clock
// FIRRTL-NEXT: connect mem_sram.W0.data, mem.writePorts[0].data
// FIRRTL-NEXT: connect mem_sram.W0.en, mem.writePorts[0].enable
// FIRRTL-NEXT: connect mem_sram.W0.mask, UInt<1>(1)
// FIRRTL-NEXT: connect mem_sram.W1.addr, mem.writePorts[1].address
// FIRRTL-NEXT: connect mem_sram.W1.clk, clock
// FIRRTL-NEXT: connect mem_sram.W1.data, mem.writePorts[1].data
// FIRRTL-NEXT: connect mem_sram.W1.en, mem.writePorts[1].enable
// FIRRTL-NEXT: connect mem_sram.W1.mask, UInt<1>(1)
// FIRRTL-NEXT: connect mem_sram.RW0.addr, mem.readwritePorts[0].address
// FIRRTL-NEXT: connect mem_sram.RW0.clk, clock
// FIRRTL-NEXT: connect mem_sram.RW0.en, mem.readwritePorts[0].enable
// FIRRTL-NEXT: connect mem.readwritePorts[0].readData, mem_sram.RW0.rdata
// FIRRTL-NEXT: connect mem_sram.RW0.wdata, mem.readwritePorts[0].writeData
// FIRRTL-NEXT: connect mem_sram.RW0.wmode, mem.readwritePorts[0].isWrite
// FIRRTL-NEXT: connect mem_sram.RW0.wmask, UInt<1>(1)
// FIRRTL-NEXT: connect mem_sram.RW1.addr, mem.readwritePorts[1].address
// FIRRTL-NEXT: connect mem_sram.RW1.clk, clock
// FIRRTL-NEXT: connect mem_sram.RW1.en, mem.readwritePorts[1].enable
// FIRRTL-NEXT: connect mem.readwritePorts[1].readData, mem_sram.RW1.rdata
// FIRRTL-NEXT: connect mem_sram.RW1.wdata, mem.readwritePorts[1].writeData
// FIRRTL-NEXT: connect mem_sram.RW1.wmode, mem.readwritePorts[1].isWrite
// FIRRTL-NEXT: connect mem_sram.RW1.wmask, UInt<1>(1)
// FIRRTL-NEXT: connect mem_sram.RW2.addr, mem.readwritePorts[2].address
// FIRRTL-NEXT: connect mem_sram.RW2.clk, clock
// FIRRTL-NEXT: connect mem_sram.RW2.en, mem.readwritePorts[2].enable
// FIRRTL-NEXT: connect mem.readwritePorts[2].readData, mem_sram.RW2.rdata
// FIRRTL-NEXT: connect mem_sram.RW2.wdata, mem.readwritePorts[2].writeData
// FIRRTL-NEXT: connect mem_sram.RW2.wmode, mem.readwritePorts[2].isWrite
// FIRRTL-NEXT: connect mem_sram.RW2.wmask, UInt<1>(1)
val mem = SRAM(1024, UInt(8.W), 2, 2, 3)

// FIRRTL-NEXT: connect mem.readPorts[0].address, pad(UInt<7>(100), 10)
// FIRRTL-NEXT: connect mem.readPorts[0].enable, UInt<1>(1)
// VERILOG: module mem_sram_1024x8
val mem = SRAM(1024, UInt(8.W), 1, 1, 1)

mem.readPorts(0).address := 100.U
mem.readPorts(0).enable := true.B
mem.writePorts(0).address := 5.U
mem.writePorts(0).enable := true.B
mem.writePorts(0).data := 12.U
mem.readwritePorts(0).address := 5.U
mem.readwritePorts(0).enable := true.B
mem.readwritePorts(0).isWrite := true.B
mem.readwritePorts(0).writeData := 100.U

// FIRRTL-NEXT: wire foo : UInt<8>
// FIRRTL-NEXT: connect foo, mem.readPorts[0].data
val foo = WireInit(UInt(8.W), mem.readPorts(0).data)

// FIRRTL-NEXT: connect mem.writePorts[1].address, pad(UInt<3>(5), 10)
// FIRRTL-NEXT: connect mem.writePorts[1].enable, UInt<1>(1)
// FIRRTL-NEXT: connect mem.writePorts[1].data, pad(UInt<4>(12), 8)
mem.writePorts(1).address := 5.U
mem.writePorts(1).enable := true.B
mem.writePorts(1).data := 12.U

// FIRRTL-NEXT: connect mem.readwritePorts[2].address, pad(UInt<3>(5), 10)
// FIRRTL-NEXT: connect mem.readwritePorts[2].enable, UInt<1>(1)
// FIRRTL-NEXT: connect mem.readwritePorts[2].isWrite, UInt<1>(1)
// FIRRTL-NEXT: connect mem.readwritePorts[2].writeData, pad(UInt<7>(100), 8)
mem.readwritePorts(2).address := 5.U
mem.readwritePorts(2).enable := true.B
mem.readwritePorts(2).isWrite := true.B
mem.readwritePorts(2).writeData := 100.U

// FIRRTL-NEXT: connect mem.readwritePorts[2].address, pad(UInt<3>(5), 10)
// FIRRTL-NEXT: connect mem.readwritePorts[2].enable, UInt<1>(1)
// FIRRTL-NEXT: connect mem.readwritePorts[2].isWrite, UInt<1>(0)
mem.readwritePorts(2).address := 5.U
mem.readwritePorts(2).enable := true.B
mem.readwritePorts(2).isWrite := false.B

// FIRRTL-NEXT: wire bar : UInt<8>
// FIRRTL-NEXT: connect bar, mem.readwritePorts[2].readData
val bar = WireInit(UInt(8.W), mem.readwritePorts(2).readData)
val bar = WireInit(UInt(8.W), mem.readwritePorts(0).readData)
}

println(lit.utility.panamaconverter.firrtlString(new Sram))
println(lit.utility.panamaconverter.verilogString(new Sram))

// FIRRTL-LABEL: public module WireAndReg :
// FIRRTL-NEXT: input clock : Clock
Expand Down
2 changes: 1 addition & 1 deletion lit/tests/Property/Good.sc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import chisel3.panamaom._
import lit.utility._

// SFC-FIRRTL-LABEL: circuit IntPropTest :
// SFC-FIRRTL-NEXT: module IntPropTest :
// SFC-FIRRTL: module IntPropTest :
// SFC-FIRRTL-NEXT: output intProp : Integer
class IntPropTest extends RawModule {
val intProp = IO(Output(Property[Int]()))
Expand Down
8 changes: 6 additions & 2 deletions lit/tests/SmokeTest.sc
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ class FooBundle extends Bundle {
}

// SFC-FIRRTL-LABEL: circuit FooModule :
// SFC-FIRRTL-NEXT: module FooModule :
// SFC-FIRRTL-NEXT: layer Verification, bind, "Verification" :
// SFC-FIRRTL-NEXT: layer Assert, bind, "Verification/Assert" :
// SFC-FIRRTL-NEXT: layer Assume, bind, "Verification/Assume" :
// SFC-FIRRTL-NEXT: layer Cover, bind, "Verification/Cover" :
// SFC-FIRRTL-NEXT: public module FooModule :
// SFC-FIRRTL-NEXT: input clock : Clock
// SFC-FIRRTL-NEXT: input reset : UInt<1>
// SFC-FIRRTL-NEXT: output io : { flip foo : UInt<3>}
// SFC-FIRRTL: skip

// MFC-FIRRTL-LABEL: circuit FooModule :
// MFC-FIRRTL-NEXT: module FooModule :
// MFC-FIRRTL-NEXT: public module FooModule :
// MFC-FIRRTL-NEXT: input clock : Clock
// MFC-FIRRTL-NEXT: input reset : UInt<1>
// MFC-FIRRTL-NEXT: output io : { flip foo : UInt<3> }
Expand Down
2 changes: 1 addition & 1 deletion panamaconverter/src/PanamaCIRCTConverter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ class PanamaCIRCTConverter(val circt: PanamaCIRCT, fos: Option[FirtoolOptions],
.withNamedAttr("name", circt.mlirStringAttrGet(Converter.getRef(firrtlMemory.id, firrtlMemory.sourceInfo).name))
.withNamedAttr("nameKind", circt.firrtlAttrGetNameKind(FIRRTLNameKind.InterestingName))
.withNamedAttr("annotations", circt.emptyArrayAttr)
.withNamedAttr("portAnnotations", circt.emptyArrayAttr)
.withNamedAttr("portAnnotations", circt.mlirArrayAttrGet(ports.map(_ => circt.emptyArrayAttr)))
.withResults(ports.map { case (_, tpe) => tpe })
.build()
val results = ports.zip(op.results).map { case ((name, _), result) => name -> result }.toMap
Expand Down
2 changes: 1 addition & 1 deletion tests.sc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ trait LitModule extends Module {
PathRef(T.dest)
}
def run(args: String*) = T.command(
os.proc("lit", litConfig().path)
os.proc("lit", litConfig().path, "-a")
.call(T.dest, stdout = os.ProcessOutput.Readlines(line => T.ctx().log.info("[lit] " + line)))
)
}

0 comments on commit 341e87a

Please sign in to comment.