Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > vhdl shifting command

Reply
Thread Tools

vhdl shifting command

 
 
red red is offline
Junior Member
Join Date: Sep 2008
Posts: 2
 
      09-24-2008
hi. i am supposed to shift A left by the number of '1's in B. den output it at S.
i chose to manually shift it. but my codes doesnt seems to work.
any help?

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity alu is
generic (n : natural :=;

port( a,b : in std_logic_vector(n-1 downto 0);
com: in std_logic_vector (3 downto 0);
cin: in std_logic;
s: out std_logic_vector(2*n-1 downto 0));
end entity alu;


architecture Behavioral of alu is

begin
process(com, a, b)

variable tmpa: std_logic_vector(2*n-1 downto 0);
variable tmpb: std_logic_vector(2*n-1 downto 0);
variable tmps: std_logic_vector(2*n-1 downto 0);

begin

if(com = "0111") then
for i in 0 to n-1 loop
if(b(i) = '1') then
tmpa := tmpa(2*n -2 downto 0) & cin;
end if;
end loop;
tmps := tmpa;
end if;

s <= tmps;
end process;
end behavioral;
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL-2002 vs VHDL-93 vs VHDL-87? afd VHDL 1 03-23-2007 09:33 AM
Matrix Shifting a_Conan VHDL 0 08-23-2005 11:51 AM
Question about shifting jahaya@gmail.com VHDL 1 07-22-2005 10:09 AM
Basic shifting question Stefan Duenser VHDL 4 12-08-2004 11:00 AM
how to write VHDL for shifting? walala VHDL 3 11-21-2003 09:37 AM



Advertisments
 



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 56 57