2016-05-19 5 views
-1
library IEEE; 
use IEEE.STD_LOGIC_1164.all; 

entity paralel_reg is 
    generic (default : positive := 4); 
    port(C, notR, E: in std_logic; D: in std_logic_vector(default downto 1); 
    Q: out std_logic_vector(default downto 1)); 
end paralel_reg; 

architecture paralel_reg of paralel_reg is 
signal q : std_logic_vector(default downto 1); 
begin 
process (C, notR) 
begin 
    if notR = '0' then q <= (others => '0'); 
    else if rising_edge(C) then q <= D; 
    end if; 
end process; --# Error: COMP96_0019: paralel_register.vhd : (18, 5): Keyword "if" expected. 
    --# Error: COMP96_0015: paralel_register.vhd : (18, 5): ';' expected. 

process (E, q) --# Error: COMP96_0019: paralel_register.vhd : (24, 2): Keyword "end" expected. 
begin 
    if E = '0' then Q <= (others => '0'); 
    else Q <= q;  --# Error: COMP96_0019: paralel_register.vhd : (24, 2): Keyword "end" expected. 
      --# Error: COMP96_0016: paralel_register.vhd : (24, 7): Design unit declaration expected. 
    end if; 
end process; 
end paralel_reg; 

# Error: COMP96_0019: paralel_register.vhd : (18, 5): Keyword "if" expected. # Error: COMP96_0015: paralel_register.vhd : (18, 5): ';' expected. # Error: COMP96_0019: paralel_register.vhd : (21, 1): Keyword "end" expected. # Error: COMP96_0019: paralel_register.vhd : (24, 2): Keyword "end" expected. # Error: COMP96_0016: paralel_register.vhd : (24, 7): Design unit declaration expected.なぜコードがコンパイルされていないのですか?

答えて

0

この:

process (C, notR) 
begin 
    if notR = '0' then q <= (others => '0'); 
    elsif rising_edge(C) then q <= D; 
    end if; 
end process; 

process (C, notR) begin 
    if notR = '0' then q <= (others => '0'); 
    else if rising_edge(C) then q <= D; 
    end if; end process; 

は、このする必要がありますVHDL ifステートメントにこれがあります形式:

if ... then 
    ... 
elsif ... then 
    ... 
elsif ... then 
    ... 
else 
    ... 
end if; 

すべてのVHDL文はセミコロンで終わります。上記は1つのステートメントで、末尾はend if;です。 VHDLステートメントは別のステートメントに埋め込むことができます。だから、あなたはif文の中、別のif文を組み込みことができますし、むしろelsifよりelse ifを使用している場合、これはあなたがやっていることです。

if ... then 
    ... 
elsif ... then 
    ... 
elsif ... then 
    ... 
else 
    IF ... THEN 
    ... 
    ELSIF ... THEN 
    ... 
    ELSE 
    ... 
    END IF; 
end if; 

VHDLのすべてのif文がend if;が必要です。上の例では、1つのifステートメントが別のステートメントに組み込まれているため、2つのend ifがあります。だから、あなたが書かれている可能性があり:

process (C, notR) begin 
    if notR = '0' then q <= (others => '0'); 
    else if rising_edge(C) then q <= D; 
    end if; 
    end if; end process; 

いますが、あまりend if秒を必要とするので、私はいつもelsifの代わりelse ifをお勧めします。

1

"エルス場合は、" VHDLに存在しない、あなたが書く必要があります。

IF ... THEN 
ELSIF ... THEN 
ELSE 
END IF; 
+2

あなたは 'else if'を使うことができますが、制御フローと' end if'文が一致するように注意する必要があります。 'q'と' Q'はVHDLで字句的に同一であり、2つの宣言があります。 'q'の出現を' qi'(感度リストを含む)に変更し、if(またはelsifを使用して)コードを分析(コンパイル)すると、もう一つの終わりを追加します。ここでのメッセージは、答えが実証されるべきだということです。どのような 'E'が意図されているか分かりません。 – user1155120

関連する問題