【问题标题】:Sharing "array of arrays" between two VHDL modules在两个 VHDL 模块之间共享“数组数组”
【发布时间】:2013-08-08 07:07:30
【问题描述】:

我在两个 VHDL 模块之间共享“数组数组”时遇到问题。

我在 VHDL 子模块中声明了一个“数组数组”,如下所示,

type avg_log is array (0 to 31) of std_Logic_vector(19 downto 0); 
signal V1 :avg_log :=(others=>others=>'0');

我想将V1()() 的所有元素发送到顶层模块,我尝试使用 PORT 和 GENERIC,但收到错误消息。

谁能帮帮我?

【问题讨论】:

    标签: arrays module vhdl


    【解决方案1】:

    您需要在一个包中定义您的type,然后通过use 将其包含在两个实体中,如下所示:

    library ieee;
    use ieee.std_logic_1164.all;
    
    package p_avg is
        type avg_log is array (0 to 31) of std_Logic_vector(19 downto 0);
    end package p_avg;
    

    然后在你的实体中

    use work.p_avg.all;
    entity my_e is
        port(
          ...
          V1 : out avg_log := (others => (others => '0'));
          ...
        );
    end entity;
    

    然后在周围架构的端口映射中使用它(还必须包含包)...还有其他方法,但这是我建议的方式...

    【讨论】:

    • 我已经按照你提到的那样尝试过,但是在端口(V1 :out :avg_log :=(others= >其他=>'0'));在我的顶级模块上,请帮忙。
    • @karthik k,如您的错误消息所示,输出模式值和子类型指示 avg_log 之间有一个虚假的“:”。 MortenZdk 下面的示例还显示了一对括号,其中包含在 std_logic_vectors 数组的端口输出的默认值中最右边的关联。他的示例代码实际上可以无误地分析。这里有一条关于在答案中信任(和使用)伪代码的消息。
    【解决方案2】:

    下面的整个示例,定义了 p_avg 包(如 BennyBarns 建议的那样)、my_e 子模块 my_e 和 tb 顶部模块;可以用 ModelSim 编译:

    library ieee;
    use ieee.std_logic_1164.all;
    
    package p_avg is
      type avg_log is array (0 to 31) of std_logic_vector(19 downto 0);
    end package p_avg;
    
    
    
    library ieee;
    use ieee.std_logic_1164.all;
    library work;
    use work.p_avg.all;
    
    entity my_e is
      port(
        v1_o : out avg_log);
    end entity;
    
    architecture sim of my_e is
    begin
      v1_o <= (others => (others => '0'));
    end architecture;
    
    
    
    library ieee;
    use ieee.std_logic_1164.all;
    library work;
    use work.p_avg.all;
    
    entity tb is
    end entity;
    
    architecture sim of tb is
      signal v1 : avg_log;
    begin
    
      my_e_1 : entity work.my_e
        port map(
          v1_o => v1);
    
    end architecture;
    

    【讨论】:

      猜你喜欢
      • 2015-10-08
      • 2017-01-21
      • 1970-01-01
      • 2016-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多