-- ############################################################################ -- # Project : Leonardo CBT-Kernel # -- # # -- # Filename : increments_decrements.vhd # -- # # -- # Component : incdecN : N-bit incrementer/decrementer # -- # # -- # Model : rtl # -- # # -- # Designer : S. Theoharis,N. Zervas # -- # Institute : VLSI Design Lab., University of Patras # -- # Date : 01.05.1999 # -- ############################################################################ library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use work.useful_functions.all; -- incdecN Entity Description entity incdecN is generic(N: INTEGER := 4); port( A: in unsigned(N-1 downto 0); D: out unsigned(N-1 downto 0); DN,UP: in std_ulogic; COUT,ZERO: out std_ulogic ); end incdecN; -- incdecN Architecture Description architecture rtl of incdecN is signal extended : unsigned(N downto 0); begin INC_DEC_Process: process(A,UP,DN) begin if (UP = '1') and (DN = '1') then -- UP and DN cancel each other extended <= ('0' & A); elsif (UP = '1') then extended <= ('0' & A) + "01"; elsif (DN = '1') then extended <= ('0' & A) - "01"; else extended <= ('0' & A); end if; end process INC_DEC_Process; -- Assign output values D <= extended(N-1 downto 0); COUT <= extended(N); ZERO <= '1' when vector_eq_zero(extended(N-1 downto 0)) else '0'; end rtl;