vhdl shifting command

red

Joined
Sep 24, 2008
Messages
2
Reaction score
0
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 :=8);

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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top