VHDL:正式端口 'portName' 没有实际值或默认值

VHDL: formal port 'portName' has no actual or default value

我在实例化 VHDL 模块 PWM 的 VHDL 测试平台上收到编译错误:"formal port 'Duty_Cycle' has no actual or default value"。站在 "dev_to_test: PWM" 代码行时会看到错误。在实例化的 PWM 模块中,Duty_Cycle stg_logic_vector 被强制转换为无符号,然后分配给整数,但认为这不会影响端口实例化。 我试图在端口映射中传递“00001111”矢量值,这导致了同样的错误。 请帮助确定错误是什么。

architecture test of test_pwm is
component PWM
    Generic (
        BIT_DEPTH   : integer;
        INPUT_CLK   : integer; -- 50MHz
        FREQ        : integer); -- 50Hz
    Port (
        Pwm_Out     : out std_logic;
        Duty_Cycle  : in std_logic_vector(BIT_DEPTH - 1 downto 0);
        Clk         : in std_logic;
        Enable      : in std_logic);
end component;

constant BIT_DEPTH  : integer := 8;
constant INPUT_CLK  : integer := 125000000; -- 50MHz
constant FREQ       : integer := 50; -- 50Hz

signal Enable      : std_logic := '0';
signal Duty_Cycle  : std_logic_vector(BIT_DEPTH - 1 downto 0) := "00001111";
signal Clk         : std_logic := '1';
signal Pwm_Out     : std_logic;   


begin
    dev_to_test: PWM
        generic map(BIT_DEPTH,INPUT_CLK,FREQ);
        port map(Pwm_Out,Duty_Cycle,Clk,Enable);

IEEE Std 1076-2008

11.7 Component instantiation statements

component_instantiation_statement ::=
    instantiation_label :
        instantiated_unit
            [ generic_map_aspect ]
            [ port_map_aspect ] ; 

and

generic_map_aspect ::=     
   generic map (generic_association_list ) 

你在 generic map(BIT_DEPTH,INPUT_CLK,FREQ); 末尾的分号太多了,因此,它没有看到端口的映射并给你错误。 要解决该错误,只需删除该分号:

dev_to_test: PWM
        generic map(BIT_DEPTH,INPUT_CLK,FREQ)
        port map(Pwm_Out,Duty_Cycle,Clk,Enable);

PS:为降低设计错误的风险,最好在端口和通用映射中使用命名关联而不是位置映射。