Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - mac design in vhdl

 
Thread Tools Search this Thread
Old 09-01-2006, 09:35 AM   #1
Default mac design in vhdl


hi..
I want to design a MAC(multiply-accumulator).I have written the
following code.The problem is ,when I do place & route in Xilinx ISE
7.1version,I get too many timing errors(around 30).My clock is 70Mhz.

entity mac is
generic(
input_width1 : integer:= 16;
input_width2 : integer:= 16;
output_width : integer := 36;
mac_cycle_width : integer := 4
);
port (
RESET : IN STD_LOGIC;
CLK : IN STD_LOGIC;
FD : IN STD_LOGIC;
ND : IN STD_LOGIC;
A : IN STD_LOGIC_VECTOR(input_width1-1 DOWNTO 0);
B : IN STD_LOGIC_VECTOR(input_width2-1 DOWNTO 0);
Q : OUT STD_LOGIC_VECTOR(output_width-1 DOWNTO 0);
RDY : OUT STD_LOGIC
);
end entity mac;

architecture rtl of mac is

signal cycle : STD_LOGIC_VECTOR(mac_cycle_width-1 DOWNTO 0);
signal rdy1 : std_logic;
signal sum : STD_LOGIC_VECTOR (output_width-1 DOWNTO 0);
signal temp2 : STD_LOGIC_VECTOR (output_width-1 DOWNTO 0);
signal prod : STD_LOGIC_VECTOR (input_width1 + input_width2 -1
DOWNTO 0);

begin

-- cycle determines the no of mac accumulations
-- fd indicates the start of new accumulation
process(reset,clk)
begin
if reset = '1' then
cycle <= (others =>'0');
elsif(clk'event and clk = '1')then
if ( fd = '1')then
cycle
<=conv_std_logic_vector((1),cycle'length);--"0001";--conv_std_logic_vector((1),cycle'length);
--;
else
cycle <= cycle +'1';
end if;
end if;
end process;

-- ND indicates that the new data is ready at the input.
-- the 2 inputs are multiplied and the product is added
-- to the previous accumulator result .
-- In the last cycle the accumulator result is given out and at
-- same time the accumulator is reset to zeros.
-- here the accumulator is variable temp1.
-- SUM holds the final accumulated result and temp2 holds the
-- intermediate results.
process(reset,clk)
variable temp1 : STD_LOGIC_VECTOR (output_width-1 DOWNTO 0);
begin
if(reset ='1')then
sum <= (others => '0');
prod <= (others => '0');
temp1 := (others => '0');
elsif( clk'event and clk ='0')then
if (nd ='1')then
prod <= A * (B);
temp1 := temp1 + prod;
if( cycle=conv_std_logic_vector((0),cycle'length))then
--"0000"--conv_std_logic_vector((0),cycle'length)
sum <= temp1;
temp1 := (others => '0');
end if;
end if;
end if;
temp2 <= temp1;
end process;


-- here Q indicates the accumulator output during all cycles
-- SUM holds the final accumulated result and temp2 holds the
-- intermediate results. both are combined to form Q.
process(clk)
begin
if( clk'event and clk ='1')then
if (
cycle=conv_std_logic_vector((0),cycle'length))then --"0000"--conv_std_logic_vector((0),cycle'length)
q <= sum;
else
q <= temp2;
end if;
end if;
end process;

--q <= sum;

-- At the end of MAC cycle rdy is generated to indicated
-- that the MAC output is ready.
process(reset,clk)
begin
if(reset ='1')then
rdy1 <= '0';
elsif( clk'event and clk ='1')then -- ori '1'
if( cycle=conv_std_logic_vector((0),cycle'length))then
--"0000"conv_std_logic_vector((0),cycle'length)
rdy1 <= '1';
else
rdy1 <= '0';
end if;
end if;
end process;

rdy <= rdy1;

end rtl;



sksaras@hotmail.com
  Reply With Quote
Old 09-04-2006, 06:04 AM   #2
sksaras@hotmail.com
 
Posts: n/a
Default Re: mac design in vhdl
hi all..
is there any wrong in this design?. fuctionally when I tested on
modelsim ,correct results were produced.Please help..


wrote:
> hi..
> I want to design a MAC(multiply-accumulator).I have written the
> following code.The problem is ,when I do place & route in Xilinx ISE
> 7.1version,I get too many timing errors(around 30).My clock is 70Mhz.
>
> entity mac is
> generic(
> input_width1 : integer:= 16;
> input_width2 : integer:= 16;
> output_width : integer := 36;
> mac_cycle_width : integer := 4
> );
> port (
> RESET : IN STD_LOGIC;
> CLK : IN STD_LOGIC;
> FD : IN STD_LOGIC;
> ND : IN STD_LOGIC;
> A : IN STD_LOGIC_VECTOR(input_width1-1 DOWNTO 0);
> B : IN STD_LOGIC_VECTOR(input_width2-1 DOWNTO 0);
> Q : OUT STD_LOGIC_VECTOR(output_width-1 DOWNTO 0);
> RDY : OUT STD_LOGIC
> );
> end entity mac;
>
> architecture rtl of mac is
>
> signal cycle : STD_LOGIC_VECTOR(mac_cycle_width-1 DOWNTO 0);
> signal rdy1 : std_logic;
> signal sum : STD_LOGIC_VECTOR (output_width-1 DOWNTO 0);
> signal temp2 : STD_LOGIC_VECTOR (output_width-1 DOWNTO 0);
> signal prod : STD_LOGIC_VECTOR (input_width1 + input_width2 -1
> DOWNTO 0);
>
> begin
>
> -- cycle determines the no of mac accumulations
> -- fd indicates the start of new accumulation
> process(reset,clk)
> begin
> if reset = '1' then
> cycle <= (others =>'0');
> elsif(clk'event and clk = '1')then
> if ( fd = '1')then
> cycle
> <=conv_std_logic_vector((1),cycle'length);--"0001";--conv_std_logic_vector((1),cycle'length);
> --;
> else
> cycle <= cycle +'1';
> end if;
> end if;
> end process;
>
> -- ND indicates that the new data is ready at the input.
> -- the 2 inputs are multiplied and the product is added
> -- to the previous accumulator result .
> -- In the last cycle the accumulator result is given out and at
> -- same time the accumulator is reset to zeros.
> -- here the accumulator is variable temp1.
> -- SUM holds the final accumulated result and temp2 holds the
> -- intermediate results.
> process(reset,clk)
> variable temp1 : STD_LOGIC_VECTOR (output_width-1 DOWNTO 0);
> begin
> if(reset ='1')then
> sum <= (others => '0');
> prod <= (others => '0');
> temp1 := (others => '0');
> elsif( clk'event and clk ='0')then
> if (nd ='1')then
> prod <= A * (B);
> temp1 := temp1 + prod;
> if( cycle=conv_std_logic_vector((0),cycle'length))then
> --"0000"--conv_std_logic_vector((0),cycle'length)
> sum <= temp1;
> temp1 := (others => '0');
> end if;
> end if;
> end if;
> temp2 <= temp1;
> end process;
>
>
> -- here Q indicates the accumulator output during all cycles
> -- SUM holds the final accumulated result and temp2 holds the
> -- intermediate results. both are combined to form Q.
> process(clk)
> begin
> if( clk'event and clk ='1')then
> if (
> cycle=conv_std_logic_vector((0),cycle'length))then --"0000"--conv_std_logic_vector((0),cycle'length)
> q <= sum;
> else
> q <= temp2;
> end if;
> end if;
> end process;
>
> --q <= sum;
>
> -- At the end of MAC cycle rdy is generated to indicated
> -- that the MAC output is ready.
> process(reset,clk)
> begin
> if(reset ='1')then
> rdy1 <= '0';
> elsif( clk'event and clk ='1')then -- ori '1'
> if( cycle=conv_std_logic_vector((0),cycle'length))then
> --"0000"conv_std_logic_vector((0),cycle'length)
> rdy1 <= '1';
> else
> rdy1 <= '0';
> end if;
> end if;
> end process;
>
> rdy <= rdy1;
>
> end rtl;




sksaras@hotmail.com
  Reply With Quote
Old 09-04-2006, 04:54 PM   #3
Duane Clark
 
Posts: n/a
Default Re: mac design in vhdl
wrote:
> hi all..
> is there any wrong in this design?. fuctionally when I tested on
> modelsim ,correct results were produced.Please help..
>
>
> wrote:
>> hi..
>> I want to design a MAC(multiply-accumulator).I have written the
>> following code.The problem is ,when I do place & route in Xilinx ISE
>> 7.1version,I get too many timing errors(around 30).My clock is 70Mhz.
>>


Have you taken a look at the timing report (*.twr) to see what paths are
failing? I assume the it is the multiply that is failing. Are you using
a chip with built in hardware multipliers? Are they being used?


Duane Clark
  Reply With Quote
Old 09-05-2006, 05:58 AM   #4
sksaras@hotmail.com
 
Posts: n/a
Default Re: mac design in vhdl
hi..thanks a lot.
You are right.when I saw the timing analyzer (post -place & route
static timing analyzer)most errors are in the multiply route.
Now I have replaced multiply by xilinx multiplier core and the errors
are reduced to 4 but the slices occupancy has increased a lot.
Also I am not supposed to use any cores.Please suggest me any other
ways to design the MAC.Or can I modify the above code (opitmise) so
that errors are reduced?.

Duane Clark wrote:
> wrote:
> > hi all..
> > is there any wrong in this design?. fuctionally when I tested on
> > modelsim ,correct results were produced.Please help..
> >
> >
> > wrote:
> >> hi..
> >> I want to design a MAC(multiply-accumulator).I have written the
> >> following code.The problem is ,when I do place & route in Xilinx ISE
> >> 7.1version,I get too many timing errors(around 30).My clock is 70Mhz.
> >>

>
> Have you taken a look at the timing report (*.twr) to see what paths are
> failing? I assume the it is the multiply that is failing. Are you using
> a chip with built in hardware multipliers? Are they being used?




sksaras@hotmail.com
  Reply With Quote
Old 09-05-2006, 04:54 PM   #5
Duane Clark
 
Posts: n/a
Default Re: mac design in vhdl
wrote:
> hi..thanks a lot.
> You are right.when I saw the timing analyzer (post -place & route
> static timing analyzer)most errors are in the multiply route.
> Now I have replaced multiply by xilinx multiplier core and the errors
> are reduced to 4 but the slices occupancy has increased a lot.
> Also I am not supposed to use any cores.Please suggest me any other
> ways to design the MAC.Or can I modify the above code (opitmise) so
> that errors are reduced?.


What chip are you targeting? The Virtex2 and later chips have built in
hardware multipliers that consume no slices. Is this a homework problem?

Again, you need to look at the timing report, see what paths are
breaking, and then determine what to do to fix them.



Duane Clark
  Reply With Quote
Old 09-06-2006, 08:13 AM   #6
sksaras@hotmail.com
 
Posts: n/a
Default Re: mac design in vhdl
hi..I am using spartan3 200k chip.I know that this chip has 12
dedicated multipliers.If I use ' * ' to multiply ,will these
multipliers be used ? If it uses these multipliers then why is the
slice occupancy increased?

Also when I use multiplier xilinx core, then it must use these built-in
multipliers only to implement.hence it should occupy no or less
slices.But there is increase in slices number.why?

> Again, you need to look at the timing report, see what paths are
> breaking, and then determine what to do to fix them.


I have seen the timing report.The problem is in the multiply only.But
how do I fix it ?.Please suggest.



Duane Clark wrote:
> wrote:
> > hi..thanks a lot.
> > You are right.when I saw the timing analyzer (post -place & route
> > static timing analyzer)most errors are in the multiply route.
> > Now I have replaced multiply by xilinx multiplier core and the errors
> > are reduced to 4 but the slices occupancy has increased a lot.
> > Also I am not supposed to use any cores.Please suggest me any other
> > ways to design the MAC.Or can I modify the above code (opitmise) so
> > that errors are reduced?.

>
> What chip are you targeting? The Virtex2 and later chips have built in
> hardware multipliers that consume no slices. Is this a homework problem?
>
> Again, you need to look at the timing report, see what paths are
> breaking, and then determine what to do to fix them.




sksaras@hotmail.com
  Reply With Quote
Old 09-13-2006, 11:11 PM   #7
james
 
Posts: n/a
Default Re: mac design in vhdl
On 6 Sep 2006 00:13:50 -0700, wrote:

>+++hi..I am using spartan3 200k chip.I know that this chip has 12
>+++dedicated multipliers.If I use ' * ' to multiply ,will these
>+++multipliers be used ? If it uses these multipliers then why is the
>+++slice occupancy increased?

************

Download XAPP467 from Xilinx web page and that will tell you what you
need to know how to use the dedicated multipliers in the Spartan3
series of devices. You can set the process constraints so that XST
will infer use of a dedicated multiplier. Thus A * B will use a
dedicated multiplier and not one comprised of LUTs. There is example
code also that you can look at an adapt to your need.

You should make use of these application notes as they can be helpful
in understanding how the logic works internally.

james


james
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute an external software from VHDL? And how to interface VHDL with JAVA? becool_nikks Software 0 03-06-2009 07:08 PM
Error: Physical sythesis tool PALAC is not supported by Formal Verification tool Conf bbiandov Software 0 12-22-2008 05:25 AM
Help on auto conversion from Matlab to vhdl on filter design hardheart Hardware 0 12-07-2007 09:19 AM
Sewing, Embroidery & SignMaking Software.. embsupply Software 0 10-02-2007 04:29 PM
Conformal LEC of a VHDL design (RTL Vs Netlist) sharatd Hardware 0 10-18-2006 02:47 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46