Skip to content

Commit

Permalink
Bump marchid to 0xf
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart authored and vfusco committed May 2, 2023
1 parent a60634e commit 8df3c93
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/cartesi-machine-tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/clua-cartesi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/riscv-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/test-machine-c-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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<uint64_t>(0x6361727465736920));
BOOST_CHECK_EQUAL(vendorid, static_cast<uint64_t>(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<uint64_t>(0xe));
BOOST_CHECK_EQUAL(archid, static_cast<uint64_t>(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<uint64_t>(0x1));
BOOST_CHECK_EQUAL(impid, static_cast<uint64_t>(cartesi::MIMPID_INIT));
}

BOOST_FIXTURE_TEST_CASE_NOLINT(read_htif_tohost_read_complex_test, ordinary_machine_fixture) {
Expand Down
6 changes: 3 additions & 3 deletions src/tests/machine-bind.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tests/machine-test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 8df3c93

Please sign in to comment.