( ESNUG 305 Item 9 ) --------------------------------------------- [11/18/98]
From: David C Black <dcblack@qualis.com>
Subject: In BC Source Code, Initialize Variables Close to Their Usage Site
John,
Your BC users should know that Behavioral Compiler needs to have variables
initialized properly to provide good results. If you fail to initialize the
entire variable in one chunk, BC doesn't recognize the initialization as
valid. Failure to initialize results in a warning messages, may create
simulation mismatches, and may create unnecessary registers.
Warning: Variable 'MAIN/ERROR_CONDITON/x_loop_connect' is not
initialized (HLS- 155)
The following is an example that might puzzle designers expecting more than
the tool currently delivers:
reg [31:0] x;
...
while (COND) begin :WHILE
if (COND) begin
x[31:8] = a;
end //if
else begin
x[31:8] = b;
end //else
x[7:0] = 0;
data_out <= x;
@(posedge clock);
end //while
Simply adding 'x = 0;' directly after the 'while' and before the 'if' saves
a register and a warning message. BC doesn't recognize that x was fully
initialized. Note that if BC sees a loop, it will put a register unless it
can determine the old value is of no use. Initialization solves this.
Alternately, you can assign a register to itself in all branches of a
conditional (pain). I recommend eliminating all BC warning messages. Only
occasionally is it acceptable to leave the warnings.
- David Black
Qualis Design
|
|