Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5. entity kombimreze is
  6. port(
  7. iSW: in std_logic_vector(7 downto 0);
  8. iINV: in std_logic;
  9. oLED: out std_logic_vector(7 downto 0);
  10. oSIGN: out std_logic;
  11. oGREAT: out std_logic
  12. );
  13. end entity;
  14.  
  15. architecture Behavioral of kombimreze is
  16. signal sZBIR : std_logic_vector(3 downto 0);
  17. signal sIND: std_logic_vector(2 downto 0);
  18. signal sLED: std_logic_vector(7 downto 0);
  19. signal sA: std_logic_vector(1 downto 0);
  20. signal sB: std_logic_vector(1 downto 0);
  21. begin
  22.  
  23. process(iINV, iSW) begin
  24. if(iSW(6) = '1' and iSW(2) = '0') then
  25. sZBIR <= (not("00" & iSW(5 downto 4)) + '1') + ('0' & iSW(2 downto 0));
  26.  
  27. elsif (iSW(6) = '0' and iSW(2) = '1') then
  28. sZBIR <= ('0' & iSW(6 downto 4)) + (not("00" & iSW(1 downto 0)) + '1');
  29.  
  30. elsif(iSW(6) = '1' and iSW(2) = '1') then
  31. sZBIR <= (not("00" & iSW(5 downto 4)) + '1') + (not("00" & iSW(1 downto 0)) + '1');
  32.  
  33. else
  34. sZBIR <= ('0' & iSW(6 downto 4)) + ('0' & iSW(2 downto 0));
  35.  
  36. end if;
  37. end process;
  38.  
  39. sIND <= "000" when iSW(0) = '1' else
  40. "001" when iSW(1) = '1' else
  41. "010" when iSW(2) = '1' else
  42. "011" when iSW(3) = '1' else
  43. "100" when iSW(4) = '1' else
  44. "101" when iSW(5) = '1' else
  45. "110" when iSW(6) = '1' else
  46. "111" when iSW(7) = '1' else
  47. "000";
  48.  
  49. sLED <= sIND & '1' & sZBIR;
  50.  
  51. oSIGN <= sLED(3) when iINV = '0' else
  52. '0';
  53.  
  54. sA <= iSW(5 downto 4);
  55. sB <= iSW(1 downto 0);
  56.  
  57. process(sA, sB, iSW) begin
  58.  
  59. if (iSW(6) = '0') and (iSW(2) = '1') then
  60. oGREAT <= '1';
  61.  
  62. elsif (iSW(6) = '0') and (iSW(2) = '0') and (sA > sB) then
  63. oGREAT <= '1';
  64.  
  65. elsif (iSW(6) = '1') and (iSW(2) = '1') and (sA < sB) then
  66. oGREAT <= '1';
  67.  
  68. else
  69. oGREAT <= '0';
  70.  
  71. end if;
  72.  
  73. end process;
  74.  
  75. oLED <= sLED when iINV = '0' else
  76. not(iSW);
  77.  
  78. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement