Line 27... |
Line 27... |
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use work.powerGrid.all;
|
use work.powerGrid.all;
|
|
|
|
|
entity kComparisonCell is
|
entity kComparisonCell is
|
generic ( W : integer := 32 );
|
generic (
|
|
RK : string := "yes";
|
|
W1 : integer := 32
|
|
);
|
port (
|
port (
|
clk,rst : in std_logic;
|
clk,rst : in std_logic;
|
|
scanOut : in std_logic; -- This signals overrides the 'signed greater or equal than' internal function and allows vdinput to flow upwards.
|
nxtSphere : in std_logic; -- Controls when the sphere goes to the next Row.
|
nxtSphere : in std_logic; -- Controls when the sphere goes to the next Row.
|
pipeOn : in std_logic; -- Enables / Disable the upwarding flow.
|
pipeOn : in std_logic; -- Enables / Disable the upwarding flow.
|
kinput : in std_logic_vector (W-1 downto 0);
|
kinput : in std_logic_vector (W1-1 downto 0);
|
koutput : out std_logic_vector (W-1 downto 0);
|
koutputhor : out std_logic_vector (W1-1 downto 0);
|
|
koutputver : out std_logic_vector (W1-1 downto 0); -- K input flowing to the next floor upstairs (but waits one clock).
|
vdinput : in std_logic_vector (W-1 downto 0); -- V.D input.
|
vdinput : in std_logic_vector (W1-1 downto 0); -- V.D input.
|
vdoutput : out std_logic_vector (W-1 downto 0) -- Selected dot product.
|
vdoutput : out std_logic_vector (W1-1 downto 0) -- Selected dot product.
|
|
|
|
|
);
|
);
|
end port;
|
|
end entity;
|
end entity;
|
|
|
|
|
architecture rtl of kComparisonCell is
|
architecture rtl of kComparisonCell is
|
|
|
signal ssge32 : std_logic; -- Signed "Greater or equal than" signal.
|
signal ssge32 : std_logic; -- Signed "Greater or equal than" signal.
|
|
signal sena : std_logic; -- Enable internal signal
|
|
signal disc : std_logic;
|
begin
|
begin
|
|
|
comparison : sge32 port map (
|
-- Enable resolution
|
|
sena <= pipeOn or scanOut;
|
|
disc <= ssge32 or scanOut;
|
|
|
|
-- Enable
|
|
kcomp : sge32
|
|
port map (
|
dataa => vdinput,
|
dataa => vdinput,
|
datab => kinput,
|
datab => kinput,
|
AgeB => ssge32
|
AgeB => ssge32
|
);
|
);
|
|
|
|
|
|
|
-- When ssge32 (greater or equal signal) is set then V.D > kte, therefore intersection is confirmed and V.D is to be shifted to the distance comparison grid.
|
-- When ssge32 (greater or equal signal) is set then V.D > kte, therefore intersection is confirmed and V.D is to be shifted to the distance comparison grid.
|
selector : process (rst,clk,ssg32,pipeOn)
|
selector : process (rst,clk,sena)
|
begin
|
begin
|
|
|
if rst='0' then
|
if rst='0' then
|
|
|
-- At the beginning set the Maximum over Maximum distance.
|
-- At the beginning set the Maximum over Maximum distance.
|
vdoutput <= '0' & (others =>'1');
|
vdoutput (W1-1)<= '0';
|
|
vdoutput (W1-2 downto 0) <= (others => '1');
|
|
koutputver <= (others => '0');
|
|
|
|
elsif rising_edge(clk) and sena='1' then
|
|
|
elsif rising_edge(clk) and pipeOn ='1' then
|
-- Flowing Upwards of vinput.
|
|
koutputver <= kinput;
|
|
|
if ssge32 = '1' then -- If VD ids grater or equal than K .....
|
if disc='1' then -- If VD ids grater or equal than K .....
|
vdoutput <= vdinput;
|
vdoutput <= vdinput;
|
else
|
else
|
vdoutput <= '0' & (others =>'1');
|
vdoutput(W1-1) <= '0';
|
|
vdoutput(W1-2 downto 0)<=( others => '1' );
|
end if;
|
end if;
|
|
|
end if;
|
end if;
|
|
|
end process;
|
end process;
|
|
|
|
|
|
|
|
|
-- Behavioral : When nxtSphere is set, the Sphere and its K constant should go the the next row
|
-- Behavioral : When nxtSphere is set, the Sphere and its K constant should go the the next row
|
|
kHorizontalPipeStage : if RK = "yes" generate
|
|
|
kPipeStage : process (clk,rst,nxtSphere)
|
process (clk,rst,nxtSphere)
|
begin
|
begin
|
|
|
if rst='0' then
|
if rst='0' then
|
|
|
koutput <= (others => '0');
|
koutputhor <= (others => '0');
|
|
|
elsif rising_edge(clk) and nxtSphere ='1' then
|
elsif rising_edge(clk) and nxtSphere ='1' then
|
|
|
koutput <= kinput;
|
koutputhor <= kinput;
|
|
|
end if;
|
end if;
|
|
|
end process;
|
end process;
|
|
|
|
end generate kHorizontalPipeStage;
|
|
|
|
|
end rtl;
|
end rtl;
|
|
|
|
|