D
dmitriym
Guest
Hello, experts!
I'm performing a research in order to define list of "rules"
regardning determinition of expressions bit widths for synthesis. I've
already googled for all related topics regarding expressions bit width
determinition. Common are issues about simple rules that are defined
in the Verilog Standard (e.g. compiler makes the bit width of RHS as
wide as LHS is). But I'm interested in synthesis bit width-related
"rules", that could help me to deal with issues like following:
--- 8< ---
reg A, B;
reg [1:0] SUM;
....
SUM = A + B;
....
--- >8 ---
[this description is bad from linter point of view (bit width of RHS
is less than bit width of assignment destination), but it is ok for
synthesis tool (adder with carry-out could be inferred)]
Or, another one example:
--- 8< ---
reg [1:0] A;
reg [2:0] B;
reg [4:0] M;
....
M = A * B + 1'b1;
....
--- >8 ---
[the product of 2-bit "A" and 3-bit "B" should have 5 bits (3+2), but
1'b1 is added and overflow can occur => so, if I defibe "M" as "reg
[5:0] M", it will be also correct? in other words, how to define the
bit width "rule" for such case?]
Maybe, someone faced with some kind of document or whatever that is
related to this problem?
I'm sorry, if this question occurs not very clear... but this problem
really disturbs me and I'll highly appreciate any help
Best regards,
-dmitriym
I'm performing a research in order to define list of "rules"
regardning determinition of expressions bit widths for synthesis. I've
already googled for all related topics regarding expressions bit width
determinition. Common are issues about simple rules that are defined
in the Verilog Standard (e.g. compiler makes the bit width of RHS as
wide as LHS is). But I'm interested in synthesis bit width-related
"rules", that could help me to deal with issues like following:
--- 8< ---
reg A, B;
reg [1:0] SUM;
....
SUM = A + B;
....
--- >8 ---
[this description is bad from linter point of view (bit width of RHS
is less than bit width of assignment destination), but it is ok for
synthesis tool (adder with carry-out could be inferred)]
Or, another one example:
--- 8< ---
reg [1:0] A;
reg [2:0] B;
reg [4:0] M;
....
M = A * B + 1'b1;
....
--- >8 ---
[the product of 2-bit "A" and 3-bit "B" should have 5 bits (3+2), but
1'b1 is added and overflow can occur => so, if I defibe "M" as "reg
[5:0] M", it will be also correct? in other words, how to define the
bit width "rule" for such case?]
Maybe, someone faced with some kind of document or whatever that is
related to this problem?
I'm sorry, if this question occurs not very clear... but this problem
really disturbs me and I'll highly appreciate any help
Best regards,
-dmitriym