Kelvin MluTest Added
Add basic MLU test to provide some test coverage for mlu
Change-Id: I9c27012a626ce4a7a383ac2cb5bad65764845506
diff --git a/hdl/chisel/src/kelvin/BUILD b/hdl/chisel/src/kelvin/BUILD
index 9873eed..a1c550e 100644
--- a/hdl/chisel/src/kelvin/BUILD
+++ b/hdl/chisel/src/kelvin/BUILD
@@ -12,19 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("@kelvin_hw//rules:chisel.bzl",
+load(
+ "@kelvin_hw//rules:chisel.bzl",
"chisel_binary",
"chisel_cc_library",
"chisel_library",
- "chisel_test")
+ "chisel_test",
+)
package(default_visibility = ["//visibility:public"])
chisel_library(
name = "kelvin_float",
srcs = [
- "scalar/Fpu.scala",
"scalar/FRegfile.scala",
+ "scalar/Fpu.scala",
],
deps = [
":kelvin",
@@ -36,8 +38,8 @@
chisel_test(
name = "kelvin_float_tests",
srcs = [
- "scalar/FpuTest.scala",
"scalar/FRegfileTest.scala",
+ "scalar/FpuTest.scala",
],
deps = [
":kelvin",
@@ -46,6 +48,16 @@
],
)
+chisel_test(
+ name = "kelvin_scalar_tests",
+ srcs = [
+ "scalar/MluTest.scala",
+ ],
+ deps = [
+ ":kelvin",
+ ],
+)
+
chisel_library(
name = "kelvin",
srcs = [
@@ -72,16 +84,16 @@
"scalar/Regfile.scala",
"scalar/SCore.scala",
"scalar/SLog.scala",
- "vector/VAluInt.scala",
"vector/VAlu.scala",
+ "vector/VAluInt.scala",
"vector/VCmdq.scala",
"vector/VCommon.scala",
"vector/VConvAlu.scala",
"vector/VConvCtrl.scala",
"vector/VCore.scala",
+ "vector/VDecode.scala",
"vector/VDecodeInstruction.scala",
"vector/VDecodeOp.scala",
- "vector/VDecode.scala",
"vector/VDot.scala",
"vector/VEncodeOp.scala",
"vector/VInst.scala",
@@ -92,7 +104,7 @@
"vector/VSt.scala",
],
deps = [
- "//hdl/chisel/src/common:common",
+ "//hdl/chisel/src/common",
],
)
@@ -226,10 +238,10 @@
chisel_binary(
name = "emit_parameters_header",
+ main_class = "kelvin.EmitParametersHeader",
deps = [
":kelvin",
],
- main_class = "kelvin.EmitParametersHeader",
)
genrule(
@@ -237,7 +249,7 @@
outs = [
"kelvin_parameters.h",
],
- tools = [":emit_parameters_header"],
cmd = "$(location :emit_parameters_header) > $(location kelvin_parameters.h)",
+ tools = [":emit_parameters_header"],
visibility = ["//visibility:public"],
)
diff --git a/hdl/chisel/src/kelvin/scalar/MluTest.scala b/hdl/chisel/src/kelvin/scalar/MluTest.scala
new file mode 100644
index 0000000..80f11c4
--- /dev/null
+++ b/hdl/chisel/src/kelvin/scalar/MluTest.scala
@@ -0,0 +1,60 @@
+// Copyright 2024 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package kelvin
+
+import chisel3._
+import chisel3.util._
+import chiseltest._
+import org.scalatest.freespec.AnyFreeSpec
+import chisel3.experimental.BundleLiterals._
+
+
+class MluSpec extends AnyFreeSpec with ChiselScalatestTester {
+ val p = new Parameters
+
+ "Initialization" in {
+ test(new Mlu(p)) { dut =>
+ assertResult(0) { dut.io.rd.valid.peekInt() }
+ }
+ }
+
+ "Multiply" in {
+ test(new Mlu(p)) { dut =>
+ dut.io.req(0).bits.addr.poke(13)
+ dut.io.req(0).bits.op.poke(MluOp.MUL)
+ dut.io.req(0).valid.poke(true.B)
+ dut.io.req(1).valid.poke(false.B)
+ dut.io.req(2).valid.poke(false.B)
+ dut.io.req(3).valid.poke(false.B)
+ for(i <- 0 until 4){
+ dut.io.rs1(i).valid.poke(true.B)
+ dut.io.rs1(i).data.poke(i + 2)
+ dut.io.rs2(i).valid.poke(true.B)
+ dut.io.rs2(i).data.poke(i + 2)
+ }
+
+ dut.clock.step()
+ dut.io.req(0).valid.poke(false.B)
+
+ dut.clock.step()
+ assertResult(1) { dut.io.rd.valid.peekInt() }
+ assertResult(13) { dut.io.rd.addr.peekInt() }
+ assertResult(4) { dut.io.rd.data.peekInt() }
+
+ dut.clock.step()
+ assertResult(0) { dut.io.rd.valid.peekInt() }
+ }
+ }
+}