与变量串联有关的VHDL错误 [英] VHDL error related to concatenation of variable

查看:71
本文介绍了与变量串联有关的VHDL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写VHDL代码,其中使用 tempx tempz 作为变量,并尝试将它们连接起来,但是我在下面注释的行上有一些错误。

I am writing VHDL code in which I have used tempx and tempz as variables and tried to concatenate them, but I am having some errors on the line annotated below. Suggestions on what to do please?

错误是:

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;


推荐答案

由于不使用流程,应使用信号,而不是 tempx tempz 的变量。那么您的第53行必须如下所示:

as you are not using a process, you should use signals instead of variables for tempx and tempz. your line 53 must then look as follows:

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

但是,使用过程可能更有意义。那么您必须将cmp组件作为一个过程来实现(在下面的示例中未完成)。该过程可能如下所示:

however, probably the use of a process makes more sense. then you have to implement your cmp component as a procedure (not done in example below). the process could look as follows:

   ...
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;
...

这篇关于与变量串联有关的VHDL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆