B
Brandon
Guest
Hello,
I've designed a complex MAC with generic word size. I'd like to now be
able to parameterize the precision of the fixed point inputs to the
accumulator. Unfortunately, I'm having some difficulty implementing
this, since I haven't been able to find any advanced (advanced for me,
at least) examples on generics.
I assume that the real and imaginary inputs to the MAC are between -1
and +1. The result of the complex multiply is therefore bound between
-2 and +2. This is then connected to the inputs of the accumulators:
[2*dwidth][2*dwidth-1 : 2*dwidth-2][2*dwidth-3 downto 0]
[ sign ][ whole bits ][ fraction bits ]
So I added accumwholewidth and accumfractwidth to denote the bit widths
so that the user may use to constrain the inputs and outputs of the
MAC.
<SNIP>
-------------------------------------------------------------------------------
-- ENTITY
-------------------------------------------------------------------------------
entity maccplx_g is
generic (
-- Bit widths
dwidth : integer;
accumwhwidth : integer; -- number of whole bits of accumulator
i/o
accumfrwidth : integer; -- number of fraction bits of
accumulator i/o
);
..
..
..
end entity maccplx_g;
-------------------------------------------------------------------------------
-- ARCHITECTURE
-------------------------------------------------------------------------------
architecture structural_ar of maccplx_g is
..
..
..
---------------------------------------------------------------------------
-- accumulator input mapping process
---------------------------------------------------------------------------
accum_map_proc: process(pre_r,pim_r)
begin
-- Sign extension of complex products
for i in 0 to accumwhwidth-2 loop
accumre_signext(i) <= pre_r(pre_r'high);
accumim_signext(i) <= pim_r(pim_r'high);
end loop;
-- Accumulator for Re{p}
accumre_ain(accumfrwidth-1 downto 0)
<= pre_r(2*dwidth-3 downto 2*dwidth-3-accumfrwidth+1);
accumre_ain(accumwhwidth+accumfrwidth downto accumfrwidth)
<= accumre_signext & pre_r(2*dwidth-1 downto 2*dwidth-2);
.
.
.
end process accum_map_proc;
end structural_ar;
</SNIP>
I get this to compile, but I'm having some errors with simulation. Does
this code look okay?
What happens if the user specifies the fraction bit width = 0
(accumfrwidth <= 0)?
For example, consider: dwidth <= 16 and accumfrwidth <= 0, it will
evaluate as a null slice, I believe? What happens in
simulation/synthesis to the following line?
accumre_ain(-1 downto 0) <= pre_r(29 downto 30);
Thanks in advance.
-Brandon
I've designed a complex MAC with generic word size. I'd like to now be
able to parameterize the precision of the fixed point inputs to the
accumulator. Unfortunately, I'm having some difficulty implementing
this, since I haven't been able to find any advanced (advanced for me,
at least) examples on generics.
I assume that the real and imaginary inputs to the MAC are between -1
and +1. The result of the complex multiply is therefore bound between
-2 and +2. This is then connected to the inputs of the accumulators:
[2*dwidth][2*dwidth-1 : 2*dwidth-2][2*dwidth-3 downto 0]
[ sign ][ whole bits ][ fraction bits ]
So I added accumwholewidth and accumfractwidth to denote the bit widths
so that the user may use to constrain the inputs and outputs of the
MAC.
<SNIP>
-------------------------------------------------------------------------------
-- ENTITY
-------------------------------------------------------------------------------
entity maccplx_g is
generic (
-- Bit widths
dwidth : integer;
accumwhwidth : integer; -- number of whole bits of accumulator
i/o
accumfrwidth : integer; -- number of fraction bits of
accumulator i/o
);
..
..
..
end entity maccplx_g;
-------------------------------------------------------------------------------
-- ARCHITECTURE
-------------------------------------------------------------------------------
architecture structural_ar of maccplx_g is
..
..
..
---------------------------------------------------------------------------
-- accumulator input mapping process
---------------------------------------------------------------------------
accum_map_proc: process(pre_r,pim_r)
begin
-- Sign extension of complex products
for i in 0 to accumwhwidth-2 loop
accumre_signext(i) <= pre_r(pre_r'high);
accumim_signext(i) <= pim_r(pim_r'high);
end loop;
-- Accumulator for Re{p}
accumre_ain(accumfrwidth-1 downto 0)
<= pre_r(2*dwidth-3 downto 2*dwidth-3-accumfrwidth+1);
accumre_ain(accumwhwidth+accumfrwidth downto accumfrwidth)
<= accumre_signext & pre_r(2*dwidth-1 downto 2*dwidth-2);
.
.
.
end process accum_map_proc;
end structural_ar;
</SNIP>
I get this to compile, but I'm having some errors with simulation. Does
this code look okay?
What happens if the user specifies the fraction bit width = 0
(accumfrwidth <= 0)?
For example, consider: dwidth <= 16 and accumfrwidth <= 0, it will
evaluate as a null slice, I believe? What happens in
simulation/synthesis to the following line?
accumre_ain(-1 downto 0) <= pre_r(29 downto 30);
Thanks in advance.
-Brandon