Shift registers¶
Shift 4¶
Verilog | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
load
and ena
are high is handled by the sequential priority of the if-else
statements. Here's how it works:
-
if (areset)
: This takes the highest priority because it's the first condition checked. Ifareset
is high, the outputq
is reset to4'b0000
, regardless of the states ofload
orena
. -
else if (load)
: This is checked next. Ifareset
is not active andload
is high,q
will be loaded with the value ofdata
. This happens even ifena
is also high. Theload
operation takes priority over the enable (ena
) because it comes before it in theelse if
chain. -
else if (ena)
: This block is only executed if bothareset
is low andload
is low. In this case, ifena
is high, the value ofq
will be right-shifted. However, this will not happen ifload
is also high, as theload
condition would already have been executed, skipping theena
block.
Summary of load
and ena
behavior:¶
- If both
load
andena
are high at the same time,load
takes priority.q
will be loaded withdata
, and theena
block (right shift) will not execute. - If only
ena
is high, the right shift operation will take place.
This ensures that when load
is asserted, it overrides the enable behavior, preventing simultaneous conflicting operations.