Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.88 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 11/05/2019 09:52:20 AM
  6. -- Design Name:
  7. -- Module Name: UC - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20.  
  21.  
  22. library IEEE;
  23. use IEEE.STD_LOGIC_1164.ALL;
  24.  
  25. -- Uncomment the following library declaration if using
  26. -- arithmetic functions with Signed or Unsigned values
  27. --use IEEE.NUMERIC_STD.ALL;
  28.  
  29. -- Uncomment the following library declaration if instantiating
  30. -- any Xilinx leaf cells in this code.
  31. --library UNISIM;
  32. --use UNISIM.VComponents.all;
  33.  
  34. entity UC is
  35.     generic (N : integer);
  36.     Port ( clk : in STD_LOGIC;
  37.            shrAQ : out std_logic;
  38.            start : in STD_LOGIC;
  39.            term : out std_logic;
  40.            loadA : out std_logic;
  41.            loadB : out std_logic;
  42.            loadQ : out std_logic;
  43.            rsta : out std_logic;
  44.            subB : out std_logic;
  45.            rstQM1 : out std_logic;
  46.            q0qm1 : in std_logic_vector(1 downto 0));
  47.            
  48. end UC;
  49.  
  50. architecture Behavioral of UC is
  51. type state_type is (sstart, sq0q1, saplus, saminusb, sshift, scscad1, sstop);
  52. signal state : state_type ;
  53. signal c : integer := N;
  54. begin
  55.     process(clk)
  56.         begin
  57.         if rising_edge(clk) then
  58.             if state = sstart then
  59.                 loadB <= '1';
  60.                 rstA <= '1';
  61.                 loadQ <= '1';
  62.                 rstQM1 <= '1';
  63.                 state <= sq0q1;
  64.             elsif state = sq0q1 then
  65.                 if q0qm1 = "01" then
  66.                     subB <= '0';
  67.                     state <= saplus;
  68.                 elsif q0qm1 = "10" then
  69.                     subB <= '1';
  70.                     state <= saminusb;
  71.                 elsif q0qm1 = "11" then
  72.                     state <= sshift;
  73.                 elsif q0qm1 = "00" then
  74.                     state <= sshift;
  75.                 end if;
  76.             elsif state = saplus then
  77.                 state <= sshift;
  78.                 subB <= '0';
  79.                 loadA <= '1';
  80.             elsif state = saminusb then
  81.                 state <= sshift;
  82.                 subB <= '1';
  83.                 loadA <= '1';
  84.             elsif state = sshift then
  85.                 shrAQ <= '1';
  86.             elsif state = scscad1 then
  87.                 c <= c - 1;
  88.                 if c = 0 then
  89.                     state <= sstop;
  90.                 else
  91.                     state <= sq0q1;
  92.                 end if;
  93.             elsif state = sstop then
  94.                 term <= '1';
  95.             end if;
  96.             end if;
  97.            end process;
  98.            
  99.            
  100.                
  101.        
  102.  
  103. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement