The Bool type is defined to have two values, True and False. typedef enum {False, True} Bool; Usage
FunctionsThe following Bool functions return either a value of True and False.
ExamplesBool a // A variable named a with a type of Bool. Valid Values are True or FalseReg#(Bool) done // A register named done with a type of Bool Vector#(5, Bool) // A vector of 5 Boolean values Bool a = 0; // ERROR! You cannot do this Bool a = True; // correct if (a) // correct .... if (a == 0) // ERROR! .... Data Type ConversionsConverting between Bool and Bit#(1)Warning: If you are performing many conversions from Bit#(1) to Bool you probably should redefine some of your Bits as Bools.Bool b = (z == 0); // Convert from bit to Bool bit x = b ? 1 : 0; // Convert from Bool to bit Bit#(1) a = 0; Bool b = unpack (a); //Convert from bit to Bool a = pack (b); //Convert from Bool to bit Data Type Conversion FunctionsBluespec provides a set of functions to convert a type between Bool and another type. During type checking, the compiler resolves these functions to a particular type instance. If you have excessive type conversion in your design, it usually indicates a poor choice of the basic object types in the design, and you may want to review your type choices. These conversion utilities do not incur logic overhead. |
Learning BSV > Data Types >