-- Copyright © 1993 by McGraw-Hill, Inc. and Zainalabedin Navabi
-- FIGURE 5.4
-- ENTITY DECLARATION OF NIBBLE-COMPARATOR TEST BENCH :
ENTITY nibble_comparator_test_bench IS
END nibble_comparator_test_bench ;
--
-- PROCEDURAL ARCHITECTURE OF NIBBLE-COMPARATOR TEST BENCH :
ARCHITECTURE procedural OF nibble_comparator_test_bench IS
TYPE integer IS ARRAY (0 TO 12) OF INTEGER;
PROCEDURE apply_data
(SIGNAL target : OUT BIT_VECTOR (3 DOWNTO 0);
CONSTANT values : IN integers;
CONSTANT period : IN TIME )
IS
VARIABLE j: INTEGER;
VARIABLE tmp : INTEGER := O;
VARIABLE buf : BIT_VECTOR (3 DOWNTO 0);
BEGIN
FOR i IN 0 TO 12 LOOP
tmp:=values (i);
j:=0;
WHILE j <= 3
IF (tmp MOD 2 = 1) THEN
buf(j) := '1';
ELSE buf (j) := '0';
ENDIF;
tmp := tmp / 2;
j := j + 1 ;
END LOOP
target <= TRANSPORT buf AFTER i * period ;
END LOOP;
END apply_data;
COMPONENT comp4 PORT (
a, b : IN bit_vector (3 DOWNTO 0); gt, eq, lt : IN BIT;
a_gt_b, a_eq_b, a_lt_b : OUT BIT);
END COMPONENT;
FOR a1 : comp4 USE ENTITY WORK.nibble_comparator(structural);
SIGNAL a, b : BIT_VECTOR (3 DOWNTO 0);
SIGNAL eql, lss, gtr : BIT;
SIGNAL vdd : BIT := '1';
SIGNAL gnd : BIT := '0';
BEGIN
a1: comp4 PORT MAP (a, b, gnd, vdd, gnd, gtr, eql, lss);
apply_data (a, 00&15&15&14&14&14&14&10&00&15&00&00&15, 500 NS);
apply_data (b, 00&14&14&15&15&12&12&12&15&15&15&00&00, 500 NS);
END procedural;
--