CHISEL:Combinational circuits

Chisel uses the boolean algebra operators and arithmetic operators same as in c, java, scala, etc programming languages.

val sel = a & b

The keyword val is part of scala which is used to name the variables that have values that won’t change. And here it is used to name the chisel wire, sel, holding the output of the bitwise and operation. A signal can also first be defined as a Wire of some type. Afterward, we can assign a value to the wire with the  ‘:=’ update operator.

val sel = Wire(UInt()))
sel := a & b

Boolean operators

& —– represents bitwise AND operator
val and = a & b
| —– represents bitwise OR operator
val or = a | b
^ —– represents bitwise XOR operator
val xor = a ^ b
~ —– represents bitwise negation
val not = ~a

Arithmetic operations

+ —– Addition operation
val add = a + b
– —– Subtraction operation
val sub = a – b
* —– multiplication operation
val mul = a * b
/ —– division operation
val div = a / b
% —– modulo operation
val mod = a % b

OperatorDescriptionData Types
*        /         %Multiplication, division, modulusUInt, SInt
+       –Addition, subtractionUInt, SInt
===      =/=Equal, not equalUInt, SInt, returns Bool
>    >=    <=Comparison operationsUInt, SInt, returns Bool
<<      >>Shift left, shift rightUInt, SInt
~NOTUInt, SInt, Bool
&        |        ^AND, OR, XORUInt, SInt, Bool
!Logical NOTBool
&&      ||Logical AND, ORBool
Chisel defined hardware operators are show above

Comments