Showing posts with label data types. Show all posts
Showing posts with label data types. Show all posts

Friday, 19 February 2021

Basics : Data Types III

Vectors

Vectors can be a net or reg data types. They are declared as [high:low] or [low:high], but the left number is always the MSB of the vector.

wire [7:0] vs; // vs[7] is the MSB.
reg [0:15] vs_1; // vs_1[15] is the MSB.

In the above examples: If it is written as vs[5:2], it is the part of the entire vector which contains 4 bits in order: vs[5], vs[4], vs[3], vs[2].

Similarly vs_1[0:7], means the first half part of the vecotr vs_.1
Vector parts can also be specified in a different way:
vector_name[start_bit+:width] : part-select increments from start_bit in above example: vs_1[0:7] is same as vs_1[0+:8].

vector_name[start_bit-:width] : part-select decrements from start_bit in above example: vs[5:2] is same as vs[5-:4].

Arrays

Arrays of reg, integer, real, time, and vectors are allowed. Arrays are declared as follows:

reg vs1[0:7];
real vs3[15:0];
wire [0:3] vs4[7:0]; // Array of vector
integer vs5[0:3][6:0]; // Double dimensional array

Strings

Strings are register data types. For storing a character, we need a 8-bit register data type. So if you want to create string variable of length n. The string should be declared as register data type of length n*8.

reg [8*8-1:0] vs_1; // vs_1 is a string of length 8.

Time Data Types

Time data type is declared using the keyword time. These are generally used to store simulation time. In general it is 64-bit long.

time vs_1;
Vs_1 = $time; // assigns current simulation time to vs_1.

Wednesday, 8 January 2020

CHISEL:DATA TYPES

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

Physical Cells :TAP CELLS, TIE CELLS, ENDCAP CELLS, DECAP CELLS

Tap Cells (Well Taps) :  These library cells connect the power and ground connections to the substrate and n­wells, respectively.  By plac...