Advertisement
Picko

(SP) 4.cviko

Oct 14th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.82 KB | None | 0 0
  1. ---------------------------------------
  2. library IEEE;
  3. use IEEE.STD_LOGIC_1164.ALL;
  4.  
  5.  
  6. entity nasobicka is
  7.     Port ( s : in  STD_LOGIC;
  8.            x : in  STD_LOGIC_VECTOR (width-1 downto 0);
  9.            y : in  STD_LOGIC_VECTOR (width-1 downto 0);
  10.            P : in  STD_LOGIC_VECTOR (2*width-1 downto 0);
  11.            done : out  STD_LOGIC);
  12. end nasobicka;
  13.  
  14. architecture Behavioral of nasobicka is
  15.  
  16. signal NL,NC : unsigned (width-1 downto 0);
  17. signal SC: unsigned (width downto 0);
  18. signal PC: integer range 0 to width;
  19.  
  20. type states is (smart, init, add, shift_NL,shift_SC,stop);
  21. signal state, next_state : state := start;
  22.  
  23. signal l1,l3 : std_logic;
  24. signal r_start : std_logic;
  25. signal R : std_logic_vector(1 to 6);
  26.  
  27. begin
  28.     l1 <= '1' when NL(0) = '1' else '0';
  29.     l3 <= '1' when PC < width else'0';
  30.    
  31.     NL_reg: process(clk) is
  32.         begin
  33.             if rising_edge(clk) then
  34.                 if r_start = '1' then
  35.                     NL <= x;
  36.                 elsif R (4) = '1' then
  37.                     NL <= SC(0) & NL(width-1 downto 1);
  38.                     end if;
  39.                     end if;
  40.                     end process;
  41.                    
  42.                     NC_reg: process (clk) is
  43.                         begin
  44.                             if rising_edge(clk) then
  45.                                 if r_start = '1' then
  46.                                     NC <= y;
  47.                                 end if;
  48.                             end if;
  49.                         end process;
  50.                                    
  51.                     SC_reg: process (clk) is
  52.                         begin
  53.                             if rising_edge(clk) then
  54.                                 if R (1) = '1' then
  55.                                     SC <= (others => '0');
  56.                                     elsif R(3) = '1' then
  57.                                     SC <= resize (SC+NC,Sc'length);
  58.                                     elsif R(5) = '1' then
  59.                                     SC <= '0' & SC(width downto 1);
  60.                                 end if;
  61.                             end if;
  62.                         end process;
  63.                            
  64.             P <= SC(width -1 downto 0) & NL;
  65.            
  66.             PC_reg: process (clk) is
  67.                 begin
  68.                     if rising_edge(clk) then
  69.                         if R(2) = '1' then
  70.                             PC<=0;
  71.                         elsif R(6) = '1' then
  72.                             PC <=PC+1;
  73.                         end if;
  74.                     end if;
  75.                 end process;
  76. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement