Advertisement
Guest User

Untitled

a guest
May 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.std_logic_1164.all;
  3. use IEEE.NUMERIC_std.all;
  4.  
  5. entity Rest is
  6. port(E: in std_logic;
  7. CLK: in std_logic;
  8. tip: in std_logic_vector(2 downto 0);
  9. --Banc: in std_logic_vector(7 downto 0);
  10. SumaIn: in std_logic_vector(7 downto 0);
  11. nr_banc: out std_logic_vector(7 downto 0);
  12. REST: out std_logic_vector(15 downto 0));
  13. end Rest;
  14.  
  15. architecture Arch_Rest of Rest is
  16. signal valoare : std_logic_vector(7 downto 0);
  17. begin
  18. process(CLK,SumaIN,tip)
  19. variable b: std_logic_vector(7 downto 0);
  20. variable R: std_logic_vector(15 downto 0);
  21. begin
  22. if E = '1' then
  23. case tip is
  24. when "111" => valoare <= "00110010";
  25. when "110" => valoare <= "00010100";
  26. when "101" => valoare <= "00001010";
  27. when "100" => valoare <= "00000101";
  28. when "011" => valoare <= "00000010";
  29. when "010" => valoare <= "00000001";
  30. when others => NULL;
  31. end case;
  32. if std_logic_vector(unsigned(SumaIn) / unsigned(valoare)) > "00000000" then
  33. b := std_logic_vector(unsigned(SumaIn) / unsigned(valoare));
  34. R := std_logic_vector(unsigned(SumaIn) - unsigned(b) * unsigned(valoare));
  35. else
  36. R := "0000000000000000";
  37. b := "00000000";
  38. end if;
  39. end if;
  40. nr_banc <= b;
  41. REST <=R;
  42. end process;
  43. end Arch_Rest;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement