【问题标题】:VHDL unconstrained std_logic_vector - detection of increasing/decreasing indexVHDL无约束std_logic_vector - 增加/减少索引的检测
【发布时间】:2021-02-24 18:02:29
【问题描述】:

如果组件上有一个不受约束的 std_logic_vector 端口,它将遵循来自组件实例化的更高级别实体的信号声明(如果信号为 (n down to 0),则端口显然会匹配此)。

但是,如果在实例化时将常量向量(例如“10100001”或 x“A1”)分配给端口,则端口将自动默认为“0 到 7”而不是“7 降到 0”。有什么方法可以“检测”到不受约束的 std_logic_vector 是递增/递减索引格式,所以我可以在必要时适当地翻转这些位?

【问题讨论】:

标签: vhdl


【解决方案1】:

VHDL 属性“升序”符合我的要求。所以“My_Signal'ascending”如果向量是“0 to n”格式会返回一个布尔值true,如果“n downto 0”格式返回false。

【讨论】:

    【解决方案2】:

    首先要注意组件上的无约束数组,因为某些综合工具可能不支持此功能,但是,对于测试台来说,它就可以了。

    接下来,您应该对范围进行标准化,而不是关注范围的升序或降序。您可以使用别名来做到这一点:

    entity fred is
    port (
      Unconstrained_Port : std_logic_vector ; 
      . . . 
    ) ; 
    end entity fred ; 
    architecture one of fred is 
      alias Constrained_Port : std_logic_vector(Unconstrained_Port'length -1 downto 0) is Unconstrained_Port ; 
    

    【讨论】:

      猜你喜欢
      • 2015-09-15
      • 1970-01-01
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多