Skip to content

feat(clara-gap10): audit_log_ring_buffer — 64-entry inference event ring buffer - #66

Merged
gHashTag merged 3 commits into
mainfrom
feat/clara-gap10-audit-log
May 16, 2026
Merged

gHashTag merged 3 commits into
mainfrom
feat/clara-gap10-audit-log

Conversation

@gHashTag

Copy link
Copy Markdown
Collaborator

CLARA Gap-10 — audit_log_ring_buffer

Summary

Implements a 64-entry circular ring buffer for on-chip inference event logging (CLARA Gap-10).

Entry Format (48 bits)

bits [47:32] = timestamp[15:0]   — free-running 16-bit timestamp
bits [31:28] = event_type[3:0]   — event class (0..15)
bits [27:0]  = data[27:0]        — inference result / operand payload

Architecture

  • Write port: single-port sequential write; head pointer auto-advances (mod 64); wrapped flag set on first full rotation
  • Read port: rd_en advances rd_ptr through all 64 entries; rd_data provides the 48-bit entry; rd_valid indicates entry validity
  • Status: head_ptr[5:0], wrapped, buf_full, buf_empty, audit_ok
  • uio integration: host dumps all 64 entries by asserting rd_en 64 times and reading rd_data

Files

File Lines Purpose
src/audit_log_ring_buffer.v 151 RTL — ring buffer, Verilog-2005, R-SI-1 clean
test/tb_audit_log_ring_buffer.v 303 Testbench — 5 scenarios, 35 assertions

Verification

iverilog -g2001 -Wall src/audit_log_ring_buffer.v test/tb_audit_log_ring_buffer.v
vvp a.out
=== SUMMARY: 35 PASS, 0 FAIL ===
ALL ASSERTIONS PASS

5 scenarios:

  • S1 — Empty read: buf_empty=1, rd_valid=0, head_ptr=0 after reset
  • S2 — Single write/read: rd_data matches {0xABCD, 0xF, 0x1234567}
  • S3 — Wrap-around at 64: wrapped=1, head_ptr wraps to 0, overwrite verified
  • S4 — Simultaneous wr_en + rd_en: write and read pointer coherent
  • S5 — Reset mid-operation: buffer clears, re-write works correctly

Constraints

  • Pure Verilog-2005 (no logic, typedef, enum, SV constructs)
  • R-SI-1 clean: zero arithmetic * operators in synthesizable code
  • Cell budget: ~400 cells (0.8% of GAMMA 48K tile budget)
  • No external IP (compiles from src/ only)

PhD Anchors

  • Chapter 8 (AGI Driver) — inference event logging for driver accountability
  • Chapter 18 (Audit Chain) — on-chip forensic record keeping
  • Chapter 36 (Holographic) — ring buffer as circular memory primitive
  • DOI: 10.5281/zenodo.19227877

gHashTag and others added 3 commits May 16, 2026 19:19
…ing buffer

CLARA Gap-10: circular ring buffer for on-chip inference event logging.

Ring buffer specs:
- 64 entries × 48 bits each
- Entry format: {timestamp[15:0], event_type[3:0], data[27:0]}
- Head pointer + wrap flag for forensic replay
- Sequential read port (rd_en / rd_data / rd_valid) for offline analysis
- uio-compatible: host can dump all 64 entries via rd_en pulses

Verification:
- iverilog -g2001 compiles clean
- tb_audit_log_ring_buffer.v: 5 scenarios, 35/35 assertions PASS
  S1: empty read
  S2: single write/read with rd_data check
  S3: wrap-around at 64 entries (buf_full, head wraps to 0)
  S4: simultaneous wr_en + rd_en coherence
  S5: reset mid-operation, re-write

Constraints met:
- Pure Verilog-2005 (no SystemVerilog keywords)
- R-SI-1 clean: zero arithmetic * operators in synthesizable code
- Cell budget: ~400 cells (0.8% GAMMA 48K budget)

PhD anchor: Chapter 8 (AGI Driver) + Chapter 18 (Audit Chain)
DOI: 10.5281/zenodo.19227877
- Fix sim/tb_canonical.v: Split 'reg stable = 1' into declaration + assignment
- Fix src/bitnet_encoder.v:
  - Replace indexed part-select x[2*i +: 2] with shift/mask approach
  - Remove size casts (10'(), 16'sd1)
  - Replace indexed part-select y_out[8*j +: 8] with case statement
  - Add newline at end of file

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix src/gf16_popcount.v: Replace a_row[2*k +: 2] with shift/mask
- Fix src/gf16_popcount16.v: Replace a_row[2*k +: 2] with shift/mask
- Fix src/blake3_anchor.v: Replace m_in[32*i +: 32] with shift/mask
- Fix src/vsa_matmul_8x8.v: Replace indexed part-select with intermediate wires and case statement
- Fix src/vsa_matmul_16x16.v: Replace indexed part-select with intermediate wires and case statement

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gHashTag
gHashTag merged commit a1d4dbb into main May 16, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant