Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error in using Shift operators in VHDL !!!

Status
Not open for further replies.

apanimesh061

Newbie level 3
Newbie level 3
Joined
Mar 19, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,299
Code:
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;

entity SU_4bit is
   port( s :    in std_logic_vector(3 downto 0);
         a :    inout std_logic_vector(3 downto 0):= "0000"
         --o : inout std_logic_vector(3 downto 0):= "0000"
       );
end SU_4bit;

architecture Behavioral of SU_4bit is
  begin
  -- signal
process(a,s)
  begin
     case s is
     when "1000" =>        
        a<= a srl 1;
        
     when "1001" =>
        a<= a ror 1;
        
     when "1011" =>
        a<= a sra 1;
     
     when others =>
        a<= "0000" ;
     
     end case;
end process;
end Behavioral;

Help me debug the errors ...... I wish to use the Shift operators !!!! ????
 

I actually was going through this site ...... VHDL Tutorial
they say the Shift Operators can be used that way.
I removed other packages but then I had to change the data type from std_logic_vector to bit_vector........
Now, there areno errors but the output s coming out to be wrong......
 

I think it would be better to use


Code VHDL - [expand]
1
2
3
4
5
a<= a(0) & a(3 downto 1);  --rotate right
a<= '0' & a(3 downto 1);   -- shift right
 
a<= a(2 downto 0) & a(3);  --rotate left
a<= a(2 downto 0) & '0';   --shift left



Alex

---------- Post added at 20:47 ---------- Previous post was at 20:36 ----------

the sll, srl, rol, ror are defined in IEEE.NUMERIC_STD.ALL and can only be used with signed or unsigned (a std_logic_vector would have to be converted first to be used with these), they also need two parameters.


Code VHDL - [expand]
1
2
3
4
5
6
7
8
function "sll" (ARG: UNSIGNED; COUNT: INTEGER) return UNSIGNED;
function "sll" (ARG: SIGNED; COUNT: INTEGER) return SIGNED;
function "srl" (ARG: UNSIGNED; COUNT: INTEGER) return UNSIGNED;
function "srl" (ARG: SIGNED; COUNT: INTEGER) return SIGNED;
function "rol" (ARG: UNSIGNED; COUNT: INTEGER) return UNSIGNED;
function "rol" (ARG: SIGNED; COUNT: INTEGER) return SIGNED;
function "ror" (ARG: UNSIGNED; COUNT: INTEGER) return UNSIGNED;
function "ror" (ARG: SIGNED; COUNT: INTEGER) return SIGNED;



that is why I think that the way I have posted above would be easier to use.

Alex
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top