Resource inference maps behavioral RTL patterns to cells such as muxes, registers and memories. Synthesis can optimize away unused logic or choose different structures for equivalent equations. Coding intent matters most where it changes the required behavior: reset style, incomplete assignments, arithmetic widths and memory access patterns.
Worked example
The indexed array read is asynchronous, while writes occur at the clock edge. This may map to registers or a distributed memory on some targets rather than a synchronous-read block RAM. The synthesis resource report tells you what was actually built.
module inferred_array(input clk,we,input [2:0] address,input [7:0] d,output [7:0] q);
reg [7:0] memory[0:7];
always @(posedge clk) if(we) memory[address]<=d;
assign q=memory[address];
endmodule
What to watch for
Do not infer resource counts from source lines. A compact expression may describe a large combinational network; optimization may remove another network entirely.
Try it yourself
What should you inspect after expecting a block RAM to be inferred?
Answer: The memory and cell-utilization reports, relevant warnings, and the inferred read/write behavior. Confirm the implementation against the target's supported memory template.
How to study this topic
Save the example in a .v file and identify its top module before compiling. Separate stimulus and observation from synthesizable RTL. Change one input, width or boundary condition at a time, predict the result, and compare that prediction with simulation. A syntax check does not establish synthesis support or timing closure.
Continue learning
Previous: Synthesizable and simulation-only constructs
Next: Lint and synthesis warnings
Browse the complete Verilog index
Explore related programmes
These recorded programmes are upcoming. This article is general educational content, not a syllabus or course sample.
Verilog