我有可变数量的模块通过 a 链接到另一个模块signal bus : std_logic_vector(NUM-1 downto 0)
,每个组件使用 8 位,因此:
bus(7 downto 0) = first module
bus(15 downto 8) = second module
至于创建实例和进行端口映射,这很容易通过
INST: for i in 0 to NUM-1 generate
Inst_module port map ( bus => bus(i*8+7 downto i*8) );
end generate INST;
我的问题:
我希望能够通过 FSM 与每个模块交互(因为它也需要做一些其他事情),所以希望能够“生成”以下代码,而不是必须写出每个手动状态(signal empty : std_logic_vector(NUM-1 downto 0)
每个模块的状态标志在哪里)
type state_type is (st0_idle, st1_work0, st1_work1 --,etc.)
signal state : state_type;
begin
process(empty)
begin
if RESET = '1' then
--reset FSM
state <= st0_idle;
else
if CLK'event and CLK='1' then
case state is
when st0_idle =>
if empty(0) = '0' then
state <= st1_work0;
elsif empty(1) = '1' then
state <= st1_work1;
--etc.
end if;
when st1_work0 =>
bus(7 downto 0) <= SOMETHING;
state <= st0_idle;
when st1_work1 =>
bus(15 downto 8) <= SOMETHINGELSE;
state <= st0_idle;
--etc..
end if;
end if;
end process;
如您所见,有很多重复。但是我不能简单地把一个for-generate
放在箱子里,那我该怎么办呢?