One user-space repair task per eligible HWE debug-diag / compile-deploy base ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content filter. Each ships a public spec with a check-to-basis table, at least two defects with single-fix fixtures, a symptom-masking fixture and an alternative correct implementation. Claude re-checked all 320: structure, the HWE quality items and trace6 Docker calibration receipts against current digests (320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120 ad-hoc family names; the next batch maps them to the canonical list. The batch's 1,256-line progress log stays in its factory report and the 36-local branch batch15-hwe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
157 lines
4.3 KiB
C++
157 lines
4.3 KiB
C++
#include "progress.hpp"
|
|
#include <ostream>
|
|
#include <stdexcept>
|
|
namespace progress {
|
|
std::uint32_t ProgressRegister::read() const volatile {
|
|
return device_->read(lane_);
|
|
}
|
|
void ProgressRegister::write(std::uint32_t value) volatile {
|
|
device_->write(lane_, value);
|
|
}
|
|
Device::Device(const Plan& plan, std::ostream& output)
|
|
: output_(output), lanes_(plan.lanes), modulus_(plan.modulus) {
|
|
for (std::uint32_t lane = 0; lane < lanes_; ++lane) {
|
|
ports_[lane].device_ = this;
|
|
ports_[lane].lane_ = lane;
|
|
bus_[lane].value = plan.initial[lane];
|
|
}
|
|
event_prefix("CONFIG");
|
|
field(lanes_);
|
|
field(modulus_);
|
|
finish_event();
|
|
}
|
|
void Device::event_prefix(const char* kind) {
|
|
output_ << kind;
|
|
field(sequence_);
|
|
++sequence_;
|
|
}
|
|
void Device::field(std::uint32_t value) {
|
|
output_ << ' ' << value;
|
|
}
|
|
void Device::finish_event() {
|
|
output_ << '\n';
|
|
}
|
|
volatile ProgressRegister& Device::port(std::uint32_t lane) {
|
|
if (lane >= lanes_) {
|
|
throw std::out_of_range("port lane");
|
|
}
|
|
return ports_[lane];
|
|
}
|
|
std::uint32_t Device::read(std::uint32_t lane) {
|
|
if (lane >= lanes_) {
|
|
throw std::out_of_range("read lane");
|
|
}
|
|
BusState& state = bus_[lane];
|
|
++state.reads;
|
|
state.audit = (state.audit * 17ULL + state.value + 1) % digest_mod;
|
|
event_prefix("READ");
|
|
field(lane);
|
|
field(state.value);
|
|
field(state.reads);
|
|
field(state.audit);
|
|
finish_event();
|
|
return state.value;
|
|
}
|
|
void Device::write(std::uint32_t lane, std::uint32_t value) {
|
|
if (lane >= lanes_ || value >= modulus_) {
|
|
throw std::out_of_range("write domain");
|
|
}
|
|
BusState& state = bus_[lane];
|
|
const std::uint32_t previous = state.value;
|
|
state.value = value;
|
|
++state.writes;
|
|
state.audit = (state.audit * 19ULL + value + 3) % digest_mod;
|
|
event_prefix("WRITE");
|
|
field(lane);
|
|
field(previous);
|
|
field(value);
|
|
field(state.writes);
|
|
field(state.audit);
|
|
finish_event();
|
|
}
|
|
void Device::begin(std::uint32_t job, const Job& descriptor) {
|
|
if (active_) {
|
|
throw std::logic_error("nested job");
|
|
}
|
|
if (descriptor.lane >= lanes_) {
|
|
throw std::out_of_range("begin lane");
|
|
}
|
|
active_ = true;
|
|
active_job_ = job;
|
|
active_lane_ = descriptor.lane;
|
|
event_prefix("BEGIN");
|
|
field(job);
|
|
field(descriptor.lane);
|
|
field(descriptor.units);
|
|
finish_event();
|
|
}
|
|
void Device::checkpoint(std::uint32_t job, std::uint32_t unit,
|
|
std::uint32_t lane, std::uint32_t word, std::uint32_t digest) {
|
|
if (!active_ || job != active_job_ || lane != active_lane_) {
|
|
throw std::logic_error("checkpoint scope");
|
|
}
|
|
BusState& state = bus_[lane];
|
|
++state.latches;
|
|
state.audit = (state.audit * 23ULL + state.value + word + digest) % digest_mod;
|
|
event_prefix("CHECKPOINT");
|
|
field(job);
|
|
field(unit);
|
|
field(lane);
|
|
field(state.value);
|
|
field(word);
|
|
field(digest);
|
|
field(state.latches);
|
|
field(state.audit);
|
|
finish_event();
|
|
}
|
|
void Device::end(std::uint32_t job, std::uint32_t lane, const Statistics& statistics) {
|
|
if (!active_ || job != active_job_ || lane != active_lane_) {
|
|
throw std::logic_error("end scope");
|
|
}
|
|
event_prefix("END");
|
|
field(job);
|
|
field(lane);
|
|
field(statistics.units);
|
|
field(statistics.digest);
|
|
finish_event();
|
|
active_ = false;
|
|
}
|
|
void Device::certificate(const std::vector<std::uint8_t>& bytes) {
|
|
for (std::uint8_t byte : bytes) {
|
|
receiver_.consume(byte);
|
|
}
|
|
event_prefix("CERTIFICATE");
|
|
field(bytes.size());
|
|
for (std::uint8_t byte : bytes) {
|
|
field(byte);
|
|
}
|
|
const Certificate& decoded = receiver_.last();
|
|
field(decoded.job);
|
|
field(decoded.unit);
|
|
field(decoded.lane);
|
|
field(decoded.word);
|
|
field(decoded.digest);
|
|
field(receiver_.bytes());
|
|
field(receiver_.accepted());
|
|
field(receiver_.rejected());
|
|
field(receiver_.audit());
|
|
finish_event();
|
|
}
|
|
void Device::dump() {
|
|
for (std::uint32_t lane = 0; lane < lanes_; ++lane) {
|
|
const BusState& state = bus_[lane];
|
|
event_prefix("BUS");
|
|
field(lane);
|
|
field(state.value);
|
|
field(state.reads);
|
|
field(state.writes);
|
|
field(state.latches);
|
|
field(state.audit);
|
|
finish_event();
|
|
}
|
|
event_prefix("IDLE");
|
|
field(active_ ? 0 : 1);
|
|
finish_event();
|
|
}
|
|
}
|