diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1416be0c0..1455ebf1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,8 @@ env: KERNEL_VERSION: v0.16.0 LINUX_VERSION: 5.15.63-ctsi-2 ROOTFS_VERSION: v0.17.0 - TEST_VERSION: v0.27.0 - GROUND_TRUTH_VERSION: v0.27.0-0001 + TEST_VERSION: v0.28.0 + GROUND_TRUTH_VERSION: v0.28.0-0001 BUILD_CACHE_VERSION: v0.10.0-0006 jobs: build: diff --git a/CHANGELOG.md b/CHANGELOG.md index 64d09d789..5c5fb9b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed crypto++ library from third-party. Using system-installed library instead. - Changed --step command-line option to --step-uarch in cartesi-machine.lua, for consistency - Removed server-manager implementation from the emulator repository +- Changed marchid to 0xf ## [0.13.0] - 2023-02-16 ### Added diff --git a/src/cartesi-machine-tests.lua b/src/cartesi-machine-tests.lua index 515e0a6ca..ff1d8f3e4 100755 --- a/src/cartesi-machine-tests.lua +++ b/src/cartesi-machine-tests.lua @@ -668,10 +668,10 @@ end local function check_test_result(ctx) io.write(ctx.ram_image, ": ") if #ctx.expected_yield_payloads ~= (ctx.yield_payload_index - 1) then - add_error(ctx, "yielded %d times, expected %d", ctx.yield_payload_index-1, #ctx.expected_yield_payloads) + add_error(ctx, "yielded %d times, expected %d", ctx.yield_payload_index-1, #ctx.expected_yield_payloads) end if ctx.read_htif_tohost_data >> 1 ~= ctx.expected_halt_payload then - add_error(ctx, "returned halt payload %d, expected %d", read_htif_tohost_data >> 1, ctx.expected_halt_payload) + add_error(ctx, "returned halt payload %d, expected %d", ctx.read_htif_tohost_data >> 1, ctx.expected_halt_payload) end if ctx.cycles ~= ctx.expected_cycles then add_error(ctx, "terminated with mcycle = %d, expected %d", ctx.cycles, ctx.expected_cycles) diff --git a/src/clua-cartesi.cpp b/src/clua-cartesi.cpp index bf0037f98..a3c1e2224 100644 --- a/src/clua-cartesi.cpp +++ b/src/clua-cartesi.cpp @@ -21,6 +21,7 @@ #include "clua-machine.h" #include "clua.h" #include "machine-c-api.h" +#include "riscv-constants.h" /// \file /// \brief Scripting interface for the Cartesi SDK. @@ -120,6 +121,10 @@ CM_API int luaopen_cartesi(lua_State *L) { clua_setintegerfield(L, CM_BREAK_REASON_REACHED_TARGET_MCYCLE, "BREAK_REASON_REACHED_TARGET_MCYCLE", -1); clua_setintegerfield(L, CM_UARCH_BREAK_REASON_REACHED_TARGET_CYCLE, "UARCH_BREAK_REASON_REACHED_TARGET_CYCLE", -1); clua_setintegerfield(L, CM_UARCH_BREAK_REASON_HALTED, "UARCH_BREAK_REASON_HALTED", -1); + + clua_setintegerfield(L, MVENDORID_INIT, "MVENDORID", -1); + clua_setintegerfield(L, MARCHID_INIT, "MARCHID", -1); + clua_setintegerfield(L, MIMPID_INIT, "MIMPID", -1); return 1; } } diff --git a/src/riscv-constants.h b/src/riscv-constants.h index 8a0a4fe94..b6648b05b 100644 --- a/src/riscv-constants.h +++ b/src/riscv-constants.h @@ -430,7 +430,7 @@ enum CARTESI_init : uint64_t { PC_INIT = UINT64_C(0x1000), ///< Initial value for pc FCSR_INIT = UINT64_C(0), ///< Initial value for fcsr MVENDORID_INIT = UINT64_C(0x6361727465736920), ///< Initial value for mvendorid - MARCHID_INIT = UINT64_C(0xe), ///< Initial value for marchid + MARCHID_INIT = UINT64_C(0xf), ///< Initial value for marchid MIMPID_INIT = UINT64_C(1), ///< Initial value for mimpid MCYCLE_INIT = UINT64_C(0), ///< Initial value for mcycle ICYCLEINSTRET_INIT = UINT64_C(0), ///< Initial value for icycleinstret diff --git a/src/test-machine-c-api.cpp b/src/test-machine-c-api.cpp index 67ab77d6b..6c04748fb 100644 --- a/src/test-machine-c-api.cpp +++ b/src/test-machine-c-api.cpp @@ -31,6 +31,7 @@ #include "grpc-machine-c-api.h" #include "machine-c-api.h" +#include "riscv-constants.h" #include "test-utils.h" #include "uarch-solidity-compat.h" @@ -1347,17 +1348,17 @@ BOOST_FIXTURE_TEST_CASE_NOLINT(ids_read_test, ordinary_machine_fixture) { int error_code = cm_read_mvendorid(_machine, &vendorid, &err_msg); BOOST_CHECK_EQUAL(error_code, CM_ERROR_OK); BOOST_CHECK_EQUAL(err_msg, nullptr); - BOOST_CHECK_EQUAL(vendorid, static_cast(0x6361727465736920)); + BOOST_CHECK_EQUAL(vendorid, static_cast(cartesi::MVENDORID_INIT)); error_code = cm_read_marchid(_machine, &archid, &err_msg); BOOST_CHECK_EQUAL(error_code, CM_ERROR_OK); BOOST_CHECK_EQUAL(err_msg, nullptr); - BOOST_CHECK_EQUAL(archid, static_cast(0xe)); + BOOST_CHECK_EQUAL(archid, static_cast(cartesi::MARCHID_INIT)); error_code = cm_read_mimpid(_machine, &impid, &err_msg); BOOST_CHECK_EQUAL(error_code, CM_ERROR_OK); BOOST_CHECK_EQUAL(err_msg, nullptr); - BOOST_CHECK_EQUAL(impid, static_cast(0x1)); + BOOST_CHECK_EQUAL(impid, static_cast(cartesi::MIMPID_INIT)); } BOOST_FIXTURE_TEST_CASE_NOLINT(read_htif_tohost_read_complex_test, ordinary_machine_fixture) { diff --git a/src/tests/machine-bind.lua b/src/tests/machine-bind.lua index 3864c1705..eb4cb5951 100755 --- a/src/tests/machine-bind.lua +++ b/src/tests/machine-bind.lua @@ -508,9 +508,9 @@ print("\n\n test read_csr") do_test("should return expected values", function(machine) local initial_csr_values = get_cpu_csr_test_values() - initial_csr_values.mvendorid = 0x6361727465736920 - initial_csr_values.marchid = 0xe - initial_csr_values.mimpid = 0x1 + initial_csr_values.mvendorid = cartesi.MVENDORID + initial_csr_values.marchid = cartesi.MARCHID + initial_csr_values.mimpid = cartesi.MIMPID initial_csr_values.htif_tohost = 0x0 initial_csr_values.htif_fromhost = 0x0 initial_csr_values.htif_ihalt = 0x0 diff --git a/src/tests/machine-test.lua b/src/tests/machine-test.lua index d1a914a06..9089817c9 100755 --- a/src/tests/machine-test.lua +++ b/src/tests/machine-test.lua @@ -230,7 +230,7 @@ do_test("machine halt and yield flags and config matches", -- Get machine default config and test for known fields local initial_config = machine:get_initial_config() -- test_util.print_table(initial_config) - assert(initial_config["processor"]["marchid"] == 0xe, + assert(initial_config["processor"]["marchid"] == cartesi.MARCHID, "marchid value does not match") assert(initial_config["processor"]["pc"] == 0x1000, "pc value does not match")