-- ENTITIY DECLERATION OF 4 bit sorter , modified only detect less than: -- if A>=B output A,B ; otherwise output B,A ENTITY bit4_sorter IS PORT (a, b : IN BIT_VECTOR (3 DOWNTO 0); -- a and b data inputs lt : IN BIT; -- previous less than sorted_a, sorted_b: OUT BIT_VECTOR (3 DOWNTO 0)); --SORTED RESULTS END bit4_sorter; -- ITERATIVE ARCHITECTURE OF NIBBLE COMPARATOR : ARCHITECTURE iterative OF bit4_sorter IS COMPONENT comp1 PORT (a, b, lt : IN BIT; a_lt_b : OUT BIT); END COMPONENT; COMPONENT muxa1 PORT (a, b : IN BIT_VECTOR; c: IN BIT; o: OUT BIT_VECTOR); END COMPONENT; FOR ALL : comp1 USE ENTITY WORK.bit1_comp (gate_level); FOR ALL : muxa1 USE ENTITY WORK.mux (behavioral_level); SIGNAL im : BIT_VECTOR ( 0 TO 3); SIGNAL gnd : BIT := '0'; SIGNAL vdd : BIT := '1'; BEGIN c0: comp1 PORT MAP (a(0), b(0), gnd, im(0)); c1to2: FOR i IN 1 TO 2 GENERATE c: comp1 PORT MAP (a(i), b(i), im(i*1-1), im(i*1) ); END GENERATE; c3: comp1 PORT MAP (a(3), b(3), im(2), im(3)); -- sort based on a_lt_b result: r1: muxa1 PORT MAP (b, a, im(3), sorted_a); r2: muxa1 PORT MAP (a, b, im(3), sorted_b); END iterative;