Skip to content

Add $rtoi/$itor in analog context (VAMS-2023 Mantis 7920) - #24

Merged
sai-v-ch merged 1 commit into
OpenVAF:mobfrom
sai-v-ch:vams2023-rtoi-itor
Aug 1, 2026
Merged

Add $rtoi/$itor in analog context (VAMS-2023 Mantis 7920)#24
sai-v-ch merged 1 commit into
OpenVAF:mobfrom
sai-v-ch:vams2023-rtoi-itor

Conversation

@sai-v-ch

Copy link
Copy Markdown
Collaborator

Summary

  • Implements $rtoi / $itor for the analog context (VAMS-2023 Annex G / Mantis 7920; LRM §9.11). Annex G's $roi() is treated as the $rtoi() typo.
  • $rtoi truncates toward zero per IEEE 1364. It lowers to a new MIR opcode FItrunc and LLVM FPToSI, not the existing language real→integer cast FIcast (which rounds via llvm.lround.i32.f64 / .round()).
  • $itor reuses the existing integer→real IFcast.
  • Wired end-to-end: builtins/sysfuns, type signatures, lowering, const-fold, simplify, interpreter, autodiff (zero derivative), LLVM codegen.
  • Part of the VAMS-2023 alignment tracked in Align with Verilog-AMS VAMS-2023 (Feb 2024): scope analysis and offer to implement #19.

Test plan

  • cargo test -p sourcegen (regenerates builtins/opcodes)
  • MIR snapshot openvaf/test_data/mir/vams2023_rtoi_itor.va shows fitrunc (not ficast)
  • Const-prop unit tests: fitrunc(1.9) folds to 1, while ficast(1.9) folds to 2
  • OSDI compile: cargo test -p osdi --no-default-features --features llvm18 including VAMS2023_RTOI
  • Integration + dlopen: cargo test -p openvaf --no-default-features --features llvm18 --test integration -- VAMS2023_RTOI (with RUN_SLOW_TESTS=1 RUN_DEV_TESTS=1)
  • cargo fmt --all -- --check

Made with Cursor

VAMS-2023 (Mantis 7920) permits IEEE 1364 $rtoi/$itor in analog.
$rtoi truncates toward zero, so it uses a new FItrunc MIR opcode and
LLVM FPToSI instead of the rounding language cast FIcast/lround.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@sai-v-ch
sai-v-ch merged commit 7805671 into OpenVAF:mob Aug 1, 2026
11 checks passed
@sai-v-ch
sai-v-ch deleted the vams2023-rtoi-itor branch August 1, 2026 03:47
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