LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.all;
ENTITY fdiv2 IS
PORT (
CLK : IN STD_LOGIC;
PM : OUT STD_LOGIC;
D : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
DOUT : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
RST : IN STD_LOGIC
);
END fdiv2;
ARCHITECTURE trans OF fdiv2 IS
SIGNAL Q1 : STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL FULL : STD_LOGIC;
SIGNAL LD : STD_LOGIC;
BEGIN
PROCESS (CLK, LD, RST)
BEGIN
IF ((NOT(RST)) = '1') THEN
Q1 <= "0000";
FULL <= '0';
ELSIF (LD = '1') THEN
Q1 <= D;
FULL <= '1';
ELSIF (CLK'EVENT AND CLK = '1') THEN
Q1 <= Q1 + "0001";
FULL <= '0';
END IF;
END PROCESS;