mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-18 17:30:02 +00:00
Refactor RAM test values.
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
9cd317624e
commit
1234aaf9d9
@ -164,6 +164,7 @@
|
|||||||
<ClCompile Include="cycles_t.cpp" />
|
<ClCompile Include="cycles_t.cpp" />
|
||||||
<ClCompile Include="cycle_t.cpp" />
|
<ClCompile Include="cycle_t.cpp" />
|
||||||
<ClCompile Include="opcode_test_suite_t.cpp" />
|
<ClCompile Include="opcode_test_suite_t.cpp" />
|
||||||
|
<ClCompile Include="ram_t.cpp" />
|
||||||
<ClCompile Include="simdjson\simdjson.cpp">
|
<ClCompile Include="simdjson\simdjson.cpp">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||||
@ -186,6 +187,7 @@
|
|||||||
<ClInclude Include="cycle_t.h" />
|
<ClInclude Include="cycle_t.h" />
|
||||||
<ClInclude Include="nlohmann\json.hpp" />
|
<ClInclude Include="nlohmann\json.hpp" />
|
||||||
<ClInclude Include="opcode_test_suite_t.h" />
|
<ClInclude Include="opcode_test_suite_t.h" />
|
||||||
|
<ClInclude Include="ram_t.h" />
|
||||||
<ClInclude Include="simdjson\simdjson.h" />
|
<ClInclude Include="simdjson\simdjson.h" />
|
||||||
<ClInclude Include="state_t.h" />
|
<ClInclude Include="state_t.h" />
|
||||||
<ClInclude Include="stdafx.h" />
|
<ClInclude Include="stdafx.h" />
|
||||||
|
@ -44,6 +44,9 @@
|
|||||||
<ClCompile Include="cycles_t.cpp">
|
<ClCompile Include="cycles_t.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="ram_t.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="stdafx.h">
|
<ClInclude Include="stdafx.h">
|
||||||
@ -73,6 +76,9 @@
|
|||||||
<ClInclude Include="cycles_t.h">
|
<ClInclude Include="cycles_t.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="ram_t.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
67
M6502/HarteTest_6502/ram_t.cpp
Normal file
67
M6502/HarteTest_6502/ram_t.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
#include "ram_t.h"
|
||||||
|
|
||||||
|
#ifdef USE_SIMDJSON_JSON
|
||||||
|
|
||||||
|
ram_t::ram_t(simdjson::dom::array input) {
|
||||||
|
m_bytes.reserve(input.size());
|
||||||
|
for (const auto byte : input) {
|
||||||
|
assert(byte.is_array());
|
||||||
|
const auto ram_entry_array = byte.get_array();
|
||||||
|
assert(byte.size() == 2);
|
||||||
|
const auto address = (uint16_t)(uint64_t)byte.at(0);
|
||||||
|
const auto value = (uint8_t)(uint64_t)byte.at(1);
|
||||||
|
m_bytes.push_back({ address, value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BOOST_JSON
|
||||||
|
|
||||||
|
ram_t::ram_t(const boost::json::array& input) {
|
||||||
|
m_bytes.reserve(input.size());
|
||||||
|
for (const auto& byte : input) {
|
||||||
|
const auto& ram_entry_array = byte.as_array();
|
||||||
|
assert(ram_entry_array.size() == 2);
|
||||||
|
const auto address = (uint16_t)ram_entry_array.at(0).as_int64();
|
||||||
|
const auto value = (uint8_t)ram_entry_array.at(1).as_int64();
|
||||||
|
m_bytes.push_back({ address, value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ram_t::ram_t(const boost::json::value& input)
|
||||||
|
: ram_t(input.as_array()) {}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_NLOHMANN_JSON
|
||||||
|
|
||||||
|
ram_t::ram_t(const nlohmann::json& input) {
|
||||||
|
assert(input.is_array());
|
||||||
|
for (const auto& byte : input) {
|
||||||
|
assert(byte.is_array());
|
||||||
|
assert(byte.size() == 2);
|
||||||
|
const auto address = byte[0].get<uint16_t>();
|
||||||
|
const auto value = byte[1].get<uint8_t>();
|
||||||
|
m_bytes.push_back({ address, value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_JSONCPP_JSON
|
||||||
|
|
||||||
|
ram_t::ram_t(const Json::Value& input) {
|
||||||
|
|
||||||
|
assert(input.isArray());
|
||||||
|
for (const auto& byte : input) {
|
||||||
|
assert(byte.isArray());
|
||||||
|
assert(byte.size() == 2);
|
||||||
|
const auto address = byte[0].asUInt();
|
||||||
|
const auto value = byte[1].asUInt();
|
||||||
|
m_bytes.push_back({ address, value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
55
M6502/HarteTest_6502/ram_t.h
Normal file
55
M6502/HarteTest_6502/ram_t.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef USE_SIMDJSON_JSON
|
||||||
|
# include "simdjson/simdjson.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BOOST_JSON
|
||||||
|
# include <boost/json.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_NLOHMANN_JSON
|
||||||
|
# include "nlohmann/json.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_JSONCPP_JSON
|
||||||
|
# include <json/json.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class ram_t {
|
||||||
|
private:
|
||||||
|
std::vector<std::pair<uint16_t, uint8_t>> m_bytes;
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef USE_SIMDJSON_JSON
|
||||||
|
ram_t(simdjson::dom::array input);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BOOST_JSON
|
||||||
|
ram_t(const boost::json::value& input);
|
||||||
|
ram_t(const boost::json::array& input);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_NLOHMANN_JSON
|
||||||
|
ram_t(const nlohmann::json& input);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_JSONCPP_JSON
|
||||||
|
ram_t(const Json::Value& input);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
[[nodiscard]] auto begin() const { return m_bytes.begin(); }
|
||||||
|
[[nodiscard]] auto end() const { return m_bytes.end(); }
|
||||||
|
|
||||||
|
[[nodiscard]] auto size() const noexcept { return m_bytes.size(); }
|
||||||
|
|
||||||
|
void clear() { m_bytes.clear(); }
|
||||||
|
|
||||||
|
[[nodiscard]] auto& at(size_t idx) { return m_bytes.at(idx); }
|
||||||
|
[[nodiscard]] const auto& at(size_t idx) const { return m_bytes.at(idx); }
|
||||||
|
};
|
||||||
|
|
@ -2,8 +2,6 @@
|
|||||||
#include "state_t.h"
|
#include "state_t.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
state_t::state_t() {}
|
|
||||||
|
|
||||||
#ifdef USE_SIMDJSON_JSON
|
#ifdef USE_SIMDJSON_JSON
|
||||||
|
|
||||||
state_t::state_t(const simdjson::dom::element serialised)
|
state_t::state_t(const simdjson::dom::element serialised)
|
||||||
@ -12,19 +10,8 @@ state_t::state_t(const simdjson::dom::element serialised)
|
|||||||
m_a((uint8_t)(uint64_t)serialised["a"]),
|
m_a((uint8_t)(uint64_t)serialised["a"]),
|
||||||
m_x((uint8_t)(uint64_t)serialised["x"]),
|
m_x((uint8_t)(uint64_t)serialised["x"]),
|
||||||
m_y((uint8_t)(uint64_t)serialised["y"]),
|
m_y((uint8_t)(uint64_t)serialised["y"]),
|
||||||
m_p((uint8_t)(uint64_t)serialised["p"]) {
|
m_p((uint8_t)(uint64_t)serialised["p"]),
|
||||||
|
m_ram(serialised["ram"].get_array()) {}
|
||||||
const auto ram_entries = serialised["ram"].get_array();
|
|
||||||
m_ram.reserve(ram_entries.size());
|
|
||||||
for (const auto ram_entry : ram_entries) {
|
|
||||||
assert(ram_entry.is_array());
|
|
||||||
const auto ram_entry_array = ram_entry.get_array();
|
|
||||||
assert(ram_entry_array.size() == 2);
|
|
||||||
const auto address = (uint16_t)(uint64_t)ram_entry_array.at(0);
|
|
||||||
const auto value = (uint8_t)(uint64_t)ram_entry_array.at(1);
|
|
||||||
m_ram.push_back({ address, value });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -36,18 +23,8 @@ state_t::state_t(const boost::json::object& serialised)
|
|||||||
m_a((uint8_t)serialised.at("a").as_int64()),
|
m_a((uint8_t)serialised.at("a").as_int64()),
|
||||||
m_x((uint8_t)serialised.at("x").as_int64()),
|
m_x((uint8_t)serialised.at("x").as_int64()),
|
||||||
m_y((uint8_t)serialised.at("y").as_int64()),
|
m_y((uint8_t)serialised.at("y").as_int64()),
|
||||||
m_p((uint8_t)serialised.at("p").as_int64()) {
|
m_p((uint8_t)serialised.at("p").as_int64()),
|
||||||
|
m_ram(serialised.at("ram")) {}
|
||||||
const auto& ram_entries = serialised.at("ram").as_array();
|
|
||||||
m_ram.reserve(ram_entries.size());
|
|
||||||
for (const auto& ram_entry : ram_entries) {
|
|
||||||
const auto& ram_entry_array = ram_entry.as_array();
|
|
||||||
assert(ram_entry_array.size() == 2);
|
|
||||||
const auto address = (uint16_t)ram_entry_array.at(0).as_int64();
|
|
||||||
const auto value = (uint8_t)ram_entry_array.at(1).as_int64();
|
|
||||||
m_ram.push_back({ address, value });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
state_t::state_t(const boost::json::value& serialised)
|
state_t::state_t(const boost::json::value& serialised)
|
||||||
: state_t(serialised.as_object()) {}
|
: state_t(serialised.as_object()) {}
|
||||||
@ -62,18 +39,8 @@ state_t::state_t(const nlohmann::json& serialised)
|
|||||||
m_a(serialised["a"].get<uint8_t>()),
|
m_a(serialised["a"].get<uint8_t>()),
|
||||||
m_x(serialised["x"].get<uint8_t>()),
|
m_x(serialised["x"].get<uint8_t>()),
|
||||||
m_y(serialised["y"].get<uint8_t>()),
|
m_y(serialised["y"].get<uint8_t>()),
|
||||||
m_p(serialised["p"].get<uint8_t>()) {
|
m_p(serialised["p"].get<uint8_t>()),
|
||||||
|
m_ram(serialised["ram"]) {}
|
||||||
const auto& ram_entries = serialised["ram"];
|
|
||||||
assert(ram_entries.is_array());
|
|
||||||
for (const auto& ram_entry : ram_entries) {
|
|
||||||
assert(ram_entry.is_array());
|
|
||||||
assert(ram_entry.size() == 2);
|
|
||||||
const auto address = ram_entry[0].get<uint16_t>();
|
|
||||||
const auto value = ram_entry[1].get<uint8_t>();
|
|
||||||
m_ram.push_back({ address, value });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -85,17 +52,7 @@ state_t::state_t(const Json::Value& serialised)
|
|||||||
m_a(serialised["a"].asUInt()),
|
m_a(serialised["a"].asUInt()),
|
||||||
m_x(serialised["x"].asUInt()),
|
m_x(serialised["x"].asUInt()),
|
||||||
m_y(serialised["y"].asUInt()),
|
m_y(serialised["y"].asUInt()),
|
||||||
m_p(serialised["p"].asUInt()) {
|
m_p(serialised["p"].asUInt()),
|
||||||
|
m_ram(serialised["ram"]) {}
|
||||||
const auto& ram_entries = serialised["ram"];
|
|
||||||
assert(ram_entries.isArray());
|
|
||||||
for (const auto& ram_entry : ram_entries) {
|
|
||||||
assert(ram_entry.isArray());
|
|
||||||
assert(ram_entry.size() == 2);
|
|
||||||
const auto address = ram_entry[0].asUInt();
|
|
||||||
const auto value = ram_entry[1].asUInt();
|
|
||||||
m_ram.push_back({ address, value });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <tuple>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifdef USE_SIMDJSON_JSON
|
#ifdef USE_SIMDJSON_JSON
|
||||||
# include "simdjson/simdjson.h"
|
# include "simdjson/simdjson.h"
|
||||||
@ -20,6 +18,8 @@
|
|||||||
# include <json/json.h>
|
# include <json/json.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "ram_t.h"
|
||||||
|
|
||||||
class state_t final {
|
class state_t final {
|
||||||
private:
|
private:
|
||||||
uint16_t m_pc = 0xffff;
|
uint16_t m_pc = 0xffff;
|
||||||
@ -28,11 +28,7 @@ private:
|
|||||||
uint8_t m_x = 0xff;
|
uint8_t m_x = 0xff;
|
||||||
uint8_t m_y = 0xff;
|
uint8_t m_y = 0xff;
|
||||||
uint8_t m_p = 0xff;
|
uint8_t m_p = 0xff;
|
||||||
std::vector<std::pair<uint16_t, uint8_t>> m_ram;
|
ram_t m_ram;
|
||||||
|
|
||||||
#ifdef USE_JSONCPP_JSON
|
|
||||||
void initialise(const Json::Value& serialised);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
state_t();
|
state_t();
|
||||||
|
@ -7,16 +7,16 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <utility>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
//#define TEST_JSON_PERFORMANCE
|
//#define TEST_JSON_PERFORMANCE
|
||||||
|
|
||||||
#define USE_SIMDJSON_JSON // 14 seconds
|
#define USE_SIMDJSON_JSON // 13 seconds
|
||||||
//#define USE_BOOST_JSON // 28 seconds
|
//#define USE_BOOST_JSON // 26 seconds
|
||||||
//#define USE_NLOHMANN_JSON // 56 seconds
|
//#define USE_NLOHMANN_JSON // 56 seconds
|
||||||
//#define USE_JSONCPP_JSON // 97 seconds
|
//#define USE_JSONCPP_JSON // 89 seconds
|
||||||
|
|
||||||
#ifdef USE_SIMDJSON_JSON
|
#ifdef USE_SIMDJSON_JSON
|
||||||
# define JSON_PREFER_PASS_BY_VALUE
|
# define JSON_PREFER_PASS_BY_VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user