我正在编写一个执行以下操作的程序:
目的:要在屏幕上移动图像。
输入:8 x 8图像
命令:00-向右移动; 01-向左移动; 10-向上移动; 11-向下滚动。
由于我是VHDL的新手,所以我需要一些帮助。
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity imagem is
port(A,B,C,D,E,F,G,H : in unsigned(7 downto 0);
SEL : in unsigned(1 downto 0);
OTA,OTB,OTC,OTD,OTE,OTF,OTG,OTH: out unsigned(7 downto 0));
end imagem;
architecture img of imagem is
begin
if SEL = "00" then
OTA <= A sll 1 ;
OTB <= B sll 1 ;
OTC <= C sll 1 ;
OTD <= D sll 1 ;
OTE <= E sll 1 ;
OTF <= F sll 1 ;
OTG <= G sll 1 ;
OTH <= H sll 1 ;
elsif SEL = "01" then
OTA <= A srl 1 ;
OTB <= B srl 1 ;
OTC <= C srl 1 ;
OTD <= D srl 1 ;
OTE <= E srl 1 ;
OTF <= F srl 1 ;
OTG <= G srl 1 ;
OTH <= H srl 1 ;
elsif SEL = "10" then
OTA <= B ;
OTB <= C ;
OTC <= D ;
OTD <= E ;
OTE <= F ;
OTF <= G ;
OTG <= H ;
OTH <= "00000000" ;
else
OTA <= "00000000" ;
OTB <= A ;
OTC <= B ;
OTD <= C ;
OTE <= D ;
OTF <= E ;
OTG <= F ;
OTH <= G ;
end if;
end img;
答案 0 :(得分:-1)
要使IF语句正常工作,请将其放在进程中...
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity imagem is
port(A,B,C,D,E,F,G,H : in unsigned(7 downto 0);
SEL : in unsigned(1 downto 0);
OTA,OTB,OTC,OTD,OTE,OTF,OTG,OTH: out unsigned(7 downto 0));
end imagem;
architecture img of imagem is
begin
process (SEL)
begin
if SEL = "00" then
OTA <= A sll 1 ;
OTB <= B sll 1 ;
OTC <= C sll 1 ;
OTD <= D sll 1 ;
OTE <= E sll 1 ;
OTF <= F sll 1 ;
OTG <= G sll 1 ;
OTH <= H sll 1 ;
elsif SEL = "01" then
OTA <= A srl 1 ;
OTB <= B srl 1 ;
OTC <= C srl 1 ;
OTD <= D srl 1 ;
OTE <= E srl 1 ;
OTF <= F srl 1 ;
OTG <= G srl 1 ;
OTH <= H srl 1 ;
elsif SEL = "10" then
OTA <= B ;
OTB <= C ;
OTC <= D ;
OTD <= E ;
OTE <= F ;
OTF <= G ;
OTG <= H ;
OTH <= "00000000" ;
else
OTA <= "00000000" ;
OTB <= A ;
OTC <= B ;
OTD <= C ;
OTE <= D ;
OTF <= E ;
OTG <= F ;
OTH <= G ;
end if;
end process;
end img;