Commit a1e2484
Moritz Scherer
[ImportVerilog][Moore] Add real-to-int & int-to-real operators
This commit introduces explicit conversion operations between real and integer types in the Moore dialect, following IEEE 1800-2023 §6.24.1 *Cast operator* and §6.12 *Real, shortreal and realtime data types*.
It also extends VerilogImport to recognize and materialize these conversions during AST translation.
- **Dialect (`MooreOps.td`)**
- Added `RealToIntOp` for rounding real/shortreal values to two-valued integers.
- Added `IntToRealOp` for widening integer values to real/shortreal.
- Both ops marked `Pure` with explicit assembly formats.
- **Import logic (`Expressions.cpp`)**
- Added conversion handling in `Context::materializeConversion`:
- `RealType` -> `IntType` -> `RealToIntOp`
- `IntType` -> `RealType` -> `IntToRealOp`
- **Tests**
- **SystemVerilog import**
- Added `basic.sv` tests verifying correct lowering of `real'(expr)` and `int'(expr)` casts for all real/int width combinations (`f32/i32`, `f64/i64`).
- Updated `builtins.sv` to expect `moore.int_to_real` instead of a generic `conversion` op.
- **Dialect MLIR**
- Added `basic.mlir` tests ensuring proper parsing/printing and type mapping for 32- and 64-bit conversions.1 parent a570dbf commit a1e2484
File tree
5 files changed
+111
-1
lines changed- include/circt/Dialect/Moore
- lib/Conversion/ImportVerilog
- test
- Conversion/ImportVerilog
- Dialect/Moore
5 files changed
+111
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
703 | 703 | | |
704 | 704 | | |
705 | 705 | | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
706 | 737 | | |
707 | 738 | | |
708 | 739 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1757 | 1757 | | |
1758 | 1758 | | |
1759 | 1759 | | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
1760 | 1785 | | |
1761 | 1786 | | |
1762 | 1787 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3308 | 3308 | | |
3309 | 3309 | | |
3310 | 3310 | | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
0 commit comments