Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Multiplication on floating point format

question: in order to use the quartus ii to do the calculation (multiplication) of floating point, may i know what is the format type used in quartus ii to convert the floating point value to binary? thanks

19 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you need create an interface to the megafunction, but the megafunction itself already exists in the altera libraries.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Sorry to ask this, how to create an interface to the megafunction? I never use this function.

    for example this is my previous codes:

    library ieee;

    use ieee.std_logic_1164.all;

    library floatfixlib;

    use floatfixlib.fixed_pkg.all;

    entity my_mult is

    port (

    clk : in std_logic;

    a,b : in sfixed(3 downto -4);

    c : out sfixed(7 downto -8)

    );

    end entity my_mult;

    architecture rtl of my_mult is

    begin

    mult_proc : process(clk)

    begin

    if rising_edge(clk) then

    c <= a * b;

    end if;

    end process;
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you are using fixed point, not floating. There is no need to instantiate floating point megafunctions.

    But the megawizard creates the files and component declarations you need. You just connect it up with a port map

    ie.

    
    my_inst : some_entity
    port map (
      clk     => clk,
      input1 => signal1,
      input2 => signal2
      ....etc
    );
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Yes the code above is doing fixed point. i also doing for floating point.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    how are you doing floating point? the floatfixpkg.float_pkg.all will not produce very good hardware results.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Yeah... i plan to do new program for floating point application. But the problem is i still don't know how to start the programming. i still figure it out. Do you have any sample coding for others application like addition or subtraction? what library to include and the method of writing the code?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You need to create VHD files from the mega wizard. You should also get a .cmp file, that contains the component declaration. Copy and paste this into your design file, and conecct up the ports something like this:

    
    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;
    entity fpadder is
      
      port (
        
        ------------------------------------------------------------
        --Clock and reset
        ------------------------------------------------------------
        clk                       : in  std_logic;
        
        a,b                       : in  std_logic_vector(31 downto 0);
        c                         : out std_logic_vector(31 downto 0);
      );
    end entity;
      
    architecture rtl of fpadder is
      
      component my_fpadder
        PORT
        (
            clock        : IN STD_LOGIC ;
            dataa        : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
            datab        : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
            result        : OUT STD_LOGIC_VECTOR (31 DOWNTO 0)
        );
    end component;
      
    begin
      
      inst1 : my_fpadder
      port map (
        clock  => clk,
        dataa  => a,
        datab  => b,
        result => c
      );
      
    end rtl;
    

    Then include your source file and the megawizard generated .vhd file in your project.