Advertisement
Florii11

Nr_binar_rev

May 10th, 2021
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.89 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.all;
  3. use IEEE.STD_LOGIC_UNSIGNED.all;
  4.  
  5. entity numarator is
  6.     port(EN,UP,CLK,MR,LD: in std_logic;
  7.     D:in std_logic_vector(3 downto 0);
  8.     CR,BR:out std_logic;
  9.     Q:out std_logic_vector(3 downto 0));
  10. end entity;
  11.  
  12. architecture comportamentala of numarator is
  13. begin
  14.     process(CLK,EN,MR,LD)
  15.     variable T:std_logic_vector(3 downto 0) := "0000";
  16.     variable c:std_logic:='0';
  17.     variable b:std_logic:='0';
  18.     begin
  19.         if(EN='0') then
  20.             T:=T;
  21.         else
  22.             if(MR='1') then
  23.                 T:="0000";
  24.             elsif(LD='1') then
  25.                 T:=D;
  26.             elsif(CLK'event and CLK='1') then
  27.                 if(UP='0') then
  28.                     T:=T+1;
  29.                     if(T="1111") then c:='1';
  30.                     else c:='0';
  31.                     end if;
  32.                 end if;
  33.                 if(UP='1') then
  34.                     T:=T-1;
  35.                     if(T="0000") then b:='1';
  36.                     else b:='0';
  37.                     end if;
  38.                 end if;
  39.             end if;
  40.         end if;
  41.         CR<=c;
  42.         BR<=b;
  43.         Q<=T;
  44.     end process;
  45. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement