Int
Int(width) is a subtype of Bits(width) (Int(w) <: Bits(w)) that adds integer arithmetic, unsigned comparisons, signed comparisons, and sign extension.
Constructor & Constants
Int(width: UInt)— requireswidth >= 0(Z3-checked).Int(0)is valid.Int(w).width— evaluates tow: UInt.- Sized constants:
value#width(decimal or hexadecimal0x...#width, including0#0) constructs aConstant-timedInt(width). Ifvalueexceedswidthbits (or cannot be proved to fit in a symbolicwidth), Neo rejects it with atruncated_constant/possible_truncated_constanterror. - Bare
0/1: Coerce toInt(1)whenInt(1)is expected. - From
UInt:n.toInt(w)constructs anInt(w)constant. - From
Bits(w):b.asInt()convertsBits(w)toInt(w).
Operators
Int(w) supports all Bits(w) operators (&, |, ^, ~, !, reduction &/|/^, &&/|| for width 1, ==, !=, <<, >> logical right shift, >>> arithmetic right shift, ##, and {...} bit selection) plus:
| Operator | Operands | Result Type | Semantics |
|---|---|---|---|
+, -, *, /, % | Equal-width Int(w) | Int(w) | Wrapping / truncated arithmetic (result width matches operand width) |
<, <=, >, >= | Equal-width Int(w) | Bits(1) | Unsigned integer comparisons |
Note on bit selection: selecting more than 1 bit from an Int produces Int(res_w), while selecting a single bit produces Bits(1).
Methods
Int(w) supports all Bits(w) methods (.asInt(), .zextend(w2) -> Int(w2), .repeat(n) -> Int(w * n), .castTo(T)) plus:
x.sextend(w2: UInt)->Int(w2): Sign-extendsxto widthw2(Z3 verifiesw >= 1andw2 >= w).x.slt(other: Int(w))->Bits(1): Signed less-than comparison ($signed(x) < $signed(other)). Requiresw >= 1.x.slte(other: Int(w))->Bits(1): Signed less-than-or-equal comparison. Requiresw >= 1.x.sgt(other: Int(w))->Bits(1): Signed greater-than comparison. Requiresw >= 1.x.sgte(other: Int(w))->Bits(1): Signed greater-than-or-equal comparison. Requiresw >= 1.
All comparison methods join the timings of x and other via LUB.