2016-12-08 49 views
-1

我收到以下错误: 行15:“if”附近的语法错误。 第4行:由于之前的错误而忽略了单位。VHDL:如果出现语法错误

这可能是一个非常愚蠢的问题,但任何人都可以帮忙吗? :)

library IEEE; 
use IEEE.std_logic_1164.all; 

entity arithmetic is 
    port( I1  :in std_logic_vector(12-1 downto 0); -- Operand 1 
      I2  :in std_logic_vector(8-1 downto 0); -- Operand 2 
      O  :out std_logic_vector(12-1 downto 0); -- Output 
      C  :out std_logic;      -- Carry Flag 
      V  :out std_logic;      -- Overflow Flag 
      VALID :out std_logic      -- Flag to indicate if the solution is valid or not 
); 

begin 

if ((unsigned(I1)-unsigned(I2)) > unsigned(I1)) and ((unsigned(I1)-unsigned(I2)) > unsigned(I2)) then 
     C <= '1'; 
    else 
     C <= '0'; 
    end if; 

if I1(x)='1' and signed(std_logic_vector(unsigned(I1)-unsigned(I2)))>0 then --x ist das höchte Bit von I1 
     V <= '1'; 
    else 
     V <= '0'; 
    end if; 

    if unsigned(I1) < unsigned(I2) then 
     VALID <= '0'; 
    else 
     VALID <= '1'; 
    end if; 

und 

O <= std_logic_vector(unsigned(I1)-unsigned(I2)); 

end arithmetic;    
+0

可能重复的[VHDL语法错误附近如果](http://stackoverflow.com/questions/20435228/vhdl-syntaxe-error-near-if) – user1155120

+0

当它完全不同的代码@ user1155120 – Alena

+0

我见过这个问题,它并没有帮助我@ user1155120 – Alena

回答

1

按照该意见,你需要去看看一些有效的VHDL代码。在示例中,根据您的设计,将信号/端口名称替换为...。你有这样的结构:

entity arithmetic is 
port(
    -- Your port list 
); 

begin 

    if (...) then 
    -- Do something 
    end if; 

end arithmetic; 

这是完全无效的。正确的描述看起来更像:

entity arithmetic is 
port(
    -- Your port list 
); 

architecture Behavioral of arithmetic is 
begin 

    process (...) 
    begin 
    if (...) then 
     -- Do something 
    end if; 
    end process; 

end Behavioral; 

希望这些差异是非常明显的。

+0

但是里面的过程应该是什么? :/ – Alena

+0

我会从你的问题开始后的代码开始。我的答案解决了你原来的问题。如果你现在遇到另一个问题,你需要创建一个新的问题,询问这个特定的问题;这不是留言板或论坛。无论如何,当你所做的只是粘贴一些代码和错误信息时,我应该如何知道你的程序要做什么? –

+0

我有粘贴代码和错误消息,这是正确的,你写的答案,这里是过程(...),我问什么应该是因为这里比问问更容易打开新的问题... – Alena