library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_signed.all; package MINE is type INTEGER_MATRIX is array (NATURAL RANGE <>, NATURAL RANGE <>) of integer; procedure addM (L, R : in INTEGER_MATRIX; RESULT : out INTEGER_MATRIX); end MINE; package BODY MINE is procedure addM (L, R : in INTEGER_MATRIX; RESULT : out INTEGER_MATRIX) is alias new_l : INTEGER_MATRIX(L'LENGTH(1) - 1 downto 0, L'LENGTH(2) - 1 downto 0) is L; alias new_r : INTEGER_MATRIX(R'LENGTH - 1 downto 0) is R; begin if (L'LENGTH /= R'LENGTH) then report "Ranges of operands are not the same" severity WARNING; return integer'LEFT; end if; for I in new_l'RANGE loop temp := temp + new_l(I)*new_r(I); end loop; return TEMP; end DOT_PRODUCT; end MINE; package body MINE is function SEARCH(VECTOR, SUBVECTOR : std_logic_vector) return integer is variable POSITION : integer; variable FOUND : boolean := FALSE; begin POSITION := -1; if (VECTOR'length < SUBVECTOR'length) then report "Incorrect usage of SEARCH function" severity error; return POSITION; end if; for I in VECTOR'length - 1 downto SUBVECTOR'length - 1 loop if not FOUND then if (VECTOR(I downto I - (SUBVECTOR'length -1)) = SUBVECTOR) then POSITION := I; FOUND := TRUE; end if; end if; end loop; return POSITION; end SEARCH; end MINE; architecture BEHAV of ELEVATOR_CONTROL is type STATE_TYPE is (F12, F22, F21, F11); signal CURRENT_STATE, NEXT_STATE : STATE_TYPE; begin process (FB1, CALL1, FB2, CALL2, FS1, FS2, DC, N1, N2, CURRENT_STATE) begin if (CURRENT_STATE = F12) then if (FS2 = '0') then UP <= '1'; NEXT_STATE <= F12; else R2 <= '1'; DO <= '1'; NEXT_STATE <= F22; end if; elsif (CURRENT_STATE = F22) then NEXT_STATE <= F22; if (N2 = '1') then R2 <= '1'; DO <= '1'; elsif (N1 = '1') then if (DC = '1') then DOWN <= '1'; NEXT_STATE <= F21; end if; end if; elsif (CURRENT_STATE = F21) then if (FS1 = '1') then R1 <= '1'; DO <= '1'; NEXT_STATE <= F11; else DOWN <= '1'; NEXT_STATE <= F21; end if; elsif (CURRENT_STATE = F11) then NEXT_STATE <= F11; if (N1 = '1') then R1 <= '1'; DO <= '1'; elsif (N2 = '1') then if (DC = '1') then UP <= '1'; NEXT_STATE <= F12; end if; end if; end if; end process; process (CLK) begin if (CLK = '1' and CLK'event) then CURRENT_STATE <= NEXT_STATE; end if; end process; end BEHAV;