The language includes the integer and fixed-point register class templates of Algorithmic C [algc], which may be instantiated as follows:
typedef ac_int<96,false> ui96; typedef ac_int<48,true> si48; typedef ac_fixed<64,4,false> uf64i4; typedef ac_fixed<32,16,false> uf32i16;
A register is associated with two values, a raw value, which is a bit vector of the same width as the register, and an integer or rational interpreted value. The interpreted value is derived from the raw value according to the register's type as follows:
The Algorithmic C register types include a "bit select" operator and "bit slice" methods. Bit selection is independent of the register type (signed vs. unsigned, integer vsfixed-point) and uses the familiar syntax. Thus, a bit of a register may be extracted or assigned in the natural way. The syntax of bit slices is less straightforward. The slice extraction method slc requires a constant template parameter indicating the width of the slice and a variable argument that represents the base index. Thus,
x.slc<4>(n)determines the slice of x of width 4 based at bit n, which the pretty-printer renders as
x[n+3,n].The value of this method is an integer register (independent of whether the register is integer or fixed-point) with ther same width parameter as the method and the same sign parameter as the operand. Thus, the numerical value of a slice is a signed or unsigned integer according to the type of the register from which it is extracted.
A bit slice is modified by a method of two arguments, the base index and an integer register containing the value to be written. The width of the slice is not specified explicitly, but rather is inferred from the type of the second argument. For example, the assignment
x.set_slc(n, ui4(6))replaces the slice of x of width 4 based at index n with the value 6 (binary 0110), and is pretty-printed as
x[n+3:n] = 6.
David Russinoff 2017-08-01