Advertisement
Guest User

Untitled

a guest
May 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4.  
  5. entity Projekt_processor is
  6. port (
  7. A : in signed(15 downto 0);
  8. B : in signed(15 downto 0);
  9. Salu : in bit_vector (3 downto 0);
  10. LDF : in bit;
  11. clk : in bit;
  12. Y : out signed (15 downto 0);
  13. C,Z,S : out std_logic
  14. );
  15. end entity;
  16. architecture rtl of Projekt_processor is
  17. begin
  18. process (Salu, A, B, clk)
  19. variable res, AA, BB, CC: signed (16 downto 0);
  20. variable CF,ZF,SF : std_logic;
  21. begin
  22. AA(16) := A(15);
  23. AA(15 downto 0) := A;
  24. BB(16) := B(15);
  25. BB(15 downto 0) := B;
  26. CC(0) := CF;
  27. CC(16 downto 1) := "0000000000000000";
  28. case Salu is
  29. when "0000" => res := AA;
  30. when "0001" => res := AA + BB;
  31. when "0010" => res := AA - BB;
  32. when "0101" => res := shift_left(AA, signed(BB));
  33. when "0111" => res := shift_right(AA,signed(BB));
  34. when "1111" => res(16) := AA(16);
  35. res(15 downto 0) := AA(16 downto 1);
  36. end case;
  37. Y <= res(15 downto 0);
  38. Z <= ZF;
  39. S <= SF;
  40. C <= CF;
  41. if (clk'event and clk='1') then
  42. if (LDF='1') then
  43. if (res = "00000000000000000") then ZF:='1';
  44. else ZF:='0';
  45. end if;
  46. if (res(15)='1') then SF:='1';
  47. else SF:='0'; end if;
  48. CF := res(16) xor res(15);
  49. end if;
  50. end if;
  51. end process;
  52. end rtl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement