00001 --**************************************************************
00002 --* *
00003 --* The source code for the ATLAS BCM "AAA" FPGA is made *
00004 --* available via the GNU General Public License (GPL) *
00005 --* unless otherwise stated below. *
00006 --* *
00007 --* In case of problems/questions/bug reports etc. please *
00008 --* contact michael.niegl@cern.ch *
00009 --* *
00010 --**************************************************************
00011
00012 --**************************************************************
00013 --* *
00014 --* $Source: /local/reps/bcmfpga/bcm_aaa/bcm_aaa/coin/comparator4.vhd,v $
00015 --* $Revision: 1.4.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:42 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023
00024 library ieee;
00025
00026 use ieee.std_logic_1164.all;
00027
00028 use ieee.std_logic_arith.all;
00029
00030 use ieee.std_logic_unsigned.all;
00031
00032 library unisim;
00033
00034 use unisim.vcomponents.all;
00035
00036
00037
00038
00039
00040 entity comparator4 is
00041 port (
00042 CLK : in ;
00043 SA : in ;
00044 SB : in ;
00045 SC : in ;
00046 SD : in ;
00047 A : in (5 downto 0);
00048 B : in (5 downto 0);
00049 C : in (5 downto 0);
00050 D : in (5 downto 0);
00051 SY : out ;
00052 Y : out (5 downto 0)
00053 );
00054 end comparator4;
00055
00056
00057
00058
00059 architecture comparator4_arc of comparator4 is
00060
00061 -------------------------- signals -----------------------------
00062 signal a_i : (5 downto 0) := (others => '0');
00063 signal b_i : (5 downto 0) := (others => '0');
00064 signal c_i : (5 downto 0) := (others => '0');
00065 signal d_i : (5 downto 0) := (others => '0');
00066 signal ab : (5 downto 0) := (others => '0');
00067 signal cd : (5 downto 0) := (others => '0');
00068 signal ab_i : (5 downto 0) := (others => '0');
00069 signal cd_i : (5 downto 0) := (others => '0');
00070 signal final : (5 downto 0) := (others => '0');
00071 signal res_ab : := '0';
00072 signal res_cd : := '0';
00073 signal res_end : := '0';
00074 signal or_stat : := '0';
00075
00076
00077 component comparator_v9_0
00078 port (
00079 a : in (5 downto 0);
00080 b : in (5 downto 0);
00081 clk : in ;
00082 ce : in ;
00083 a_ge_b : out ;
00084 qa_ge_b : out );
00085 end component;
00086
00087 begin
00088
00089 a_i <= A when SA = '1' else (others => '0');
00090 b_i <= B when SB = '1' else (others => '0');
00091 c_i <= C when SC = '1' else (others => '0');
00092 d_i <= D when SD = '1' else (others => '0');
00093
00094 comp_1 : comparator_v9_0
00095 port map (
00096 a => a_i ,
00097 b => b_i ,
00098 clk => CLK ,
00099 ce => '1' ,
00100 a_ge_b => res_ab,
00101 qa_ge_b => open);
00102
00103 comp_2 : comparator_v9_0
00104 port map (
00105 a => c_i ,
00106 b => d_i ,
00107 clk => CLK ,
00108 ce => '1' ,
00109 a_ge_b => res_cd,
00110 qa_ge_b => open);
00111
00112 ab_i <= a when res_ab = '1' else b;
00113 cd_i <= c when res_cd = '1' else d;
00114 or_stat <= SA or SB or SC or SD when rising_edge(CLK);
00115 ab <= ab_i when rising_edge(CLK);
00116 cd <= cd_i when rising_edge(CLK);
00117
00118 comp_3 : comparator_v9_0
00119 port map (
00120 a => ab ,
00121 b => cd ,
00122 clk => CLK ,
00123 ce => '1' ,
00124 a_ge_b => res_end,
00125 qa_ge_b => open);
00126
00127 final <= ab when res_end = '1' else cd;
00128 SY <= or_stat when rising_edge(CLK);
00129 Y <= final when rising_edge(CLK);
00130
00131 end comparator4_arc;
00132