Forum: FPGA, VHDL & Co. ISE Multiplizierer Spartan 3A


von Philip K. (plip)


Lesenswert?

Hi,

ich habe einen 24x24 Bit Multiplizierer programmiert, der weil ich genug 
Zeit habe und nicht 4 18x18 Multiplizierer verbraten will seriell mit 
einem 18x18 arbeitet.
Jetzt sagt mir ISE zwar das: 
======================================================================== 
=
Advanced HDL Synthesis Report

Macro Statistics
# FSMs                                                 : 1
# Multipliers                                          : 1
 18x18-bit multiplier                                  : 1
# Adders/Subtractors                                   : 4
 24-bit adder                                          : 2
 48-bit adder                                          : 2
# Registers                                            : 186
 Flip-Flops                                            : 186

======================================================================== 
=

aber am Ende steht das:

======================================================================== 
=
*                            Final Report 
*
======================================================================== 
=
...
#      MULT18X18SIO                : 2
======================================================================== 
=

Warum sinds auf einmal 2?

Und noch eine Frage. Mein Ressourcenverbrauch schaut so aus:

Device utilization summary:
---------------------------

Selected Device : 3s700afg484-5

 Number of Slices:                     271  out of   5888     4%
 Number of Slice Flip Flops:           186  out of  11776     1%
 Number of 4 input LUTs:               507  out of  11776     4%
 Number of IOs:                         99
 Number of bonded IOBs:                 99  out of    372    26%
 Number of MULT18X18SIOs:                2  out of     20    10%
 Number of GCLKs:                        1  out of     24     4%

Das kommt mir relativ viel vor aber ich habe auch keinerlei Erfahrung 
damit. Vielleicht kann mir jemand der sie hat sagen, ob das für solches 
Modul angemessen ist oder ich eher ineffizient designed habe.

Gruß philip

von Kest (Gast)


Lesenswert?

Ohne Source Code ist es schwer was zu sagen, aber eventuell hast Du 
signed und unsigned verwechelt. Beachte also das Vorzeichen bei Deinen 
MUL-Operationen.

Kest

von Philip K. (plip)


Lesenswert?

Sollte eigentlich unsigned sein.
Und nochwas - ich habe das Ganze mit variabler Eingangswortbreite 19-36 
Bit realisiert, die ich als generic N übergebe. Wenn ich das gleiche 
Design für einen festen Wert mache, also N im code durch 24 ersetze, 
statt 24 zu übergeben, verbrauche ich deutlich weniger Ressourcen.
Warum ist das so?

Hier mal der Code für 24 Bit fest:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity mult24BitU_ser is
  port(
    clk: in std_logic;
    start: in std_logic;
    m1, m2: in std_logic_vector(23 downto 0);
    p: out std_logic_vector(47 downto 0);
    done: out std_logic
  );
end mult24BitU_ser;

architecture bhv of mult24BitU_ser is
  signal multin1, multin2: std_logic_vector(17 downto 0);
  signal multout: std_logic_vector(35 downto 0);
  signal add_mout: std_logic_vector(47 downto 0);
  signal Sum: std_logic_vector(47 downto 0);
begin

  multout <= multin1 * multin2;

  Statemachine: process(clk)
    type state is(idle, multaa, multab, multba, multbb, wait_res);
    variable pstate: state := idle;
    variable switch_state: boolean := false;
    variable waitcycle: boolean := true;
  begin
    if(rising_edge(clk))then
      if(switch_state)then
        switch_state := false;
        waitcycle := false;
        if(pstate = idle)then
          pstate := multaa;
        elsif(pstate = multaa)then
          pstate := multab;
        elsif(pstate = multab)then
          pstate := multba;
        elsif(pstate = multba)then
          pstate := multbb;
        elsif(pstate = multbb)then
          pstate := wait_res;
        elsif(pstate = wait_res)then
          pstate := idle;
        end if;
      end if;

      if(pstate = idle)then
        if(start = '1')then
          Sum <= (others => '0');
          add_mout <= (others => '0');
          done <= '0';
          switch_state := true;
        end if;
      end if;

      if(pstate = multaa)then
        -- Multiplikation aa
        multin1  <= m1(17 downto 0);
        multin2  <= m2(17 downto 0);
        switch_state := true;
      end if;

      if(pstate = multab)then
        add_mout(35 downto 0) <= multout;-- Ergebnis multaa
        -- Multiplikation ab
        multin1  <= m1(17 downto 0);
        multin2(5 downto 0)  <= m2(23 downto 18);
        multin2(17 downto 6) <= (others => '0');
        switch_state := true;
      end if;

      if(pstate = multba)then
        Sum <= Sum + add_mout;-- Ergebnis multaa aufaddieren
        add_mout(47 downto 18) <= multout(29 downto 0);

        -- Multiplikation ba
        multin1  <= m2(17 downto 0);
        multin2(5 downto 0)  <= m1(23 downto 18);
        multin2(17 downto 6) <= (others => '0');
        switch_state := true;
      end if;

      if(pstate = multbb)then
        Sum <= Sum + add_mout;-- Ergebnis multab aufaddieren
        add_mout(47 downto 18) <= multout(29 downto 0);
        -- Multiplikation bb
        multin1(5 downto 0)  <= m1(23 downto 18);
        multin2(5 downto 0)  <= m2(23 downto 18);

        multin1(17 downto 6) <= (others => '0');
        multin2(17 downto 6) <= (others => '0');

        switch_state := true;
      end if;

      if(pstate = wait_res)then
        if(not waitcycle)then
          Sum <= Sum + add_mout;-- Ergebnis multba aufaddieren
          add_mout(47 downto 36) <= multout(11 downto 0);-- Ergebnis 
multbb
          waitcycle := true;
        else
          p <= Sum + add_mout;-- Wert ausgeben
          done <= '1';
          switch_state := true;
        end if;
      end if;
    end if;

  end process;
end bhv;

von Philip K. (plip)


Lesenswert?

Die vorige Frage hat sich erledigt, hab falschen Wert für N verwendet...

von Kest (Gast)


Lesenswert?

Siehe Xilinx xapp467:

"Each embedded multiplier block (MULT18X18 primitive) supports two 
independent dynamic data input ports: 18-bit signed or 17-bit unsigned."

Da Du 18 bit unsigned hast (das gleiche wie std_logic_vector), werden 
daraus 2 MUL(tiplizierer) gebaut.

Grüße

Kest

von Philip K. (plip)


Lesenswert?

Ok, danke!

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.