OpenCores
URL https://opencores.org/ocsvn/raytrac/raytrac/trunk

Subversion Repositories raytrac

[/] [raytrac/] [trunk/] [sqrtdiv/] [sqrtdiv.vhd] - Diff between revs 80 and 81

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 80 Rev 81
Line 32... Line 32...
entity sqrtdiv is
entity sqrtdiv is
        generic (
        generic (
                reginput: string        := "YES";
                reginput: string        := "YES";
                c3width : integer       := 18;
                c3width : integer       := 18;
                functype: string        := "INVERSION";
                functype: string        := "INVERSION";
                iwidth  : integer       := 18;
                iwidth  : integer       := 32;
                owidth  : integer       := 18;
 
                awidth  : integer       := 9
                awidth  : integer       := 9
        );
        );
        port (
        port (
                clk,rst : in std_logic;
                clk,rst : in std_logic;
                value   : in std_logic_vector (iwidth-1 downto 0);
                value   : in std_logic_vector (iwidth-1 downto 0);
                zero    : out std_logic;
                zero    : out std_logic;
                result  : out std_logic_vector (owidth-1 downto 0)
 
 
                sqr             : out std_logic_vector (15 downto 0);
 
                inv             : out std_logic_vector (16 downto 0)
        );
        );
end sqrtdiv;
end sqrtdiv;
 
 
architecture sqrtdiv_arch of sqrtdiv is
architecture sqrtdiv_arch of sqrtdiv is
 
 
Line 58... Line 59...
        --! funky::Segunda etapa: Calculo del valor de la funcion evaluada en f.
        --! funky::Segunda etapa: Calculo del valor de la funcion evaluada en f.
        signal funkyadd                 : std_logic_vector (2*awidth-1 downto 0);
        signal funkyadd                 : std_logic_vector (2*awidth-1 downto 0);
        signal funkyexp                 : std_logic_vector (2*integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
        signal funkyexp                 : std_logic_vector (2*integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
        signal funkyzero                : std_logic;
        signal funkyzero                : std_logic;
 
 
        signal funkyq                   : std_logic_vector (2*c3width+3 downto 0);
        signal funkyq                   : std_logic_vector (2*c3width-1  downto 0);
        signal funkyselector    : std_logic;
        signal funkyselector    : std_logic;
 
 
        --! cumpa::Tercera etapa: Selecci'on de valores de acuerdo al exp escogido.
        --! cumpa::Tercera etapa: Selecci'on de valores de acuerdo al exp escogido.
        signal cumpaexp                 : std_logic_vector (2*integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
        signal cumpaexp                 : std_logic_vector (2*integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
        signal cumpaq                   : std_logic_vector (2*c3width+3 downto 0);
        signal cumpaq                   : std_logic_vector (2*c3width-1 downto 0);
        signal cumpaselector    : std_logic;
        signal cumpaselector    : std_logic;
        signal cumpazero                : std_logic;
        signal cumpazero                : std_logic;
 
 
        signal cumpaN                   : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
        signal cumpaN                   : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
        signal cumpaF                   : std_logic_vector (c3width+1 downto 0);
        signal cumpaF                   : std_logic_vector (c3width-1 downto 0);
 
 
        --! chief::Cuarta etapa: Corrimiento a la izquierda o derecha, para el caso de la ra'iz cuadrada o la inversi'on respectivamente. 
        --! chief::Cuarta etapa: Corrimiento a la izquierda o derecha, para el caso de la ra'iz cuadrada o la inversi'on respectivamente. 
 
 
        signal chiefN                   : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
        signal chiefN                   : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
        signal chiefF                   : std_logic_vector (c3width+1 downto 0);
        signal chiefF                   : std_logic_vector (c3width-1 downto 0);
 
        signal chiefQ                   : std_logic_vector (c3width-1 downto 0);
 
 
 
        --! inverseDistance::Quinta etapa
 
 
 
        signal iDistN                   : std_logic_vector (integer(ceil(log(real(iwidth),2.0)))-1 downto 0);
 
        signal iDistF                   : std_logic_vector (c3width-1 downto 0);
        --! Constantes para manejar el tamaño de los vectores
        --! Constantes para manejar el tamaño de los vectores
        constant exp1H : integer := 2*integer(ceil(log(real(iwidth),2.0)))-1;
        constant exp1H : integer := 2*integer(ceil(log(real(iwidth),2.0)))-1;
        constant exp1L : integer := integer(ceil(log(real(iwidth),2.0)));
        constant exp1L : integer := integer(ceil(log(real(iwidth),2.0)));
        constant exp0H : integer := exp1L-1;
        constant exp0H : integer := exp1L-1;
        constant exp0L : integer := 0;
        constant exp0L : integer := 0;
Line 87... Line 92...
        constant add1L : integer := awidth;
        constant add1L : integer := awidth;
        constant add0H : integer := awidth-1;
        constant add0H : integer := awidth-1;
        constant add0L : integer := 0;
        constant add0L : integer := 0;
 
 
 
 
        constant c3qHH : integer := 2*c3width+3;
        constant c3qHH : integer := 2*c3width-1;
        constant c3qHL : integer := c3width+2;
        constant c3qHL : integer := c3width;
        constant c3qLH : integer := c3width+1;
        constant c3qLH : integer := c3width-1;
        constant c3qLL : integer := 0;
        constant c3qLL : integer := 0;
 
 
begin
begin
 
 
        --! expomantis.
        --! expomantis.
Line 145... Line 150...
                else
                else
                        funkyselector<='1';
                        funkyselector<='1';
                end if;
                end if;
        end process funkyget;
        end process funkyget;
 
 
        funkyinversion:
 
        if functype="INVERSION" generate
 
                meminvr:func
 
                generic map (memoryPath&"meminvr.mif")
 
                port map(
 
                        expomantisadd(awidth-1 downto 0),
 
                        expomantisadd(2*awidth-1 downto awidth),
 
                        clk,
 
                        funkyq(c3qLH-2 downto c3qLL),
 
                        funkyq(c3qHH-2 downto c3qHL));
 
 
 
        end generate funkyinversion;
 
        funkysquare_root:
        sqrt: funcinvr
        if functype="SQUARE_ROOT" generate
 
                sqrt: func
 
                generic map (memoryPath&"memsqrt.mif")
                generic map (memoryPath&"memsqrt.mif")
                port map(
                port map(
                        expomantisadd(awidth-1 downto 0),
                funkyadd(awidth-1 downto 0),
                        (others => '0'),
 
                        clk,
                        clk,
                        funkyq(c3qLH-2 downto c3qLL),
                funkyq(c3qLH downto c3qLL));
                        open);
 
 
 
                sqrt2x: func
        sqrt2x: funcinvr
                generic map (memoryPath&"memsqrt2f.mif")
                generic map (memoryPath&"memsqrt2f.mif")
                port map(
                port map(
                        (others => '0'),
                funkyadd(2*awidth-1 downto awidth),
                        expomantisadd(2*awidth-1 downto awidth),
 
                        clk,
                        clk,
                        open,
                funkyq(c3qHH downto c3qHL));
                        funkyq(c3qHH-2 downto c3qHL));
 
 
 
        end generate funkysquare_root;
 
 
 
        --! cumpa.
        --! cumpa.
        cumpaProc:
        cumpaProc:
        process (clk,rst)
        process (clk,rst)
        begin
        begin
Line 207... Line 195...
                        cumpaN<=cumpaexp(exp1H downto exp1L);
                        cumpaN<=cumpaexp(exp1H downto exp1L);
                        cumpaF<=cumpaq(c3qHH downto c3qHL);
                        cumpaF<=cumpaq(c3qHH downto c3qHL);
                end if;
                end if;
        end process cumpaMux;
        end process cumpaMux;
 
 
        --! chief.
        --! Branching.
 
        -- exp <= chiefN;
 
        -- fadd <= chiefF(c3width-2 downto c3width-1-awidth);
        chiefProc:
        chiefProc:
        process (clk,rst)
        process (clk,rst)
        begin
        begin
                if rst=rstMasterValue then
                if rst=rstMasterValue then
                        chiefF <= (others => '0');
                        chiefF <= (others => '0');
Line 221... Line 211...
                        chiefN <= cumpaN;
                        chiefN <= cumpaN;
                        zero <= cumpazero;
                        zero <= cumpazero;
                end if;
                end if;
        end process chiefProc;
        end process chiefProc;
        chiefShifter: RLshifter
        chiefShifter: RLshifter
        generic map(functype,c3width+2,iwidth,owidth)
        generic map("SQUARE_ROOT",c3width,iwidth,16)
        port map(
        port map(
                chiefN,
                chiefN,
                chiefF,
                chiefF,
                result);
                sqr);
 
        branching_invfunc:
 
        if functype="INVERSION" generate
 
                sqrt: funcinvr
 
                generic map (memoryPath&"meminvr.mif")
 
                port map(
 
                        chiefF(c3width-2 downto c3width-1-awidth),
 
                        clk,
 
                        chiefQ(c3width-1 downto 0));
 
 
 
 
 
 
 
        end generate branching_invfunc;
 
 
 
        branchingHighLander:
 
        if functype="SQUARE_ROOT" generate
 
                chiefQ <= (others => '0');
 
        end generate branchingHighLander;
 
 
 
        --! Inverse
 
        inverseDistanceOK:
 
        if functype="INVERSION" generate
 
 
 
                inverseDistance:
 
                process (clk,rst)
 
                begin
 
 
 
                        if rst=rstMasterValue then
 
                                iDistN <= (others => '0');
 
                                iDistF <= (others => '0');
 
                        elsif clk'event and clk='1' then
 
                                iDistN <= chiefN;
 
                                iDistF <= chiefQ;
 
                        end if;
 
 
 
 
 
                end process inverseDistance;
 
 
 
                inverseShifter: RLshifter
 
                generic map("INVERSION",c3width,iwidth,17)
 
                port map(
 
                        iDistN,
 
                        iDistF,
 
                        inv);
 
        end generate inverseDistanceOK;
 
 
 
        inverseDistanceNOTOK:
 
        if functype = "SQUARE_ROOT" generate
 
                iDistN <= (others => '0');
 
                iDistF <= (others => '0');
 
                inv <= (others => '0');
 
        end generate inverseDistanceNOTOK;
 
 
end sqrtdiv_arch;
end sqrtdiv_arch;
 
 
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.