Merge changes from topics "kelvin-vsubsu", "kelvin_reg_0"
* changes:
Initialize several registers to 0
Fix vsubs.u
diff --git a/.bazelrc b/.bazelrc
index c4e0831..365b9e4 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -7,3 +7,8 @@
build --host_copt=-Wno-unused-variable
build --host_copt=-Wno-unused-value
build --host_copt=-Wno-uninitialized
+
+# This lets us generate key/value pairs for the workspace which can be used to
+# generate the version information.
+
+build --workspace_status_command=utils/get_workspace_status.sh
diff --git a/README.md b/README.md
index 9c68e06..b697d08 100644
--- a/README.md
+++ b/README.md
@@ -20,5 +20,6 @@
Verilog source for the Matcha SoC can be generated using:
```bash
-bazel build //hdl/chisel:kelvin_cc_library_emit_verilog
+bazel clean --expunge # To generate the ToT sha
+bazel build //hdl/chisel:matcha_kelvin_verilog
```
diff --git a/hdl/chisel/BUILD b/hdl/chisel/BUILD
index d260a33..3b958a8 100644
--- a/hdl/chisel/BUILD
+++ b/hdl/chisel/BUILD
@@ -77,6 +77,13 @@
)
chisel_cc_library(
+ name = "valuint_cc_library",
+ chisel_lib = ":kelvin",
+ emit_class = "kelvin.EmitVAluInt",
+ module_name = "VAluInt",
+)
+
+chisel_cc_library(
name = "vcmdq_cc_library",
chisel_lib = ":kelvin",
emit_class = "kelvin.EmitVCmdq",
@@ -145,3 +152,15 @@
emit_class = "kelvin.EmitVSt",
module_name = "VSt",
)
+
+genrule(
+ name = "matcha_kelvin_verilog",
+ srcs = [":Kelvin.v"],
+ outs = ["kelvin.v"],
+ cmd = """
+ echo "// SHA: $$(awk '/KELVIN_BUILD_GIT_VERSION/ { print $$2 }' \
+ bazel-out/volatile-status.txt)" > $@
+ cat $< >> $@
+ """,
+ stamp = 1, # this provides volatile-status.txt
+)
diff --git a/hdl/verilog/Sram_1rwm_256x288.v b/hdl/verilog/Sram_1rwm_256x288.v
index 011c7cc..425b662 100644
--- a/hdl/verilog/Sram_1rwm_256x288.v
+++ b/hdl/verilog/Sram_1rwm_256x288.v
@@ -11,13 +11,12 @@
input volt_sel
);
+`ifdef FPGA
reg [287:0] mem [0:255];
reg [7:0] raddr;
assign rdata = mem[raddr];
-`ifdef FPGA
-
always @(posedge clock) begin
for (int i = 0; i < 32; i++) begin
if (valid & write & wmask[i]) begin
diff --git a/tests/verilator_sim/BUILD b/tests/verilator_sim/BUILD
index 216b7a7..452c11f 100644
--- a/tests/verilator_sim/BUILD
+++ b/tests/verilator_sim/BUILD
@@ -88,22 +88,44 @@
],
)
+cc_library(
+ name = "valu",
+ hdrs = [
+ "kelvin/alu_ref.h",
+ "kelvin/valu.h",
+ ],
+ deps = [
+ ":vencodeop",
+ ],
+)
+
cc_test(
name = "valu_tb",
size = "large",
srcs = [
- "kelvin/alu_ref.h",
- "kelvin/valu.h",
"kelvin/valu_tb.cc",
],
deps = [
":kelvin_if",
":sim_libs",
- ":vencodeop",
+ ":valu",
"//hdl/chisel:valu_cc_library",
],
)
+cc_test(
+ name = "valuint_tb",
+ srcs = [
+ "kelvin/valuint_tb.cc",
+ ],
+ deps = [
+ ":kelvin_if",
+ ":sim_libs",
+ ":valu",
+ "//hdl/chisel:valuint_cc_library",
+ ],
+)
+
cc_library(
name = "vdecode",
hdrs = [
diff --git a/tests/verilator_sim/kelvin/valuint_tb.cc b/tests/verilator_sim/kelvin/valuint_tb.cc
index f86ad37..05999be 100644
--- a/tests/verilator_sim/kelvin/valuint_tb.cc
+++ b/tests/verilator_sim/kelvin/valuint_tb.cc
@@ -1,12 +1,12 @@
// Copyright 2023 Google LLC
-#include "VVAluInt.h"
-#include "sysc_tb.h"
-#include "valu.h"
+#include "VVAluInt.h" // Generated.
+#include "tests/verilator_sim/kelvin/valu.h"
+#include "tests/verilator_sim/sysc_tb.h"
struct VAluInt_tb : Sysc_tb {
sc_out<bool> io_in_valid;
- sc_out<sc_bv<kOpBits> > io_in_op;
+ sc_out<sc_bv<encode::kOpBits> > io_in_op;
sc_out<sc_bv<3> > io_in_f2;
sc_out<sc_bv<3> > io_in_sz;
sc_out<sc_bv<6> > io_in_vd_addr;
@@ -41,15 +41,15 @@
const uint8_t ve_addr = rand_int(0, 63);
uint32_t sv_data = 0;
- uint8_t op = rand_int(0, kOpEntries - 1);
+ uint8_t op = rand_int(0, encode::kOpEntries - 1);
// Inputs.
valu_t r = {0};
r_.read(r);
- if (op == vdwconv) {
+ if (op == encode::vdwconv) {
// Disallow DW in CRT.
- op = 0; // TODO
+ op = 0;
}
io_in_valid = valid;
@@ -142,7 +142,7 @@
static void VAluInt_test(char* name, int loops, bool trace) {
sc_signal<bool> io_in_valid;
- sc_signal<sc_bv<kOpBits> > io_in_op;
+ sc_signal<sc_bv<encode::kOpBits> > io_in_op;
sc_signal<sc_bv<3> > io_in_f2;
sc_signal<sc_bv<3> > io_in_sz;
sc_signal<sc_bv<6> > io_in_vd_addr;
diff --git a/utils/get_workspace_status.sh b/utils/get_workspace_status.sh
new file mode 100755
index 0000000..730757e
--- /dev/null
+++ b/utils/get_workspace_status.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Copyright 2023 Google LLC
+#
+# This script will be run by bazel when the build process wants to generate
+# information about the status of the workspace.
+#
+# The output will be key-value pairs in the form:
+# KEY1 VALUE1
+#
+# If this script exits with a non-zero exit code, it's considered as a failure
+# and the output will be discarded.
+
+git_rev=$(git rev-parse HEAD)
+if [[ $? != 0 ]];
+then
+ exit 1
+fi
+echo "KELVIN_BUILD_GIT_VERSION ${git_rev}"