首页 文章

不同类型,单个模块

提问于
浏览
0

我想知道是否可以使用(实例化)具有不同类型的相同(vhdl)模块 . 例如,它的一些输入/输出端口是不同长度的数组?

一种选择是:

component PARITY
    generic (N : integer);
    port    (A : in  std_ulogic_vector
                (N-1 downto 0);
             ODD : out std_ulogic);
    end component;

但我希望将std_ulogic_vector(N-1 downto 0)预定义为一种类型 .

也许在PARITY内部或外部使用一些参数化(通用)包?

我希望这是有道理的...

谢谢!

1 回答

  • 1

    VHDL-2008允许您具有接口类型(通用子句和通用映射方面中的类型) .

    Entity declaration:

    entity E1 is
      generic (
        type myType
      );
      port (
        Clock   : std_logic;
        Inputs  : myType;
        Outputs : myType
      );
    end entity;
    
    architecture rtl of E1 is
    begin
      -- Outputs(Outputs'left) <= Inputs(Inputs'right);
    end architecture;
    

    Entity usage:

    entity E2 is
    end entity;
    
    architecture rtl of E2 is
      constant N1 : positive := 8;
      subtype ST1 is std_logic_vector(N1 - 1 downto 0);
    begin
      inst : entity work.E1
        generic map (
          myType => ST1
        )
        port map (
          Clock   => '0',
          Inputs  => (others => '1'),
          Outputs => open
        );
    end architecture;
    

    So that's the theory. Now comes the disadvantages:

    • 合成中的支持很少见 .

    • 您不能像 E1 中的数组一样使用 InputsOutputs ,因为类型是不完整的接口类型 . 该工具不会知道myType映射到数组类型,例如允许索引和切片操作 . 属性也是如此 . 由于没有关于该类型的知识, 'left'right 将不起作用 .

    这就是为什么我为VHDL-2017写了LCS-2016-059的主要部分 .


    Alternative

    您也可以在实体中使用无约束端口 - 如果您的工具支持:),而不是传递通用参数 N .

    entity E1 is
      port (
        Clock   : std_logic;
        Inputs  : std_logic_vector;
        Outputs : Inputs'range
      );
    end entity;
    

相关问题