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

6.4 KiB

Peripheral service contract

State and values

clockmodel::Bus starts with eight devices numbered 0 through 7. Every device has four unsigned 32-bit register words, a FIFO of at most 16 words, and a chronological audit of at most 32 successful register writes. All state starts at zero or empty. Separate Bus objects and different device IDs have independent state, including when their operations are interleaved.

Arg is signed 64-bit. IDs are 0 through 7, register numbers are 0 through 3, and word arguments are 0 through 4294967295. FIFO counts are 0 through 16 and history counts are 0 through 32. Values outside a parameter's domain return the status described below without conversion to a narrower type. Register 0 is clock_en, 1 is reset_n, 2 is enable, and 3 is data. Only bit 0 of each of the first three register words represents its functional gate; all other bits are retained as ordinary word contents.

A Reply has a status string and a vector of unsigned 32-bit values. An error has an empty vector. Every failed operation preserves all registers, FIFO words, and audit entries of every device. Successful operations only affect their selected device. No method writes stdout or stderr.

Register operations

Reply read(Arg id, Arg reg) const checks id then reg, returning ID or REG respectively. It returns OK with the selected raw register word and does not require any gate.

Reply write(Arg id, Arg reg, Arg value) checks id, reg, then value, returning ID, REG, or WORD. A clock write stores its word and leaves every other register and the FIFO unchanged.

A reset_n write whose bit 0 is one requires the clock gate and otherwise returns CLOCK. A reset_n write whose bit 0 is zero stores its word, clears bit 0 of enable, sets data to zero, and empties the FIFO; the other enable bits remain. It is allowed with the clock gate closed.

An enable write whose bit 0 is one requires clock then reset_n and returns CLOCK or RESET when the corresponding gate is closed. An enable write whose bit 0 is zero is allowed with any gates. Other registers and the FIFO remain unchanged for an enable write.

A data write checks clock, reset_n, then enable and returns CLOCK, RESET, or ENABLE if the corresponding gate is closed. It then returns FULL when the FIFO has 16 words. Otherwise it stores the data word and appends that word to the FIFO.

Each successful register write appends the pair (register number, requested word) to the audit, including repeated values and reset side effects represented by the requested reset write alone. When the audit would exceed 32 entries its oldest entry is discarded. Register writes return OK with no values.

Composite operations

Reply configure(Arg id, Arg clock, Arg reset, Arg enable, Arg data) checks id, then the four word domains from left to right. It then checks bit 0 of clock, reset, and enable, returning CLOCK, RESET, or ENABLE at the first closed requested gate. It applies the following register writes as one transaction: reset_n=0, clock_en=clock, reset_n=reset, enable=enable, data=data. It retains the existing audit and adds those five entries using the audit capacity rule. The reset step empties the previous FIFO and the final FIFO contains just data. Success returns OK with no values, including on repeated configuration.

Reply burst(Arg id, const std::vector<Arg>& values) checks id, vector length, then every word from left to right. It returns ID, COUNT for a length over 16, or WORD. An empty vector returns OK without gate checks or changes. A nonempty vector checks clock, reset_n, and enable in that order, then checks that the entire vector fits in the remaining FIFO capacity, returning CLOCK, RESET, ENABLE, or FULL. It applies the data writes in vector order as one transaction and returns OK with no values.

Reply drain(Arg id, Arg count) checks id then count, returning ID or COUNT. A zero count returns OK with no values and no gate checks or changes. A positive count checks clock, reset_n, then enable and returns CLOCK, RESET, or ENABLE. It returns SHORT if fewer than count FIFO words are available. Otherwise it removes and returns the oldest count words in order. It does not change registers or audit.

Inspection and clearing

Reply snapshot(Arg id) const returns ID for an invalid id. Otherwise it returns OK and the four raw register words, the FIFO length, and all FIFO words oldest first. It makes no changes and does not require gates.

Reply history(Arg id, Arg count) const checks id then count, returning ID or COUNT. It returns OK and the newest min(count, available entries) audit entries in chronological order, flattened as reg,value,reg,value. A zero count returns an empty vector. It makes no changes and does not require gates.

Reply clear(Arg id) returns ID for an invalid id. Otherwise it resets that device's registers to zero and empties its FIFO and audit, returns OK with no values, and requires no gates. Repeating clear succeeds.

Text interface

Reply command(Bus& first, Bus& second, const std::string& line) selects first with token a and second with b. The remaining tokens are one of read id reg, write id reg value, configure id clock reset enable data, burst id followed by zero or more words, drain id count, snapshot id, history id count, or clear id. It calls the matching Bus method and returns its reply. Tokens are separated by one or more ASCII spaces or tabs; leading and trailing spaces or tabs are allowed. Decimal integer tokens have an optional leading minus and one or more digits and must fit Arg; leading zeroes are allowed. A leading plus is not accepted.

Unknown selection, unknown verb, missing or extra fixed arguments, a malformed decimal token, or a token outside signed 64-bit range returns SYNTAX without calling a Bus method. Empty or whitespace-only lines return SYNTAX. Lines contain printable ASCII, spaces, or tabs and are at most 1024 bytes. A stream contains 0 through 4096 lines; the final line may omit its linefeed.

std::string encode(const Reply& reply) returns status, one ASCII space, the decimal vector length, then each value preceded by one space, followed by one linefeed. It has no other output or side effects. Decimal fields have no sign or leading zeroes except zero itself. The demo returns exit code 0, writes one encoded reply for each input line in order, and writes no stderr. Empty input produces zero stdout bytes. Evaluation also calls each Bus method directly through an observer using its original arguments.