Skip to content

Commit

Permalink
[cover] update rvdecoderdb test cases and bump it to scala3
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed Jan 13, 2025
1 parent db5740f commit 5dfbffb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,11 @@ trait PanamaModule extends JavaModule {

object rvdecoderdb extends RVDecoderDB

trait RVDecoderDB extends common.RVDecoderDBJVMModule with ScalaModule {
def scalaVersion = T(v.scala)
def osLibIvy = v.oslib
def upickleIvy = v.upickle
trait RVDecoderDB extends common.RVDecoderDBJVMModule with ScalaModule with ScalafmtModule {
def scalaVersion = T(v.scala)
def osLibIvy = v.oslib
def upickleIvy = v.upickle

override def millSourcePath = os.pwd / "rvdecoderdb" / "rvdecoderdb"
}

Expand Down
13 changes: 7 additions & 6 deletions cover/tests/src/CoverTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

package cover.tests

import rvdecoderdb.*
import org.chipsalliance.rvdecoderdb
import utest.*
import os.*

object RVDecoderDBTest extends TestSuite:
val tests = Tests:
test("RVDecoderDB should decode correctly") {
val decoder = new RVDecoderDB()
val instruction = 0x00000013 // NOP instruction in RISC-V
val decoded = decoder.decode(instruction)
assert(decoded.mnemonic == "NOP")
test("rvdecoderdb works") {
val instTable: Iterable[rvdecoderdb.Instruction] = rvdecoderdb.instructions(os.pwd / "rvdecoderdb" / "rvdecoderdbtest" / "jvm" / "riscv-opcodes")
instTable.foreach { case inst: rvdecoderdb.Instruction =>
println(inst.toString)
}
}

1 change: 1 addition & 0 deletions nix/zaozi/cover.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let
./../../circtlib
./../../mlirlib
./../../cover
./../../rvdecoder
];
};

Expand Down
4 changes: 2 additions & 2 deletions rvdecoderdb/rvdecoderdb/src/parser/parse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object parse {
val pseudoEncodingMap = collection.mutable.HashMap.empty[(String, String), org.chipsalliance.rvdecoderdb.Encoding]

// create normal instructions
rawInstructionSets.foreach { set: RawInstructionSet =>
rawInstructionSets.foreach { case set: RawInstructionSet =>
set.rawInstructions.foreach {
case rawInst: RawInstruction if rawInst.isNormal =>
require(
Expand All @@ -77,7 +77,7 @@ object parse {
}

// imported_instructions - these are instructions which are borrowed from an extension into a new/different extension/sub-extension. Only regular instructions can be imported. Pseudo-op or already imported instructions cannot be imported.
rawInstructionSets.foreach { set: RawInstructionSet =>
rawInstructionSets.foreach { case set: RawInstructionSet =>
set.rawInstructions.foreach {
case rawInst: RawInstruction if rawInst.importInstructionSet.isDefined =>
instructionSetsMap.filter(_._2.head == rawInst.importInstructionSet.get).map {
Expand Down

0 comments on commit 5dfbffb

Please sign in to comment.