2014-10-28 131 views
0
entity fourbitmult is 
    Port (a,b : in STD_LOGIC_VECTOR (3 downto 0); 
     p : out STD_LOGIC_VECTOR (7 downto 0)); 
end fourbitmult; 

architecture Behavioral of fourbitmult is 
component twobitmult 

port(a,b:in std_logic_vector(1 downto 0); 
p:out std_logic_vector (3 downto 0)); 
end component; 
component rca 
port(a,b:in std_logic_vector(3 downto 0); 
s:out std_logic_vector(3 downto 0); 
carry:out std_logic; 
cin:in std_logic='0' 
); 
end component; 
component halfadder 
port(a,b:in std_logic; 
s,c:out std_logic); 
end component; 
signal c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22: std_logic; 
begin 
m1:twobitmult port map(a(0),a(1),b(0),b(1),p(0),p(1),c1,c2); 
m2:twobitmult port map(a(2),a(3),b(0),b(1),c15,c16,c17,c18); 
m3:twobitmult port map(a(0),a(1),b(2),b(3),c19,c20,c21,c22); 
m4:twobitmult port map(a(2),a(3),b(2),b(3),c7,c8,c9,c10); 
r1:rca port map(c15,c16,c17,c18,c19,c20,c21,c22,c3,c4,c5,c6,c12); 
r2:rca port map(c1,c2,c7,c8,c3,c4,c5,c6,p(2),p(3),p(4),p(5),c11); 
c13<=c11 or c12; 
h1:halfadder port map(c13,c9,p(6),c14); 
h2:halfadder port map(c14,c10,p(7)); 
end Behavioral; 

我爲4位vedic乘法器寫了一個VHDL代碼。 我得到一個錯誤:vhdl 4位vedic乘法器

Line 45. parse error, unexpected EQ, expecting SEMICOLON or CLOSEPAR".. 

的語法是完全正確的,我不明白爲什麼這是一個錯誤。什麼可能是錯的?

回答

1

The syntax is perfectly right

不完全。

cin:in std_logic='0' 

應該

cin: in std_logic := '0' 
------------------^ 

你也失蹤開始上下文子句:

library ieee; 
use ieee.std_logic_1164.all; 

您刪除了一些頭註釋顯然,沒有指示哪些線是第45行(這是上面的摘錄)。你的例子不是Minimal, Complete, and Verifiable example

語法錯誤往往容易顯示出來,當您使用空格和縮進一貫很好。

願意做一個關於語義要求?

爲補遺「中發現比在端口映射甲縮醛更多實際數據」

正如你已經發現你也有語義錯誤,以及上面的語法錯誤。雖然你沒有更新你的問題,但這些錯誤也可以在這裏解釋。

對原線路54「相比,端口映射甲縮醛找到更多的實際值」 - 59是因爲你沒有相同數量的端口映射協會端口作爲組件聲明的聲明爲twobitmultrca實例。

您可以通過使用名爲協會,允許您使用與陣列基本元素類型的實際相關聯的正式的陣列端口元素治癒這些。 (允許更多的關聯列表條目比端口數量)。你似乎有與rca組件聲明錯誤

注意,有比所示是擴大數組類型可能更多端口映射關聯。

似乎carry旨在是一個數組類型(和以下已經被註釋,以反映)。

另請注意,組件中的數組類型是按降序排列的端口元素索引聲明的,並將它們與實體fourbitmult數組類型端口的升序元素相關聯。

如果您能夠使用與聲明相同範圍方向的切片,則關聯列表條目可簡化爲a => a(1 downto 0),。對於其他可以連接切片實際的地方也是如此。

所以通過正規的元素使得端口匹配的數量:

library ieee; 
use ieee.std_logic_1164.all; 

entity fourbitmult is 
    port ( 
     a,b:  in std_logic_vector (3 downto 0); 
     p:   out std_logic_vector (7 downto 0)); 
end fourbitmult; 

architecture behavioral of fourbitmult is 
    component twobitmult 
     port (
      a,b: in std_logic_vector (1 downto 0); 
      p:  out std_logic_vector (3 downto 0) 
     ); 
    end component; 
    component rca 
     port ( 
      a,b: in std_logic_vector (3 downto 0); 
      s:  out std_logic_vector (3 downto 0); 
      carry: out std_logic_vector (3 downto 0); -- std_logic; 
      cin: in std_logic := '0' -- formerly line 45 
    ); 
    end component; 
    component halfadder 
     port (
      a,b: in std_logic; 
      s,c: out std_logic 
     ); 
    end component; 
    signal c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12, 
      c13,c14,c15,c16,c17,c18,c19,c20,c21,c22: std_logic; 
begin 
m1: 
    twobitmult 
     port map (
      -- a(0),a(1),b(0),b(1),p(0),p(1),c1,c2 
      a(1) => a(0), 
      a(0) => a(1), 
      b(1) => b(0), 
      b(0) => b(1), 
      p(3) => p(0), 
      p(2) => p(1), 
      p(1) => c1, 
      p(0) => c2 
     ); 
m2: 
    twobitmult 
     port map ( 
      -- a(2),a(3),b(0),b(1),c15,c16,c17,c18 
      a(1) => a(2), 
      a(0) => a(3), 
      b(1) => b(0), 
      b(0) => b(1), 
      p(3) => c15, 
      p(2) => c16, 
      p(1) => c17, 
      p(0) => c18 
     ); 
m3: 
    twobitmult 
     port map (
      -- a(0),a(1),b(2),b(3),c19,c20,c21,c22 
      a(1) => a(0), 
      a(0) => a(1), 
      b(1) => b(2), 
      b(0) => b(3), 
      p(3) => c19, 
      p(2) => c20, 
      p(1) => c21, 
      p(0) => c22 
     ); 
m4: 
    twobitmult 
     port map (
      -- a(2),a(3),b(2),b(3),c7,c8,c9,c10 
      a(1) => a(2), 
      a(0) => a(3), 
      b(1) => b(2), 
      b(0) => b(3), 
      p(3) => c7, 
      p(2) => c8, 
      p(1) => c9, 
      p(0) => c10 
     ); 
r1: 
    rca 
     port map (
      --c15,c16,c17,c18,c19,c20,c21,c22,c3,c4,c5,c6,c12 
      a(3) => c15, 
      a(2) => c16, 
      a(1) => c17, 
      a(0) => c18, 
      b(3) => c19, 
      b(2) => c20, 
      b(1) => c21, 
      b(0) => c22, 
      carry(3) => c3, 
      carry(2) => c4, 
      carry(1) => c5, 
      carry(0) => c6, 
      cin => c12 
     ); 
r2: 
    rca 
     port map (
      -- c1,c2,c7,c8,c3,c4,c5,c6,p(2),p(3),p(4),p(5),c11 
      a(3) => c1, 
      a(2) => c2, 
      a(1) => c7, 
      a(0) => c8, 
      b(3) => c3, 
      b(2) => c4, 
      b(1) => c5, 
      b(0) => c6, 
      carry(3) => p(2), 
      carry(2) => p(3), 
      carry(1) => p(4), 
      carry(0) => p(5), 
      cin => c11 
     ); 

     c13 <= c11 or c12; 

h1: 
    halfadder 
     port map ( 
      c13,c9,p(6),c14 
     ); 
h2: 
    halfadder 
     port map ( 
      c14,c10,p(7) 
     ); 
end behavioral; 

這種分析,但沒有實體/已宣佈的組件架構對不能詳細闡述,也沒有功能驗證。

+0

我試過你的建議,但我得到錯誤,如「在港口地圖中發現的比實際情況更多的實際情況」,從54到59.plz的行中給出了一些其他建議。謝謝你,先生 – Jyoti 2014-10-29 16:41:31