00001 ------------------------------------------------------------------------------ 00002 -- This file is a part of the LPP VHDL IP LIBRARY 00003 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS 00004 -- 00005 -- This program is free software; you can redistribute it and/or modify 00006 -- it under the terms of the GNU General Public License as published by 00007 -- the Free Software Foundation; either version 3 of the License, or 00008 -- (at your option) any later version. 00009 -- 00010 -- This program is distributed in the hope that it will be useful, 00011 -- but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 -- GNU General Public License for more details. 00014 -- 00015 -- You should have received a copy of the GNU General Public License 00016 -- along with this program; if not, write to the Free Software 00017 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 ------------------------------------------------------------------------------- 00019 -- Author : Alexis Jeandet 00020 -- Mail : alexis.jeandet@lpp.polytechnique.fr 00021 ---------------------------------------------------------------------------- 00022 library IEEE; 00023 use IEEE.numeric_std.all; 00024 use IEEE.std_logic_1164.all; 00025 library lpp; 00026 use lpp.general_purpose.all; 00027 00028 00029 00030 entity RShifter is 00031 generic( 00032 Input_SZ : integer := 16; 00033 shift_SZ : integer := 4 00034 ); 00035 port( 00036 clk : in std_logic; 00037 reset : in std_logic; 00038 shift : in std_logic; 00039 OP : in std_logic_vector(Input_SZ-1 downto 0); 00040 cnt : in std_logic_vector(shift_SZ-1 downto 0); 00041 RES : out std_logic_vector(Input_SZ-1 downto 0) 00042 ); 00043 end entity; 00044 00045 00046 00047 00048 architecture ar_RShifter of RShifter is 00049 00050 signal REG : std_logic_vector(Input_SZ-1 downto 0); 00051 signal RESSHIFT: std_logic_vector(Input_SZ-1 downto 0); 00052 00053 begin 00054 00055 RES <= REG; 00056 RESSHIFT <= std_logic_vector(SHIFT_RIGHT(signed(OP),to_integer(unsigned(cnt)))); 00057 00058 process(clk,reset) 00059 begin 00060 if reset = '0' then 00061 REG <= (others => '0'); 00062 elsif clk'event and clk ='1' then 00063 if shift = '1' then 00064 REG <= RESSHIFT; 00065 end if; 00066 end if; 00067 end process; 00068 end ar_RShifter;
© Copyright 2011 LPP-CNRS | Design by Alexis Jeandet