Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------------
- -- Barrelshifter fuer LSL, LSR, ASR, ROR mit Shiftweiten von 0 bis 3 (oder
- -- generisch n-1) Bit.
- --------------------------------------------------------------------------------
- -- Datum: ??.??.2013
- -- Version: ?.?
- --------------------------------------------------------------------------------
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.numeric_std.all;
- use ieee.std_logic_signed.all;
- --use ieee.math_real.all;
- entity ArmBarrelShifter is
- --------------------------------------------------------------------------------
- -- Breite der Operanden (n) und die Zahl der notwendigen
- -- Multiplexerstufen (m) um Shifts von 0 bis n-1 Stellen realisieren zu
- -- koennen. Es muss gelten: ???
- --------------------------------------------------------------------------------
- generic (OPERAND_WIDTH : integer := 4;
- SHIFTER_DEPTH : integer := 2;
- );
- port ( OPERAND : in std_logic_vector(OPERAND_WIDTH-1 downto 0);
- MUX_CTRL : in std_logic_vector(1 downto 0);
- AMOUNT : in std_logic_vector(SHIFTER_DEPTH-1 downto 0);
- ARITH_SHIFT : in std_logic;
- C_IN : in std_logic;
- DATA_OUT : out std_logic_vector(OPERAND_WIDTH-1 downto 0);
- C_OUT : out std_logic
- );
- end entity ArmBarrelShifter;
- architecture structure of ArmBarrelShifter is
- signal data: std_logic_vector(OPERAND_WIDTH-1 downto 0);
- begin
- --Linksshifter
- lsl_k : for k in 0 to SHIFTER_DEPTH-1 generate
- --erste ebene
- lsl_i : for i in 0 to OPERAND_WIDTH-1 generate
- С_OUT <= C_IN when C_IN = '0' else
- data(OPERAND_WIDTH); --MSB
- data(i) <= OPERAND(i) when AMOUNT(k) = '0' else
- C_IN when i <= k else
- OPERAND(i-1);
- end generate;
- end generate;
- --Rechtsshifter hier benutzen wir OPERAND(i) wobei es eig data(i) sein muss damit es auch bei ebenen > 1 funktioniert
- lsr_k : for k in 0 to SHIFTER_DEPTH-1 generate
- --erste ebene
- lsr_i: for i in OPERAND_WIDTH-1 downto 0 generate
- С_OUT <= C_IN when C_IN = '0' else
- data(0); --LSB
- data(i) <= OPERAND(i) when AMOUNT(k) = '0' else
- C_IN when i > (SHIFTER_DEPTH - k) else
- OPERAND(i+1);
- end generate;
- end generate;
- --Rechtsshifter A
- asr_k : for k in 0 to SHIFTER_DEPTH-1 generate
- --erste ebene
- asr_i: for i in OPERAND_WIDTH-1 downto 0 generate
- data(i) <= OPERAND(i) when AMOUNT(k) = '0' else
- OPERAND(OPERAND_WIDTH-1) when i > (SHIFTER_DEPTH - k) else
- OPERAND(i+1);
- end generate;
- end generate;
- --ROTATION
- rotate_k : for k in 0 to SHIFTER_DEPTH-1 generate
- -- Erste Ebene
- rotate_i : for i in 0 to OPERAND_WIDTH-1 generate
- С_OUT <= C_IN when C_IN = '0' else
- data(0); --LSB
- data(i) <= OPERAND(i) when AMOUNT(k) = '0' else
- OPERAND((i + 1 + k) mod OPERAND_WIDTH);
- end generate;
- end generate;
- DATA_OUT <= data;
- end architecture structure;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement