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

117 lines
3.0 KiB
C++

#include "model.hpp"
#include <utility>
namespace clockmodel {
Reply Bus::configure(Arg id, Arg clock, Arg reset, Arg enable, Arg data)
{
if (!valid_id(id)) {
return error("ID");
}
if (!valid_word(clock)) {
return error("WORD");
}
if (!valid_word(reset)) {
return error("WORD");
}
if (!valid_word(enable)) {
return error("WORD");
}
if (!valid_word(data)) {
return error("WORD");
}
if ((clock & 1) == 0) {
return error("CLOCK");
}
if ((reset & 1) == 0) {
return error("RESET");
}
if ((enable & 1) == 0) {
return error("ENABLE");
}
const auto index = static_cast<std::size_t>(id);
Device trial = devices_[index];
std::array<Event, 5> plan{{
{1, 0},
{0, static_cast<Word>(clock)},
{1, static_cast<Word>(reset)},
{2, static_cast<Word>(enable)},
{3, static_cast<Word>(data)}
}};
for (const Event& event : plan) {
std::string status = apply(trial, event.reg, event.value);
if (status != "OK") {
return error(status);
}
}
devices_[index] = std::move(trial);
return success();
}
Reply Bus::burst(Arg id, const std::vector<Arg>& values)
{
if (!valid_id(id)) {
return error("ID");
}
if (values.size() > 16) {
return error("COUNT");
}
for (Arg value : values) {
if (!valid_word(value)) {
return error("WORD");
}
}
if (values.empty()) {
return success();
}
const auto index = static_cast<std::size_t>(id);
const Device& current = devices_[index];
std::string permission = data_permission(current);
if (permission != "OK") {
return error(permission);
}
const std::size_t available = 16 - current.fifo.size();
if (values.size() > available) {
return error("FULL");
}
Device trial = current;
for (Arg value : values) {
const auto word = static_cast<Word>(value);
std::string status = apply(trial, 3, word);
if (status != "OK") {
return error(status);
}
}
devices_[index] = std::move(trial);
return success();
}
Reply Bus::drain(Arg id, Arg count)
{
if (!valid_id(id)) {
return error("ID");
}
if (!valid_count(count, 16)) {
return error("COUNT");
}
if (count == 0) {
return success();
}
const auto index = static_cast<std::size_t>(id);
const auto length = static_cast<std::size_t>(count);
const Device& current = devices_[index];
std::string permission = data_permission(current);
if (permission != "OK") {
return error(permission);
}
if (length > current.fifo.size()) {
return error("SHORT");
}
Device trial = current;
Reply reply = success();
reply.values.reserve(length);
for (std::size_t offset = 0; offset < length; ++offset) {
reply.values.push_back(trial.fifo.front());
trial.fifo.pop_front();
}
devices_[index] = std::move(trial);
return reply;
}
}