amos 2f32624d3b Batch 18 (20261026-C-hwe-codegen-18): add 100 calibrated HWE code-gen tasks; pause production for rollout
100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth
range given to batch 22), each with at least one independent
contract-edge defect and plain public docs. Claude reviewed 100/100
USABLE against current digests; no ID or source overlap with main or
batch 22. Difficulty is unmeasured.

progress.md records the wrap-up: all Codex sessions and Qwen schedulers
stopped for the user's rollout, Qwen results so far (57 HARD of 373),
and what is left on each batch branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 17:52:13 +08:00

58 lines
1.6 KiB
C++

#include "model.hpp"
#include <algorithm>
namespace clockmodel {
std::vector<Word> Bus::export_snapshot(const Device& device)
{
std::vector<Word> values;
values.reserve(5 + device.fifo.size());
for (Word word : device.regs) {
values.push_back(word);
}
values.push_back(static_cast<Word>(device.fifo.size()));
for (Word word : device.fifo) {
values.push_back(word);
}
return values;
}
std::vector<Word> Bus::export_history(const Device& device, std::size_t count)
{
const std::size_t total = device.events.size();
const std::size_t length = std::min(count, total);
const std::size_t skip = total - length;
std::vector<Word> values;
values.reserve(length * 2);
for (std::size_t offset = skip; offset < total; ++offset) {
const Event& event = device.events[offset];
values.push_back(event.reg);
values.push_back(event.value);
}
return values;
}
Reply Bus::snapshot(Arg id) const
{
if (!valid_id(id)) {
return error("ID");
}
const auto index = static_cast<std::size_t>(id);
const Device& device = devices_[index];
Reply reply = success();
reply.values = export_snapshot(device);
return reply;
}
Reply Bus::history(Arg id, Arg count) const
{
if (!valid_id(id)) {
return error("ID");
}
if (!valid_count(count, 32)) {
return error("COUNT");
}
const auto index = static_cast<std::size_t>(id);
const auto length = static_cast<std::size_t>(count);
const Device& device = devices_[index];
Reply reply = success();
reply.values = export_history(device, length);
return reply;
}
}