【发布时间】:2019-04-25 12:08:07
【问题描述】:
我不明白为什么以下示例中“sig2”的信号分配不会成功,而“sig1”却可以。随着时钟上升沿“sig2”变为“X”!
是什么原因?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.STD_LOGIC_UNSIGNED.all;
entity Test_tb is
end entity Test_tb;
architecture Structural of Test_tb is
signal sig1 : std_logic_vector (3 downto 0) := (others => '0');
signal sig2 : std_logic_vector (7 downto 0) := (others => '0');
signal clk : std_logic := '0';
begin
clk_generate: process is
begin
wait for 5 ns;
clk <= not clk;
end process clk_generate;
gen_label : for gen_indx in 0 to 3 generate
begin
process (clk) is
begin
if clk = '1' and clk'event then
sig1 (gen_indx) <= '1';
for loop_indx in 0 to 1 loop
sig2 (gen_indx * 2 + loop_indx) <= '1';
end loop;
end if;
end process;
end generate gen_label;
end architecture Structural;
【问题讨论】:
-
这个问题不是minimal reproducible example,使读者无法轻易复制问题或验证任何答案。一个简单的解决方案是将循环语句替换为
sig2(gen_indx * 2 + 1 downto gen_indx * 2) <= (others => '1');。问题是在细化设计层次结构期间用于识别驱动程序的最长静态前缀。循环参数是动态阐述的,原来最长的静态前缀是sig2。 -
@user1155120 感谢您的通知。我编辑了代码以立即验证。
标签: vhdl variable-assignment generate