omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tests / arboris / scoreboard_oracle.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Stdin adapter for the repository's independent C scoreboard oracle. |
| 3 | * Host test only. The program has no device or dispatch interface. */ |
| 4 | #include "omega_bw_hazard.h" |
| 5 | #include "omega_api_decl.h" |
| 6 | #include <stdint.h> |
| 7 | #include <stdio.h> |
| 8 | |
| 9 | int main(void) { |
| 10 | static uint8_t code[32768]; |
| 11 | static uint64_t wire[3203584]; |
| 12 | uint64_t result; |
| 13 | OmegaBwHazardReport report; |
| 14 | size_t size = fread(code, 1, sizeof code, stdin); |
| 15 | if (size == 0 || size == sizeof code || ferror(stdin)) return 2; |
| 16 | if (omega_bw_hazard_check(code, size, &report) != 0) return 2; |
| 17 | if (omega2_hz_chk(&result, code, sizeof code, size, wire, 3203584) != 0 || |
| 18 | result != 0 || wire[0] != report.insns || wire[1] != report.reachable || |
| 19 | wire[2] != report.count) { |
| 20 | fputs("OM-2 and C scoreboards disagree\n", stderr); |
| 21 | return 2; |
| 22 | } |
| 23 | printf("scoreboard: %zu instructions, %zu reachable, %zu hazards\n", |
| 24 | report.insns, report.reachable, report.count); |
| 25 | return report.count != 0; |
| 26 | } |