Guest User

Untitled

a guest
Jun 29th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.11 KB | None | 0 0
  1. -- Johannes Jansson
  2. -- 900921-2839
  3. -- johjans@student.chalmers.se
  4. -- Hand-in 2.5
  5.  
  6. LIBRARY ieee;
  7. USE IEEE.STD_LOGIC_1164.ALL;
  8. USE IEEE.STD_LOGIC_UNSIGNED.ALL;
  9.  
  10. ENTITY cnt74163 IS
  11.   PORT (clock, clear, load, enablep, enablet: IN  STD_LOGIC;
  12.         d:                                    IN  STD_LOGIC_VECTOR(3 DOWNTO 0);
  13.         q:                                    OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
  14.         rco:                                  OUT STD_LOGIC);
  15. END cnt74163;
  16.  
  17. ARCHITECTURE arch_cnt74163 OF cnt74163 IS
  18.   signal qnext,qcopy: std_logic_vector(3 downto 0);
  19. BEGIN
  20.   PROCESS(clock) BEGIN
  21.     if clock'event and clock = '1' then
  22.       qcopy <= qnext;
  23.     end if;
  24.   end process;
  25.   q <= qcopy;
  26.   process(qcopy,d,clear,load,enablep,enablet) begin
  27.     rco <= '0';
  28.     if qcopy = "1111" and enablet = '1' then
  29.       rco <= '1';
  30.     end if;
  31.     if clear = '0' then
  32.       qnext <= (others => '0');
  33.     elsif load = '0' then
  34.       qnext <= d;
  35.     elsif enablep = '1' and enablet = '1' then
  36.       qnext <= qcopy + '1';
  37.     else
  38.       qnext <= qcopy;
  39.     end if;
  40.   end process;
  41. end arch_cnt74163;
Add Comment
Please, Sign In to add comment