سلام
میخواستم بدونم توی عبارت زیر اینکه بیتها از منفی یک شروع میشن و بیت آخرش هم باز منفیه مفهوم خاصی داره؟
سوال دوم اینکه درباره نوع داده sfixed در vhdl اگه چیزی میدونید ممنون میشم برام بذارید.
اصل برنامه اینه:
میخواستم بدونم توی عبارت زیر اینکه بیتها از منفی یک شروع میشن و بیت آخرش هم باز منفیه مفهوم خاصی داره؟
output_re(-1 downto 1 - data_width) <= re(-1 downto 1 - data_width);
وسوال دوم اینکه درباره نوع داده sfixed در vhdl اگه چیزی میدونید ممنون میشم برام بذارید.
اصل برنامه اینه:
library ieee_proposed;
use ieee_proposed.fixed_float_types.all;
use ieee_proposed.fixed_pkg.all;
entity cmul is
generic (
-- same data width is used for the real and imaginary component
data_width : integer range 0 to 128 := 16
);
port (
-- input a
input_a_re : in sfixed (0 downto 1 - data_width);
input_a_im : in sfixed (0 downto 1 - data_width);
-- input b
input_b_re : in sfixed (0 downto 1 - data_width);
input_b_im : in sfixed (0 downto 1 - data_width);
-- output
output_re : out sfixed(0 downto 1 - data_width);
output_im : out sfixed(0 downto 1 - data_width)
);
end cmul;
-- Function Implementation 0
architecture FIMP_0 of cmul is
-- internal signals with short names
-- input a = a + b * j
-- input b = x + y * j
signal a, b, x, y : sfixed (0 downto 1 - data_width);
-- output = re + im * j
-- cropping is required
signal re, im : sfixed(2 downto 2 - 2 * data_width);
begin
-- input a = a + b * j
a <= input_a_re;
b <= input_a_im;
-- input b = x + y * j
x <= input_b_re;
y <= input_b_im;
-- output real part
-- a * x - b * y
re <= (a * x) - (b * y);
-- output imaginary part
-- a * y + b * x
im <= (a * y) + (b * x);
-- crop the outputs to fit with data width
output_re(0) <= re(2);
output_re(-1 downto 1 - data_width) <= re(-1 downto 1 - data_width);
output_im(0) <= im(2);
output_im(-1 downto 1 - data_width) <= im(-1 downto 1 - data_width);
end FIMP_0;
use ieee_proposed.fixed_float_types.all;
use ieee_proposed.fixed_pkg.all;
entity cmul is
generic (
-- same data width is used for the real and imaginary component
data_width : integer range 0 to 128 := 16
);
port (
-- input a
input_a_re : in sfixed (0 downto 1 - data_width);
input_a_im : in sfixed (0 downto 1 - data_width);
-- input b
input_b_re : in sfixed (0 downto 1 - data_width);
input_b_im : in sfixed (0 downto 1 - data_width);
-- output
output_re : out sfixed(0 downto 1 - data_width);
output_im : out sfixed(0 downto 1 - data_width)
);
end cmul;
-- Function Implementation 0
architecture FIMP_0 of cmul is
-- internal signals with short names
-- input a = a + b * j
-- input b = x + y * j
signal a, b, x, y : sfixed (0 downto 1 - data_width);
-- output = re + im * j
-- cropping is required
signal re, im : sfixed(2 downto 2 - 2 * data_width);
begin
-- input a = a + b * j
a <= input_a_re;
b <= input_a_im;
-- input b = x + y * j
x <= input_b_re;
y <= input_b_im;
-- output real part
-- a * x - b * y
re <= (a * x) - (b * y);
-- output imaginary part
-- a * y + b * x
im <= (a * y) + (b * x);
-- crop the outputs to fit with data width
output_re(0) <= re(2);
output_re(-1 downto 1 - data_width) <= re(-1 downto 1 - data_width);
output_im(0) <= im(2);
output_im(-1 downto 1 - data_width) <= im(-1 downto 1 - data_width);
end FIMP_0;