[Chisel] About conditional branching
Introduction
While writing chisel, you will learn that you can use the following syntax as a conditional branch.
if
when
Mux (MuxCase)
How should these be used?
if and when/Mux
First, these differ in whether the variable used for conditional judgment is of scala Boolean type or chisel BOOL type.
if: scala Boolean type
when/Mux: chisel BOOL type
In other words, whether to use if or when/Mux depends on the type of the variable to be judged.
when and Mux
As for how to use when and Mux, I think
"Mux" when calculating a value to be connected to some signal it seems that it is not possible to connect the value calculated inside "when" to the value defined outside "when" (a compile error occurred).
"when" when processing changes depending on conditions
This is just my personal opinion, though.
Recent Posts
See AllPhenomenon There is an array Check whether the index variable is within the size of the array, and access the element only if it is...
Overview When communicating data using a Queue, the following operations are possible: Queue.io.enq.valid: When set to false, data will...
What I want to do There are multiple similar units Most of processes are the same, only some differences. Select an appropriate unit...
Comments