admin管理员组文章数量:1335415
I'm trying to implement a floating point adder/subtractor. I've already achieved the code to work. When I run the simulation it works as expected.
The thing is when I try to synthesize it in Vivado I get this errors: "constant expression required width mismatch in assignment" and "target has 279 bits, source has 86 bits" on a line that says:
my_p_nt_a <= to_unsigned(0, to_integer(abs_exp_diff)) & my_p & to_unsigned(0, 2**NE - 1- to_integer(abs_exp_diff));
This corresponds to the mantissa's alignment.
Some more info:
signal my_p_nt_a: unsigned(NF + 2**NE-1 downto 0);
signal abs_exp_diff: unsigned(NE downto 0);
NE is the number of bits the exponent has.
I don't know how to solve it. I've tried different ways but I keep getting problems when synthesizing.
I'm trying to implement a floating point adder/subtractor. I've already achieved the code to work. When I run the simulation it works as expected.
The thing is when I try to synthesize it in Vivado I get this errors: "constant expression required width mismatch in assignment" and "target has 279 bits, source has 86 bits" on a line that says:
my_p_nt_a <= to_unsigned(0, to_integer(abs_exp_diff)) & my_p & to_unsigned(0, 2**NE - 1- to_integer(abs_exp_diff));
This corresponds to the mantissa's alignment.
Some more info:
signal my_p_nt_a: unsigned(NF + 2**NE-1 downto 0);
signal abs_exp_diff: unsigned(NE downto 0);
NE is the number of bits the exponent has.
I don't know how to solve it. I've tried different ways but I keep getting problems when synthesizing.
Share Improve this question edited Nov 20, 2024 at 6:52 the busybee 12.7k3 gold badges14 silver badges34 bronze badges asked Nov 20, 2024 at 0:32 Sofía AcuñaSofía Acuña 272 bronze badges 2- We probably can't say very much without knowing the size of all of those signals. If you really are concatenating 279 bits and trying to store it in an 86 bit destination, that certainly is a problem. – Tim Roberts Commented Nov 20, 2024 at 0:35
- 1 Please edit your question to add a minimal reproducible example. – the busybee Commented Nov 20, 2024 at 6:51
1 Answer
Reset to default 2The meaning of the error message is, in Vivado synthesis you can't extend your operand by a number of 0's where the number depends on the value at abs_exp_diff. This works only, if abs_exp_diff would be a constant. I expect most of the synthesis tools will not be able to do this.
Instead you should use this solution:
entity test_shift is
end entity test_shift;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
architecture struct of test_shift is
constant NF : natural := 10; -- example value
constant NE : natural := 12; -- example value
signal abs_exp_diff : unsigned(NE downto 0);
signal my_p : unsigned(NF-1 downto 0);
signal my_p_nt_a : unsigned(NF+2**NE-1 downto 0);
begin
process(my_p, abs_exp_diff)
variable my_p_nt_a_v : unsigned(my_p_nt_a'range);
begin
my_p_nt_a_v := (others => '0');
my_p_nt_a_v(my_p'range) := my_p;
my_p_nt_a <= shift_left(my_p_nt_a_v, 2*NE-1-to_integer(abs_exp_diff));
end process;
end architecture;
Edit: You could also use a function:
function insert_my_p (my_p : in unsigned(NF-1 downto 0);
abs_exp_diff : in unsigned(NE downto 0))
return unsigned is
variable my_p_nt_a_v : unsigned(NF+2**NE-1 downto 0);
begin
my_p_nt_a_v := (others => '0');
my_p_nt_a_v(my_p'range) := my_p;
return shift_left(my_p_nt_a_v, 2*NE-1-to_integer(abs_exp_diff));
end function;
本文标签:
版权声明:本文标题:floating point - Constant expression required width mismatch in assignment. Non synthesizable VHDL code line - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742388857a2465585.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论