Assignment
To assign one signal to the value of another signal, use the <=
operator. This is a hardware synthesizable assignment connecting two wires together.
var a = Logic(), b = Logic();
// assign `a` to always have the same value as `b`
a <= b;
It is also possible to do a partial assignment to a signal using assignSubset
.
var a = Logic(width: 3), b = Logic(width: 2);
// assign the bottom two bits of `a` to have the same value as `b`
a.assignSubset(b.elements);
// assign the upper bit (index 2) of `a` to be 0
a.assignSubset([Const(0)], 2);
If you’re assigning groups of bits that are already collected as a single Logic
, consider using a swizzle
.