Skill v1.0.0
currentAutomated scan100/100name: cpu-microarchitecture-isa-and-mesi description: Model, implement, and verify CPU instruction decoders (x86_64, ARM, RISC-V), pipeline forwarding/stall units, and MESI/MOESI snooping cache coherence protocols enforcing the Single-Writer-Multiple-Reader (SWMR) invariant. allowed-tools: execute_bash view_file write_to_file metadata: version: "1.0.0"
CPU Microarchitecture, ISA Encoding (x86_64, ARM, RISC-V), Pipelining & Cache Coherence
Model, implement, and verify CPU instruction decoders (x86_64, ARM, RISC-V), pipeline forwarding/stall units, and MESI/MOESI snooping cache coherence protocols enforcing the Single-Writer-Multiple-Reader (SWMR) invariant.
A. Identity
- Skill Name:
cpu-microarchitecture-isa-and-mesi - Domain:
computer-architecture - Specialization: Instruction Decoding, 5-Stage/OoO Hazard Forwarding, MESI/MOESI Cache Coherence & Memory Hierarchy
- Version:
1.0.0 - Purpose: Enforce production-grade language semantics, type soundness, memory/resource safety, ABI interoperability, and automated verification.
- Supported Tasks: Architecture design, implementation, memory/concurrency auditing, build/toolchain integration, debugging, and verification.
- Required Knowledge: RISC-V Unprivileged/Privileged ISA, ARMv8-A Manual, SWMR Cache Coherence Invariant
- Dependencies: Host compilers/interpreters (
gcc,g++,as,ld,python3,node,bash,perl,sqlite3) and target CI toolchains. - Compatibility Requirements: Model-agnostic Markdown + progressive disclosure.
B. Activation Criteria
When to Use
- Activate when writing, refactoring, debugging, optimizing, or auditing code in
Instruction Decoding, 5-Stage/OoO Hazard Forwarding, MESI/MOESI Cache Coherence & Memory Hierarchy. - Activate when verifying memory safety, concurrency invariants, build reproducibility, or FFI/ABI boundaries.
Technical Triggers
- RISC-V (
RV32I/RV64GC), ARMv8-A,x86_64, pipeline hazards (RAW, load-use stall), MESI/MOESI cache coherence.
Prerequisites
- Target OS, CPU architecture (
x86_64,AArch64,RISC-V,wasm32), and runtime mode (hosted vs. freestanding).
When NOT to Use
- Do not conflate full programming languages with hardware description languages (HDLs), query languages, or compiler IRs; route each to its exact specialization.
C. Problem Understanding
Execute this 8-step intake protocol before generating code:
- Identify the Engineering Problem: Define the exact functional, latency, and resource requirements.
- Extract Explicit Requirements: Record language version, API signatures, and error-handling contracts.
- Identify Hidden Technical Constraints: Surface integer overflow, aliasing, lifetime/GC pressure, nullability, and concurrency hazards.
- Determine Environmental Limitations: Probe whether the native compiler/runtime is installed in the sandbox or requires target-toolchain verification.
- Identify Applicable Standards: Enforce RISC-V Unprivileged/Privileged ISA, ARMv8-A Manual, SWMR Cache Coherence Invariant.
- Separate Known Facts from Assumptions: Partition verified target platform facts from disclosed assumptions.
- Identify Missing Critical Information: Apply safe, deterministic defaults when non-blocking.
- Establish Measurable Acceptance Criteria: Zero compiler/linter warnings, zero sanitizer/memory traps, and 100% pass across nominal, boundary, and adversarial tests.
D. Technical Reasoning Protocol
Follow UNDERSTAND -> PLAN -> IMPLEMENT -> COMPILE -> TEST -> VERIFY -> REVIEW across the 12 mandatory language dimensions:
- Syntax & Semantics: Never forward writes targeting hardwired-zero registers (
x0in RISC-V,XZRin AArch64), giveEX/MEMpriority overMEM/WBforwarding, and assert the SWMR MESI invariant on every bus transaction. - Type System: Enforce strict static typing, exhaustive pattern/union matching, or runtime schema guards.
- Memory & Resource Management: Guarantee deterministic cleanup (RAII,
defer/errdefer, ownership borrow checking, or context managers). - Standard Library Discipline: Prefer bounds-checked, allocation-explicit standard containers.
- Build & Package Management: Lock dependency hashes and enforce reproducible compiler flags.
- Compiler / Interpreter Invocation: Enable maximum warning and static-analysis gates (
-Wall -Wextra -Werror -Wpedantic -fanalyzer). - Debugging: Preserve frame pointers (
-fno-omit-frame-pointer) and symbol tables (-g) for deterministic stack traces. - Testing: Exercise positive, zero/empty boundary, overflow, and malformed input paths.
- Performance Optimization: Optimize data layout (contiguous arrays/slices) and algorithmic complexity before micro-tuning.
- Security Hardening: Prevent buffer overflows, injection (SQL/shell), and timing side-channels.
- Interoperability (FFI / ABI): Enforce C ABI layout (
#[repr(C)]/extern "C"), alignment, and panic/exception containment across FFI boundaries. - Production Engineering Practices: Document operational invariants, complexity bounds, and verification status (
VERIFIEDvs.PARTIALLY VERIFIED).
E. Verification Protocol
Verification Methods and Test Requirements
Build and run the nominal, boundary, and negative cases with the target toolchain listed under Dependencies (strict warnings, sanitizers/analyzers where available), and record the exact toolchain status.
Failure Conditions, Boundary Cases, and Tolerances
- Failure Conditions: Any compiler error, warning under
-Werror, sanitizer fault, memory leak, or failed unit assertion. - Boundary Cases: Empty/zero-size inputs, maximum type limits (
SIZE_MAX,INT64_MAX,NaN), and resource exhaustion. - Numerical & Semantic Tolerances: Exact integer/state equivalence (
0tolerance) and IEEE 754 relative bounds where applicable. - Safety and Performance Criteria: Deterministic time and space complexity.
- Reproducibility Requirements: Log exact tool versions and distinguish native host execution from target-toolchain CI checks in
validation.md.
Multi-Stage Quality Assurance Workflow
- Stage 1 (Requirement Verification): Confirm language version, ABI, and API contracts.
- Stage 2 (Technical Verification): Audit type soundness, memory lifetimes, and concurrency ordering.
- Stage 3 (Implementation Verification): Compile/execute nominal tests.
- Stage 4 (Edge-Case Verification): Stress-test boundary, overflow, and malformed inputs.
- Stage 5 (Independent Review): Run orthogonal static analysis (
-fanalyzer/ AST audit) or sanitizer checks (ASan/UBSan). - Stage 6 (Final Validation): Classify as
VERIFIED(when native compiler/runtime executed) orPARTIALLY VERIFIED(when target compiler is absent in VM and verified via AST/behavioral model).
Gotchas and Error Detection
Report all language defects using the 6-field schema (Description, Severity, Root Cause, Potential Consequences, Proposed Correction, Verification Procedure):
- Silent Integer Overflow & Truncation: Always guard size multiplications (
count > SIZE_MAX / sizeof(T)) and narrowing casts. - Unchecked FFI Boundary Unwinding: Never allow exceptions or panics to unwind across an
extern "C"ABI boundary.