Você está na página 1de 1

entity divisor_int is --generic(n: integer :=100); Port (numer,denom: in INTEGER range -99 to 99; detect_rst: out bit; verst:

out integer; divd: out integer range -99 to 99); end; architecture behavior of divisor_int is signal aux_rst: integer range -99 to 99; begin process(num,den) begin IF (num<0 and den<0) or (num>0 and den>0) then aux_rst <= ((num REM den)*100/den); verst <= aux_rst; IF aux_rst=0 then divd <= num/den; detect_rst <= '0'; -- Detecta resto nvel baixo(no tem resto) ELSEIF aux_rst/=0 and aux_rst>=56 then divd <= (num/den) + 1; detect_rst <= '1'; -- Detecta que existe resto (nvel alto) ELSEIF aux_rst/=0 and aux_rst<=55 then divd <= num/den; detect_rst <= '1'; -- Detecta que existe resto (nvel alto) end IF; ELSEIF (num>0 and den<0) or (num<0 and den>0) then IF aux_rst=0 then divd <= num/den; detect_rst <= '0'; -- Detecta que no tem resto ELSEIF aux_rst/=0 and abs(aux_rst)>=56 then divd <=(num/den)-1; detect_rst <='1'; ELSEIF aux_rst/=0 and abs(aux_rst)<=55 then divd <= num/den; detect_rst <= '1'; end IF; end IF; end process; end behavior;

Você também pode gostar