Al(Ga) surface mesh analysis pipeline#1
Open
mikanystrom wants to merge 193 commits into
Open
Conversation
Source fixes for building and running m3utils on ARM64_DARWIN: - m3arch.sh: Add ARM64_DARWIN detection for arm64 Darwin - xmlParser.c: Use <expat.h> instead of hardcoded /usr/local path (include path provided via SYSTEM_CC flags in CM3 config) - MpfrC.c: Use <stdlib.h> instead of <malloc.h> on macOS - trstlp.c: Suppress unused variable warning on f2c-generated iout - mk_inputs.sh: Use m3arch.sh for platform detection, GNU sed for \U uppercase, cc -E -P -x c instead of cpp for .ee preprocessing - compat.c: Shims for drem() and gamma() missing on macOS - m3makefile: Link compat.c into diesplit - reports.scm: Fix params format to include n (layer count) as third element, matching report-yields-for-params expectations - run.scm: Work around Polynomial.LaTeXFmt nil dereference in Mpfr.FormatInt on ARM64_DARWIN by skipping LaTeX formatting - uncensor.sh: Script to generate .scm files from .CENSORED versions with plausible dummy values for proprietary constants - yield.scm, defs-21ww07.scm, reports-21ww38.scm: Generated uncensored files with placeholder values Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Step-by-step HOWTO for building CM3 and m3utils on Apple Silicon macOS, documenting all fixes and workarounds discovered during the port. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add BUILDING_CSP_EXAMPLES.md documenting how to compile and run
the CSP examples on ARM64_DARWIN, including the stack size fix
needed for complex processes (patching cspc's Mach-O LC_MAIN
stacksize to 4GB to work around macOS's 64MB hard ulimit).
Remove c_source("compat") from diesplit m3makefile since the
drem/gamma shims were moved to libm3's MathPosixC.c.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- bin/macho-set-stacksize: Python script to patch LC_MAIN.stacksize in Mach-O binaries, bypassing the Apple linker's 512 MB arm64 limit (default: 8 GB) - csp/src/m3makefile: post-link step runs macho-set-stacksize on cspc automatically on Darwin - csp/src/BUILDING_CSP_EXAMPLES.md: updated to document the automated stack fix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements an LR(1) parser for the CSP language using the caltech-parser (parserlib) framework, following the rdlparse pattern. Phase 1 performs syntax checking only; Phase 2 will add S-expression generation for cspc. Key design decisions: - >> lexed as single T_RSHIFT token (avoids LR(1) shift-reduce conflict between greater-than and right-shift; nested loop closers need > > spacing) - Precedence declarations resolve bset/bclr (+/-) vs arithmetic ambiguity: kyacc defaults to reduce on shift-reduce conflicts (opposite of yacc), so explicit %left/%right on rule names controls the resolution - Statement disambiguation by LR(1) lookahead after lvalue (no syntactic predicates needed) Includes 116-test suite covering all CSP language features from the reference manual. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement --scm flag for S-expression output compatible with cspc's loaddata! function, and --name flag for cell name override. All 85+ grammar rule actions in cspParseExt.e now build S-expression TEXT strings using direct emission (no CspGrammar/SchemeObject dependency). Add comprehensive user manual with CSP language reference and S-expression format documentation, plus a pandoc-based Makefile for PDF/LaTeX generation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a Scheme library that parses .sys files describing systems of communicating CSP processes, runs cspfe to produce .scm intermediate files, patches cellinfo with channel port definitions, writes .procs files, and drives the full compilation pipeline through drive! and cm3. Includes tokenizer, recursive descent parser, semantic validator, cellinfo construction/patching, .procs generation, and build orchestrator. Loaded into cspc after setup.scm. Usage: (build-system! "hello.sys") Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Documents the .sys file format (channels, processes, ports, instances), the build-system! Scheme procedure and its options, the build pipeline, and includes two worked examples (hello world, producer-consumer). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 26 test cases for the .sys system description format: 10 parse-only tests, 8 full-build tests, and 8 error-detection tests, plus shared .csp source files and an automated runner script. Update .gitignore to exclude generated PDF/TEX and build/ directories. Update BUILDING_CSP_EXAMPLES.md with revised stack size notes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace begin/end with %[% %]% as the inline body delimiter in .sys files. The sequence %[% cannot appear in legal CSP, so the tokenizer reads the body as raw text (tracking string literals to avoid false matches on %]% inside strings) and passes it to cspfe verbatim. This eliminates the lossy tokenize-then-reconstruct round-trip that broke multi-character CSP operators and required fragile spacing heuristics. The tokenizer is simplified to only handle .sys syntax. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a build-system! section to BUILDING_CSP_EXAMPLES.md covering the .sys file format, %[% %]% inline body syntax, and three examples (hello world, producer-consumer, Collatz sequence). Add build_collatz.sys to the test suite (26 tests, all passing). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Detailed plan for building a SystemVerilog synthesis-subset parser using CM3 parserlib (LR(1)), targeting ASIC design automation tasks including linting, elaboration, and gate-level decomposition. Three phases: core RTL, extended synthesis constructs, Scheme-based analysis. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
LR(1) parser built on CM3 parserlib supporting the SystemVerilog synthesis subset: modules, packages, interfaces with modports, always_ff/comb/latch, if/case/for/generate, typedef/enum/struct, functions/tasks, full expression hierarchy, module instantiation with named/implicit/positional ports, and compiler directives. Produces S-expression output for downstream Scheme processing. Tested on ~1100 lines of real ASIC SystemVerilog (sim1588). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…, directives in statements - Add interface/endinterface with modport declarations - Add interface port types in module port lists (axi_if.slave s) - Move logic/reg/integer into data_type for broader usage (parameters, function returns) - Add implicit named port connections (.name without parentheses) - Allow compiler directives inside statements, function/task bodies - Add module-level import declarations (before port list) - Support prefix increment/decrement in for/generate loops Tested on sim1588 RTL plus FIFO, arbiter, and interface test cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add sv/src/svread.scm: Scheme-based lint analysis for svfe output - Reads S-expression AST from svfe --scm - Collects port signals, local declarations, assignments - Detects undriven outputs - Reports signal counts per module - Works with mscheme interpreter - Fix member access in S-expressions: use (field ...) instead of (. ...) to avoid conflict with Scheme dotted pair notation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Detect blocking assigns in always_ff and non-blocking assigns in always_comb - two of the most common RTL coding errors. Also fix begin block traversal to handle optional block names. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Thorough inline documentation for all svread.scm functions with S-expression format reference and usage examples - Add sv/doc/svfe-manual.txt covering build, usage, supported constructs, S-expression format, and lint checks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…arkdown manual - Split monolithic svread.scm into svbase.scm (AST navigation), svlint.scm (lint checks), svgen.scm (SV code generation) - Add svsynth: mscheme extended with BDD primitives for logic synthesis (BDDPrims.m3 wraps the CM3 BDD library as Scheme primitives) - Add svsynth.scm: Scheme-side synthesis driver that builds BDDs from combinational always_comb/assign blocks - Convert user manual to markdown with Makefile for pandoc/LaTeX PDF Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>= as statement forms - Add ++/-- (pre and post) as statement forms - Add port_direction packed_dim_list port_ident rule for ports like "input [7:0] data" without explicit type keyword (implies logic) - Tested on 8 open-source SV files: 6/8 pass (remaining 2 need type casting and procedural-block local declarations) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add ' as char token and cast rule: type'(expr) parsed as (cast type expr) - Allow net_declaration inside begin/end blocks (e.g., integer i;) - All 8 open-source stress test files now parse successfully Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Parser: 19/27 open-source SV files now parse (up from 3/25)
- Add inside operator (set membership + case inside)
- Add unsigned/signed cast expressions
- Add struct literals and assignment patterns ('{...})
- Add Verilog-2001 attributes (* ... *)
- Add assert statements (simple immediate assertions)
- Add case inside with value ranges ([lo:hi])
- Add user-defined types in struct members, ports, wire/net declarations
- Add int port type, interface ports without direction
- Add automatic variable declarations in procedural blocks
- Add parameter/localparam with user-defined types (deferred-decision parsing)
- Add generate-if/for in module body, begin blocks
- Add type keyword, endmodule/endpackage/endinterface labels
- Allow optional space in sized numeric literals
- Handle bare semicolons at top level
Verification: add svverify.scm (exhaustive simulation), svfec.scm (formal
equivalence checking via BDD comparison), fix BDD wire cache in svgates.scm.
Add 12 test designs with gate netlists, iverilog testbenches, and cells.v.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…and localparam in blocks - # delay expressions as statements (#10; #500 clk = ~clk;) - @(sensitivity) event control as statements - real and time data types - Float number literals (0.001, 0.000001) - localparam/parameter declarations inside begin/end blocks - System task calls ($info, etc.) in generate blocks - case/casez/casex at module body level - Test suite: 32/32 pass Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create sv/src/svpp.py: standalone SystemVerilog preprocessor handling `define (with parameters), `undef, `ifdef/`ifndef/`elsif/`else/`endif, `include, and `timescale. Line numbers preserved for error messages. - Remove T_DIRECTIVE grammar rules from parser (description, package_item, module_item, statement, function_body_item, task_body_item, interface_item) - Add signed_dims/unsigned_dims port declarations - Fix missing preinc/predec actions in for_step (was causing segfault due to NIL .val in TextCat.Concat) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Handle (port dir name (id)) format where the signal name is a bare symbol preceding an empty (id) form. This occurs when a port has no explicit type keyword (e.g., "input a" without "logic" or user type). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These files contain template placeholders (e.g., **PROLOG**), not valid SystemVerilog. Renaming prevents them from being picked up by SV tooling. Updated all references in Main.m3 and shell scripts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
128 assign statements in ecc/src.good/test0.sv were missing trailing semicolons (bug in the code generator that produced this file). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Escaped identifiers: \name.with.dots now lexed as T_IDENT - Wire port declarations: "wire vcc" in port lists (no direction prefix) - Fix assert/else: remove empty alternative from opt_assert_else to resolve shift/reduce conflict with enclosing if/else (kyacc prefers REDUCE, which incorrectly consumed the else for the if instead of the assert) Test suite: 47/47 local files pass, 34/34 RISC-V core files pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
svfe --scm: header comment (;; Command/CWD/Date) + pretty-printed S-expression AST with indentation (string-aware). svpp: single-line /* svpp: ... */ comment + `line resync to preserve downstream line numbers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Much cleaner than breaking at every paren. One line per SV source line, indented by nesting depth. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously only module-level items got (@ N ...) line wrappers. Now statements inside always_comb/always_ff/begin blocks do too, so the pretty-printer produces one indented line per source line. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tty-printer Consistent with statement_list: all structural components get (@ line) annotations via the grammar, not special-cased in the pretty-printer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace Intel-internal build infrastructure (ToolConfig.pl, MODEL_ROOT env var, NEBULON) with paths derived from directory layout; `make top` generates .top standalone - Comment out Intel GCC SYSTEM_LD path in m3overrides - Replace removed BigInt.Zero/One/Two with BigInt.New(0/1/2) - Rename TextUtils -> CitTextUtils (interface was renamed in cm3) - Lazy-init props arrays in RegScala.m3 and RegModula3.m3 to work around cm3 C backend type-cell registration bug during module init - Handle sw/hw as keyword properties in GenViews.mg (raw RDL stores them as keywords, not strings as in preprocessed RDL) - Add ARM64_DARWIN to .gitignore for genviews and wm_support build dirs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Five M3 libraries and two programs for analyzing LEXT confocal
microscope surface data of Al(Ga) alloy samples:
plylib — binary PLY reader (float + uchar properties, triangles)
meshlib — Vec3 ops, TriMesh (normals, areas, adjacency, globals)
facetlib — plane fitting, Rodrigues rotation to z-up, height field
extraction, region-growing segmentation with PQueue seed
selection and vertical-angle filtering
curvlib — cotangent-Laplacian mean curvature (1/length units),
quadratic residual fitting, anomaly detection,
height field gridding with aspect-ratio-matched cells,
Gaussian multiresolution smoothing, band-pass decomposition
plydemo — end-to-end demo: single-face analysis, segmentation of
full surface scans, multiresolution contour output with
curvature/residual/anomaly/spectral-band data files and
gnuplot scripts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
11-page LaTeX report covering: - Data format and instrument description (Olympus LEXT confocal) - Pipeline architecture (5 libraries, 2 programs) - Algorithms: plane fitting, Rodrigues rotation, cotangent-Laplacian curvature, quadratic residual fitting, anomaly detection, region-growing segmentation, Gaussian multiresolution decomposition - Results: automatic segmentation (9 regions from 1M-vertex scan), per-region curvature statistics, curvature+anomaly overlay, spectral band-pass decomposition - Usage examples and future work Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the barycentric 1/3 area approximation with the proper mixed Voronoi area (Meyer, Desbrun, Schroeder, Barr 2003): non-obtuse triangles get true Voronoi regions; obtuse triangles give half to the obtuse vertex, quarter each to the others. Prevents spurious curvature spikes at obtuse triangles. Regenerated all 38 atlas figures and updated the report (now 16 pages). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add plylib, meshlib, facetlib, curvlib to SHIPDIRS and plydemo, plytest to M3SUBS in the top-level Makefile. Add override entries for all four libraries in m3overrides. Builds cleanly with make std (CM3=yes RTA_CM3_HOME=/path/to/cm3/install). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per-package m3overrides now include the top-level m3overrides directly, instead of going through an intermediate Al_Ga/m3overrides that duplicated the same entries. Removes all "package already overridden" warnings during build. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4765757 to
f91b1d0
Compare
- Atlas images now use per-image center environments allowing
natural page breaks between faces
- PNG dimensions match data aspect ratio with set size ratio -1
so equal x/y scale is preserved without squashing
- Standalone figures use [p] placement with height caps
- Fix orphaned \begin{center} from earlier sed edits
- Fix Nystrom -> Nyström throughout
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gen-atlas.sh generates all 38 curvature atlas PNGs from PLY data. Computes a common tick interval from the larger axis range so x and y ticks are at identical spacing, matching the equal-scale plot area. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Toy C++ class hierarchy (Shape, Circle, Rectangle, ShapeList) with a three-layer binding: C++ library, extern "C" bridge, idiomatic M3. Demonstrates five key interop patterns: 1. Object lifetime: WeakRef cleaners call C++ destructors on GC 2. Ownership transfer: owned flag suppresses double-free 3. String marshaling: malloc'd char* -> TEXT -> free() 4. Callbacks: trampoline + LOOPHOLE for closure-to-function-pointer 5. Exception bridging: C++ catch -> error code -> M3 RAISES 6-page LaTeX design notes analyzing each pattern and discussing generalization to real C++ libraries (Open3D, Eigen, CGAL). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All public interfaces now have formal requires/ensures/modifies/
invariant specifications on every procedure. Type invariants are
documented at the type level.
Added references to:
- Meyer, Desbrun, Schroeder, Barr (2003) — cotangent Laplacian
and mixed Voronoi area
- Desbrun, Meyer, Schroeder, Barr (1999) — cotangent weights
- Rodrigues (1840) — rotation formula
- Burt and Adelson (1983) — Laplacian pyramid
- Max (1999) — vertex normal weights
- Rabbani, van den Heuvel, Vosselman (2006) — region growing
- Turk (1994) — PLY file format
Implementation files have header comments summarizing the algorithms
and their sources.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- plylib: add ASCII PLY format support (format ascii 1.0) - plydemo: add -scale parameter for coordinate unit conversion (default 0.001 for old data; use 100 for May 17 data) - 5-page addendum report with curvature atlas for 5 new faces Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The cotangent Laplacian of the height field z gives the discrete Laplacian (nabla^2 z = 2H), not mean curvature H directly. The normalization was dividing by 2A (giving 2H) instead of 4A (giving H). All curvature values were 2x too high. Found by analytic validation: synthetic sphere (R=1000, 5000) and paraboloid (a=0.0001, 0.001) now return H correct to 4+ significant figures. Dimensional analysis on real Face 4 also consistent. Regenerated all 38+5 atlas figures and both report PDFs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2-page LaTeX note explaining the bug (dividing by 2A instead of 4A), the validation (4 analytic tests + dimensional cross-check), and the impact (absolute scale wrong by 2x, relative patterns unaffected). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generates synthetic PLY meshes (sphere caps, paraboloids) with known analytic curvature for validating the pipeline. Used to find and verify the factor-of-2 curvature fix. Usage: genply sphere <R> <n> — hemisphere cap, H = 1/R genply paraboloid <a> <extent> <step> — z = a(x^2+y^2), H(0) = 2a Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Face extents are tens of microns, not millimeters. The _100 versions use scale 0.00001 for old data (was 0.001) and scale 1.0 for new data (was 100). Curvature color scale ±300 /mm (was ±3 /mm). The original-scale reports are preserved for comparison. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Date updated to May 26, 2026
- Add Claude as co-author
- Fix "native coordinates are in nanometers" -> instrument-specific
- Fix "binary PLY" -> "binary or ASCII PLY" throughout
- Fix curvature formula: 1/(2A) -> 1/(4A) with explanation
- Fix unit conversion paragraph to use -scale parameter
- Fix results table: divide height/residual values by 100
- Fix prose: 152 um -> 1.52 um, 182 um -> 1.82 um, etc.
- Fix spectral text: 500 um -> 5 um, 5 um -> 0.05 um
- Fix curvature caption: radius 500 um -> 5 um
- Fix build system: describe top-level m3overrides inclusion
- Add -scale parameter to all usage examples
- Add \label{sec:usage} for cross-reference from data section
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
🤖 Generated with Claude Code