Chisel data types are used to specify the type of values held in the state elements or flowing on wires. Chisel defines the Bundles for making collection of values with named fields (Similar to Structs in other languages and Vecs for indexable collections of values. There are three data types (which represents the vector of bits) to describe the signals, combinational logic, registers.
- Bits
- UInt (Unsigned Integer)
- SInt (Signed Integer)
UInt and SInt extends the Bits data type. The Chisel uses the two’s complement as signed integer representation. Definition for three data types as follows
Bits (8.W) –> an 8 bit width Bits
UInt (8.W) –> an 8 bit width unsigned Integer
SInt (8.W) –> an 8 bit width Signed Integer
Example:
0.U //defines the Unsigned Integer constant of 0
-3.S // defines the Signed Integer constant of -3
We can also define the Integer with width.
7.U(4.W) // defines the Unsigned Integer of width 4
8.S(7.W) // Signed decimal 7 bit literal of type SInt
For constants defined in other bases than decimal, the constant is defined in a string with a preceding h for hexdecimal(base 16), o for octal(base 8), b for binary (base 2). In these case we omit the bit width and the chisel infers the minimum width to fit the constants in, in this below case width 8 will be considered.
“hdf”.U // Hexa decimal representation of 223
“o337”.U // Octal representation of 223
“b1101_1111”.U // Binary representation of 223
No comments:
Post a Comment