Consider the following combinatorial functions written inside an RTL modu…
Consider the following combinatorial functions written inside an RTL module: function [3:0] func_a; input [3:0] in; integer k; begin func_a = in; for (k = 0; k < 4; k = k + 1) begin func_a[k] = func_a[k] ^ in[3-k]; end end endfunction function [3:0] func_b; input [3:0] in; begin func_b = func_b + in; end endfunction Which of the following statements correctly describe how a logic synthesis tool handles func_a and func_b ? *(Select all that apply)*
- func_a synthesizes into a pure feed-forward combinational circuit composed of four 2-input XOR gates operating in parallel.
- func_a fails to synthesize because reading the return variable func_a[k] on the right-hand side creates an unresolvable combinational feedback loop.
- func_b infers a latch or combinational feedback loop because the return variable func_b is read before being completely initialized.
- In synthesizable Verilog, all variables declared inside a function or used as the function return value are treated as combinational variables; multiple assignments within a loop simply represent intermediate wire re-assignments during static unrolling.
- func_b is illegal in synthesizable RTL and causes a synthesis compiler error or critical warning regarding an uninitialized self-referential variable.
Correct answer
A. func_a synthesizes into a pure feed-forward combinational circuit composed of four 2-input XOR gates operating in parallel.; C. func_b infers a latch or combinational feedback loop because the return variable func_b is read before being completely initialized.; D. In synthesizable Verilog, all variables declared inside a function or used as the function return value are treated as combinational variables; multiple assignments within a loop simply represent intermediate wire re-assignments during static unrolling.; E. func_b is illegal in synthesizable RTL and causes a synthesis compiler error or critical warning regarding an uninitialized self-referential variable.
Explanation
* **A & D are TRUE:** In procedural code (and functions), sequential assignments to a variable before the function exits do not create physical loops; synthesis converts the procedural iterations into a Directed Acyclic Graph (DAG) of unrolled intermediate nets. For func_a : * func_a[0] = in[0] ^ in[3] * func_a[1] = in[1] ^ in[2] * func_a[2] = in[2] ^ in[1] * func_a[3] = in[3] ^ in[0] This maps cleanly to four 2-input XOR gates with no loops. * **B is FALSE:** Synthesis tools expand procedural assignments inside functions iteratively; reading an earlier assignment to the same variable in the same block does not create feedback. * **C & E are TRUE:** In func_b , func_b is read on the RHS ( func_b + in ) without any prior assignment in that execution path. This represents an uninitialized read of a combinational variable, which violates synthesis rules, generating a combinational loop warning/error or unwanted memory latch inference.