关于VHDL的问题,不知道为什么问题老是出现在case语句,对照过教程好像没有错误啊。。。quartus ii6.0
--四位乘法器libraryieee;--导入标准库useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;-...
--四位乘法器
library ieee; --导入标准库
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--定义一个名字叫做calculator乘法器的实体,他的是输入信号in1,in2是长度为4的
--逻辑向量,表示两个乘数;他的输出是长度为8的
entity calculator is
port(in1,in2:in std_logic_vector(3 downto 0); --参与运算的两个数
option: in std_logic_vector(1 downto 0); --运算的操作类型
r0,r1,r2,r3,r4,r5,r6,r7:out std_logic_vector( 6 downto 0));
end entity calculator;
--定义一个结构体用来描述calculator的功能
architecture multiply of calculator is
--声明内部信号
signal temp1 :std_logic_vector(3 downto 0);
signal temp2 :std_logic_vector(4 downto 0);
signal temp3 :std_logic_vector(5 downto 0);
signal temp4 :std_logic_vector(7 downto 0);
signal result :std_logic_vector(7 downto 0);
--00加法
--01减法
--10和运算
--11异或运算
begin
case option is
when "00" => result <= in1 + in2;
when "01" => result <= in1 - in2;
when "10" => result <= in1 and in2;
when "11" => result <= in1 xor in2;
when OTHERS =>result <= in1 xor in2;
end case;
temp1<=in1 when in2(0)='1' else "0000";
temp2<=in1&'0' when in2(1)='1' else "00000";
temp3<=in1&"00" when in2(2)='1' else "000000";
temp4<='0'&in1&"000" when in2(3)='1' else "00000000";
result<=temp4+temp3+temp2+temp1 ;
--下面把结果转化为七段显示管的信号
r0<="1001111" when result(0)='1' else "1000000";
r1<="1001111" when result(1)='1' else "1000000";
r2<="1001111" when result(2)='1' else "1000000";
r3<="1001111" when result(3)='1' else "1000000";
r4<="1001111" when result(4)='1' else "1000000";
r5<="1001111" when result(5)='1' else "1000000";
r6<="1001111" when result(6)='1' else "1000000";
r7<="1001111" when result(7)='1' else "1000000";
end architecture multiply;
说是case语句附近错误。。。求解救 展开
library ieee; --导入标准库
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--定义一个名字叫做calculator乘法器的实体,他的是输入信号in1,in2是长度为4的
--逻辑向量,表示两个乘数;他的输出是长度为8的
entity calculator is
port(in1,in2:in std_logic_vector(3 downto 0); --参与运算的两个数
option: in std_logic_vector(1 downto 0); --运算的操作类型
r0,r1,r2,r3,r4,r5,r6,r7:out std_logic_vector( 6 downto 0));
end entity calculator;
--定义一个结构体用来描述calculator的功能
architecture multiply of calculator is
--声明内部信号
signal temp1 :std_logic_vector(3 downto 0);
signal temp2 :std_logic_vector(4 downto 0);
signal temp3 :std_logic_vector(5 downto 0);
signal temp4 :std_logic_vector(7 downto 0);
signal result :std_logic_vector(7 downto 0);
--00加法
--01减法
--10和运算
--11异或运算
begin
case option is
when "00" => result <= in1 + in2;
when "01" => result <= in1 - in2;
when "10" => result <= in1 and in2;
when "11" => result <= in1 xor in2;
when OTHERS =>result <= in1 xor in2;
end case;
temp1<=in1 when in2(0)='1' else "0000";
temp2<=in1&'0' when in2(1)='1' else "00000";
temp3<=in1&"00" when in2(2)='1' else "000000";
temp4<='0'&in1&"000" when in2(3)='1' else "00000000";
result<=temp4+temp3+temp2+temp1 ;
--下面把结果转化为七段显示管的信号
r0<="1001111" when result(0)='1' else "1000000";
r1<="1001111" when result(1)='1' else "1000000";
r2<="1001111" when result(2)='1' else "1000000";
r3<="1001111" when result(3)='1' else "1000000";
r4<="1001111" when result(4)='1' else "1000000";
r5<="1001111" when result(5)='1' else "1000000";
r6<="1001111" when result(6)='1' else "1000000";
r7<="1001111" when result(7)='1' else "1000000";
end architecture multiply;
说是case语句附近错误。。。求解救 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询