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

Subversion Repositories jart

[/] [jart/] [branches/] [ver0branch/] [sqrt.vhd] - Diff between revs 68 and 69

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

Rev 68 Rev 69
Line 16... Line 16...
        port
        port
        (
        (
                clk,rst,ena : in std_logic;
                clk,rst,ena : in std_logic;
 
 
                radical         : in std_logic_vector (W2-1 downto 0);
                radical         : in std_logic_vector (W2-1 downto 0);
                sho                     : out std_logic;
                root            : out std_logic_vector ((W2/2)-1 downto 0)
                a,b,x,y         : out std_logic_vector ((W2/2)-1 downto 0);
 
                decoder         : out integer range 0 to (W2/2)-1
 
        );
        );
end entity;
end entity;
 
 
 
 
architecture rtl of sqrt is
architecture rtl of sqrt is
Line 34... Line 32...
        signal sa0,sb0,sx0,sy0,sb0_1            : std_logic_vector (WP-1 downto 0);
        signal sa0,sb0,sx0,sy0,sb0_1            : std_logic_vector (WP-1 downto 0);
        signal sa1,sb1,sx1,sy1,sb1_1,muxs1      : std_logic_vector (WP-1 downto 0);
        signal sa1,sb1,sx1,sy1,sb1_1,muxs1      : std_logic_vector (WP-1 downto 0);
        signal sa2,sb2,sx2,sy2                          : std_logic_vector (WP-1 downto 0);
        signal sa2,sb2,sx2,sy2                          : std_logic_vector (WP-1 downto 0);
        signal localenc1                                        : integer range 0 to WP-1;
        signal localenc1                                        : integer range 0 to WP-1;
        signal localenc2                                        : integer range 0 to WP-1;
        signal localenc2                                        : integer range 0 to WP-1;
 
        signal sho                                                      : std_logic;
 
        signal a,b,x,y                                          : std_logic_vector ((W2/2)-1 downto 0);
 
        signal decoder                                          : integer range 0 to (W2/2)-1;
 
        signal ab,xy                                            : std_logic_vector (W2-1 downto 0);
 
 
 
 
        begin
        begin
 
 
        -- Logic function signals ...... if some day there's a paper of how this logic circuit works, it will be easier to comprehend this block of code
        -- Logic function signals ...... if some day there's a paper of how this logic circuit works, it will be easier to comprehend this block of code
Line 51... Line 53...
                sy0(i)<=sb0(i) and sa0(i);
                sy0(i)<=sb0(i) and sa0(i);
 
 
                -- Stage 1 : Function for signal Y.
                -- Stage 1 : Function for signal Y.
                muxs1(i) <= sy1(i) or (not(sx1(i)) and sb1_1(i));
                muxs1(i) <= sy1(i) or (not(sx1(i)) and sb1_1(i));
 
 
 
                -- Stage 3 :
 
                ab(i*2)         <= b(i);
 
                ab(i*2+1)       <= a(i);
 
                xy(i*2)         <= y(i);
 
                xy(i*2+1)       <= x(i);
 
 
 
 
        end generate signalization;
        end generate signalization;
 
 
 
 
 
 
 
 
        stages: process (rst,clk,ena,sx0,sx1,localenc2)
        stages: process (rst,clk,ena,sx0,sx1,localenc2)
                variable localenc0 : integer range 0 to WP-1;
                variable localenc0 : integer range 0 to WP-1;
 
 
        begin
        begin
 
 
                -- Highest signifcant pair enconder : look for the bit pair with the most significant bit.
                -- Highest signifcant pair enconder : look for the bit pair with the most significant bit.
                localenc0 := WP-1;
                localenc0 := WP-1;
                stg0henc: while localenc0>0 loop
                stg0henc: while localenc0>0 loop
Line 96... Line 103...
                        x<=(others => '0');
                        x<=(others => '0');
                        y<=(others => '0');
                        y<=(others => '0');
                        a<=(others => '0');
                        a<=(others => '0');
                        b<=(others => '0');
                        b<=(others => '0');
 
 
 
                        --Stage 4
 
                        root <= (others=>'0');
 
 
 
 
 
 
                elsif rising_edge(clk) and ena='1' then
                elsif rising_edge(clk) and ena='1' then
 
 
                        -- Stage01 
                        -- Stage01 
Line 135... Line 145...
                        end if;
                        end if;
 
 
                        decoder<=localenc2;
                        decoder<=localenc2;
                        sho<=sa2(localenc2);
                        sho<=sa2(localenc2);
 
 
                        stage34
                        -- stage34
 
                        for i in 0 to WP-1 loop
 
                                if i>decoder then
 
                                        root(i)<='0';
 
                                elsif decoder-i>2 then
 
                                        root(i)<=ab(decoder+i+1);
 
                                elsif decoder-i=2 then
 
                                        root(i)<=(ab(decoder+i+1) and not(sho)) or (xy(decoder+i+1) and sho);
 
                                else
 
                                        root(i)<=xy(decoder+i+1);
                end if;
                end if;
 
                        end loop;
 
 
 
                end if;
 
 
        end process stages;
        end process stages;
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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