Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- entity nasobicka is
- Port ( s : in STD_LOGIC;
- x : in STD_LOGIC_VECTOR (width-1 downto 0);
- y : in STD_LOGIC_VECTOR (width-1 downto 0);
- P : in STD_LOGIC_VECTOR (2*width-1 downto 0);
- done : out STD_LOGIC);
- end nasobicka;
- architecture Behavioral of nasobicka is
- signal NL,NC : unsigned (width-1 downto 0);
- signal SC: unsigned (width downto 0);
- signal PC: integer range 0 to width;
- type states is (smart, init, add, shift_NL,shift_SC,stop);
- signal state, next_state : state := start;
- signal l1,l3 : std_logic;
- signal r_start : std_logic;
- signal R : std_logic_vector(1 to 6);
- begin
- l1 <= '1' when NL(0) = '1' else '0';
- l3 <= '1' when PC < width else'0';
- NL_reg: process(clk) is
- begin
- if rising_edge(clk) then
- if r_start = '1' then
- NL <= x;
- elsif R (4) = '1' then
- NL <= SC(0) & NL(width-1 downto 1);
- end if;
- end if;
- end process;
- NC_reg: process (clk) is
- begin
- if rising_edge(clk) then
- if r_start = '1' then
- NC <= y;
- end if;
- end if;
- end process;
- SC_reg: process (clk) is
- begin
- if rising_edge(clk) then
- if R (1) = '1' then
- SC <= (others => '0');
- elsif R(3) = '1' then
- SC <= resize (SC+NC,Sc'length);
- elsif R(5) = '1' then
- SC <= '0' & SC(width downto 1);
- end if;
- end if;
- end process;
- P <= SC(width -1 downto 0) & NL;
- PC_reg: process (clk) is
- begin
- if rising_edge(clk) then
- if R(2) = '1' then
- PC<=0;
- elsif R(6) = '1' then
- PC <=PC+1;
- end if;
- end if;
- end process;
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement