我想使用命令行中设置的泛型来有条件地实例化组件。我更希望使用通用字符串(即<React.Fragment>
<Suspense>
<DialogBox />
</Suspense>
</React.Fragment>
或fast
)而不是数字。
我在stackOverflow上找不到任何示例,所以我想问一下。
答案 0 :(得分:0)
这里是使用泛型有条件地实例化组件体系结构的示例。相同的代码可用于实例化不同的组件:
LIBRARY ieee;
use ieee.std_logic_1164.all;
entity dut is
generic (
SPEED : string := "fast"
);
port(
clk : in std_logic;
reset: in std_logic;
start: in std_logic;
done: out std_logic);
end entity dut;
architecture dutarch of dut is
component delay is
port (
clk : in std_logic;
reset: in std_logic;
start: in std_logic;
done: out std_logic
);
end component delay;
begin
d1g: if (SPEED = "fast") generate
d1f : entity work.delay(fast)
port map (
clk => clk,
reset => reset,
start => start,
done => done
);
else generate
d1s : entity work.delay(slow)
port map (
clk => clk,
reset => reset,
start => start,
done => done
);
end generate;
end architecture dutarch;