library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.numeric_std.all;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity roror is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (3 downto 0));
end roror;
architecture Behavioral of roror is
signal a : std_logic_vector (3 downto 0);
signal b : std_logic_vector (3 downto 0);
begin
a<= "1000";
process (clk, rst)
begin
if (clk' event and clk = '1')then
b <= a ror 3;
end if;
end process;
q <= b;
end Behavioral;
Just before you start posting about the next error about signed/unsigned types not being visible, you need to remove the std_logic_arith library from your code.
Besides using possibly conflicting libraries, you didn't check at all which libraries define "ror" for which data types.
ror is defined in ieee.numeric_std, for unsigned and signed type only. It's not defined in the legacy synopsis libraries or ieee.std_1164. So it's pretty clear why ror can't work in your code.
ieee.numeric_std has however xror working for std_logic_vector.
And needless to say that you can easily write your own rotate operation for std_logic_vector.
Well, you didnt post the new code or the error, so we cannot help.
But you need to delete the library. numeric_std and std_logic_arith have clashes. std_logic_arith is non-standard and numeric_std should be used instead.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 --============================================================================ -- Shift and Rotate Functions --============================================================================ -- Id: S.1 function SHIFT_LEFT (ARG: UNSIGNED; COUNT: NATURAL) return UNSIGNED; -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) -- Result: Performs a shift-left on an UNSIGNED vector COUNT times. -- The vacated positions are filled with '0'. -- The COUNT leftmost elements are lost. -- Id: S.2 function SHIFT_RIGHT (ARG: UNSIGNED; COUNT: NATURAL) return UNSIGNED; -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) -- Result: Performs a shift-right on an UNSIGNED vector COUNT times. -- The vacated positions are filled with '0'. -- The COUNT rightmost elements are lost. -- Id: S.3 function SHIFT_LEFT (ARG: SIGNED; COUNT: NATURAL) return SIGNED; -- Result subtype: SIGNED(ARG'LENGTH-1 downto 0) -- Result: Performs a shift-left on a SIGNED vector COUNT times. -- The vacated positions are filled with '0'. -- The COUNT leftmost elements are lost. -- Id: S.4 function SHIFT_RIGHT (ARG: SIGNED; COUNT: NATURAL) return SIGNED; -- Result subtype: SIGNED(ARG'LENGTH-1 downto 0) -- Result: Performs a shift-right on a SIGNED vector COUNT times. -- The vacated positions are filled with the leftmost -- element, ARG'LEFT. The COUNT rightmost elements are lost. --============================================================================ -- Id: S.5 function ROTATE_LEFT (ARG: UNSIGNED; COUNT: NATURAL) return UNSIGNED; -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) -- Result: Performs a rotate-left of an UNSIGNED vector COUNT times. -- Id: S.6 function ROTATE_RIGHT (ARG: UNSIGNED; COUNT: NATURAL) return UNSIGNED; -- Result subtype: UNSIGNED(ARG'LENGTH-1 downto 0) -- Result: Performs a rotate-right of an UNSIGNED vector COUNT times. -- Id: S.7 function ROTATE_LEFT (ARG: SIGNED; COUNT: NATURAL) return SIGNED; -- Result subtype: SIGNED(ARG'LENGTH-1 downto 0) -- Result: Performs a logical rotate-left of a SIGNED -- vector COUNT times. -- Id: S.8 function ROTATE_RIGHT (ARG: SIGNED; COUNT: NATURAL) return SIGNED; -- Result subtype: SIGNED(ARG'LENGTH-1 downto 0) -- Result: Performs a logical rotate-right of a SIGNED -- vector COUNT times.
Dear FvM
as I understood from u there are some conflecting libraries. I can remove any of the libraries which i post cause I need them for the rest of my task, I am not intending to use the code to do only rotate (ROR). I will use some other arithmetic and logical operations.
if you say that I do ror by myself, what about if i need further shifter operations, rol,ssl ...etc,,, you do it all by yourself ??
thank you once again FvM
function rotate_right (signal d_in:std_logic_vector)return std_logic_vector is
variable b : std_logic_vector (d_in' range);
begin
b := (d_in' low & d_in(d_in' high downto d_in low+1));
return b;
end rotate_right;
b := std_logic_vector(unsigned(d_in) ror 1);
b := std_logic_vector(rotate_right(unsigned(d_in),1));
These two expressions are equivalent (using numeric_std)
Code:b := std_logic_vector(unsigned(d_in) ror 1); b := std_logic_vector(rotate_right(unsigned(d_in),1));
Junus2012 said:what about my function, as a second solution what the problem it has ??
thnaks
function rotate_right (signal d_in:std_logic_vector)return std_logic_vector is
variable b : std_logic_vector(d_in'length-1 downto 0);
begin
b := d_in; -- this normalizes the range
return b(0) & b(b'high downto 1);
end rotate_right;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?