2013-03-23 86 views
1

我正在寫VHDL代碼,其中我使用了tempxtempz作爲變量,並嘗試將它們連接起來,但我在下面註釋的行上有一些錯誤。建議請做些什麼?VHDL錯誤與變量連接相關

的錯誤是:

Error (10500): VHDL syntax error at ArrayDivider.vhd(53) near text ":="; expecting "(", or "'", or ".", 
Error (10500): VHDL syntax error at ArrayDivider.vhd(53) near text "&"; expecting "(", or "'", or "." 

代碼:

------- Array Divider -------- 

library ieee; 
use ieee.std_logic_1164.all; 

----- Entity ----- 

entity ArrayDivider is 
    generic 
    (
     ---- For x/y 
     Nx : integer := 8; --- Number of bits in x 
     Ny : integer := 4 --- Number of bits in y 
    ); 
    port 
    (
     ipx : in std_logic_vector(Nx-1 downto 0); -- Input x --- (Nx-1 downto 0) 
     ipy : in std_logic_vector(Ny-1 downto 0); -- Input y --- (Ny-1 downto 0) 
     opd : out std_logic_vector(Nx-Ny downto 0); -- Quotient --- (Nx-Ny downto 0) 
     opr : out std_logic_vector(Ny-1 downto 0) -- Remainder --- (Ny-1 downto 0) 
    ); 
end ArrayDivider; 

----- Architecture ----- 

Architecture Div of ArrayDivider is 
--- This component will compare ipy with parts of ipx of given bits and --- 
--- generate bits of divident as well as partial subtraction results --- 
--- x = parts of ipx (tempx), y = ipy, op = opd(x) and final z = opr ---  

    component Cmp is 
     generic 
     (
      N : integer := 4 
     ); 
     port 
     (
      x : in std_logic_vector(N-1 downto 0); --- N-1 downto 0 
      y : in std_logic_vector(N-1 downto 0); --- N-1 downto 0 
      z : out std_logic_vector(N-1 downto 0); --- N-1 downto 0 
      op : out std_logic 
     ); 
    end Component; 
    variable tempx : std_logic_vector(Ny-1 downto 0) := ipx(Nx-1 downto Nx-Ny); --- (Ny-1 downto 0) (Nx-1 downto Nx-Ny) 
    variable tempz : std_logic_vector(Ny-1 downto 0); --- (Ny-1 downto 0) 
begin 
    lup: 
     for a in Nx-Ny downto 0 generate --- Nx-Ny downto 0 
     begin   
    Cmpa: Cmp generic map(Ny) port map(tempx, ipy, tempz, opd(a)); --- (Ny) 
    grea: 
      if(a > 0) generate 
       tempx := tempz(Ny-2 downto 0) & ipx(a-1); --- (Ny-2 downto 0) 
      end generate grea; 
    zero: 
      if(a = 0) generate 
       opr <= tempz; 
      end generate zero; 
     end generate lup; 
end Div; 
+0

如果您打算綜合這一點,只能在過程中使用變量。否則,信號就是你想要的。 – 2013-03-23 12:12:10

回答

1

因爲你沒有使用過程中,你應該使用信號,而不是變量tempxtempz。然後,您的行53必須看起來如下:

tempx <= tempz(Ny-2 downto 0) & ipx(a-1); 

但是,可能使用過程更有意義。那麼你必須實現你的cmp組件作爲一個過程(在下面的例子中沒有做)。該過程可能如下所示:

... 
end Component; 
begin 

div_proc: process(ipy, ipx) 
    variable tempx : std_logic_vector(Ny-1 downto 0) ; 
    variable tempz : std_logic_vector(Ny-1 downto 0); 
begin 
    lup: 
     for a in 1 downto 0 loop   
    -- Cmpa: Cmp generic map(Ny) port map(tempx, ipy, tempz, opd(a)); 
     grea: 
      if(a > 0) then 
       tempx := tempz(Ny-2 downto 0) & ipx(a-1); 
      end if; 
     zero: 
      if(a = 0) then 
      opr <= tempz; 
      end if; 
    end loop; 
end process div_proc; 
... 
+0

我也使用過信號,但在這種情況下,與多個驅動程序有關的新錯誤發生在tempx的初始化點,我嚴重地知道該怎麼做!!!!! ..........: ( – 2013-03-24 12:04:57

+0

要知道你的for/generate結構不是一個循環!這個語句導致你在for/generate結構中描述的邏輯有多個實現((Nx-Ny)+1),因此你有多個tempx驅動。 – baldyHDL 2013-03-24 18:09:15

+0

我添加了一個過程/變量解答的例子給答案... – baldyHDL 2013-03-24 18:19:41