端口映射中的低电平有效复位

active low reset in Port Mapping

所以当 "top file" 上的端口映射组件时,是否可以在端口映射时反转复位输入,如下例所示?

假设顶级文件代码为:

        entity topfile is
        port(
              clk : in std_logic;
              reset : in std_logic
              --Other input and outputs
                );


         architecture arch of topfile is
         begin

          c1: entity work.component1(behavioral)
          port map(
                    clk => clk,
                    reset => not reset,
                    .
                    .
                    .
                     );
          c2: entity work.component2(behavioral)
          port map(
                    clk => clk,
                    reset => not reset,
                    .
                    .
                    .
                     );


               end arch;

是的,你可以。只要'manipulated'信号的类型和长度与端口匹配即可。

是的,你可以,但你必须使用 VHDL 2008。在 VHDL 2008 之前,不允许在端口映射中使用所谓的表达式

不要轻率地决定使用 VHDL 2008。并非所有工具都支持 VHDL 2008,即使您发现当前使用的所有工具都支持它,您能否确定您将来可能希望切换到的任何工具也支持它?

鉴于使用 VHDL 2008 解决此特定问题的优势很小,我建议使用这样的虚拟信号:

    entity topfile is
    port(
          clk : in std_logic;
          reset : in std_logic
          --Other input and outputs
            );


     architecture arch of topfile is
          signal resetn : std_logic
     begin

     resetn <= not reset;

      c1: entity work.component1(behavioral)
      port map(
                clk => clk,
                reset => resetn,
                .
                .
                .
                 );
      c2: entity work.component2(behavioral)
      port map(
                clk => clk,
                reset => resetn,
                .
                .
                .
                 );

端口映射中的表达式添加了额外的增量延迟,因此上面的代码将完全模拟为与您的原始代码相同。

正如 Matthew 指出的那样,表达式 在 2008 年之前的端口映射中是不允许的,但是在 2008 年之前支持 转换函数,至少通过 Vivado、ISE 和 ModelSim。您可以编写一个简单的 invert 函数并将其放入一个包中,该包会在您的其他源文件中得到 used。像这样:

function invert (input : std_logic) return std_logic is
begin
  return not input;
end function;

然后您可以在您的端口映射中使用 reset => invert(reset),,而不需要您的工具支持 VHDL2008。这仍然非常可读,没有使用任何 'extra' 信号。


在相关说明中,我建议不要在 FPGA 中使用低电平有效内部信号。设备中物理块的时钟启用和重置通常不是低电平有效,因此将它们写成低电平有效会导致额外的反转逻辑。