为什么我的 VHDL 乘法器没有输出?
Why do I get no output at my VHDL multiplier?
我正在尝试制作一个 4 位乘法器。这是我的顶层设计:
这是两个模块:
然而,当我尝试对此进行模拟时,我没有得到任何输出。我的测试平台:
ARCHITECTURE behavior OF sim3 IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT multiplicator
PORT(
a : IN std_logic_vector(3 downto 0);
b : IN std_logic_vector(3 downto 0);
reset : IN std_logic;
clk : IN std_logic;
start : IN std_logic;
prod : OUT std_logic_vector(7 downto 0);
ready : OUT std_logic
);
END COMPONENT;
--Inputs
signal a : std_logic_vector(3 downto 0) := (others => '0');
signal b : std_logic_vector(3 downto 0) := (others => '0');
signal reset : std_logic := '0';
signal clk : std_logic := '0';
signal start : std_logic := '0';
--Outputs
signal prod : std_logic_vector(7 downto 0);
signal ready : std_logic;
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: multiplicator PORT MAP (
a => a,
b => b,
reset => reset,
clk => clk,
start => start,
prod => prod,
ready => ready
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
wait for clk_period;
reset<='1';
wait for clk_period;
reset<='0';
a<="0011";
b<="0010";
start <='1';
wait for clk_period*10;
end process;
END;
当我将开始设置为“1”时,模拟就停止了。我不知道为什么。我收到以下错误:
ERROR: at 20 ns(10000): Iteration limit 10000 is reached. Possible zero delay oscillation detected where simulation can not advance in time because signals can not resolve to a stable value in File "D:/faculta/PL II/multiplicator/reg8.vhd" Line 45. Please correct this code in order to advance past the current simulation time.
我看不出那一行有什么问题:
q_s <= "00000000" WHEN reset='1' ELSE d WHEN reset='0' and load='1' ELSE q_s;
有什么帮助吗?
不要使用带加载使能的寄存器,使用时钟边沿寄存器。迭代限制是 ISIM 中的增量循环限制。在 b
中引入一个“1”,你会得到一个引人注目的振荡器,一个带有增量周期延迟和反转(求和)的循环。使 num4、reg4 和 reg8 时钟边沿以其负载驱动,这似乎与 Lab10 兼容,它显示时钟的使用(以及 @scary_jeff 的 VHDL 源代码,尽管以 BIT 类型表示std_logic)。这种反馈现象在 William Kafig 的书 VHDL 101 Everything you need to know to get started 的第 4 章中提到。
Google 翻译有帮助。似乎从来没有人为他们的作业提供讲义。
如果您查看 reg4
中对 q_s
赋值的原始实现:
block1:
block (ck = '1' and not ck'stable)
begin
q_s <= guarded "0000" when reset = '1' else
d when reset = '0' and load = '1' else
q_s;
end block block1;
我会将其翻译成可综合的过程语句而不是块语句,明确 reg4
(和 reg8
)是一个时钟寄存器:
block1:
process (ck)
begin
if rising_edge(ck) then
if reset = '1' then
q_s <= (others => '0');
elsif load = '1' then
q_s <= d;
end if;
end if;
end process;
原来有效的原因是一个块语句可以有一个保护语句。
这一变化明确了 q_s
是一个同步复位的时钟寄存器。
您可能还注意到我们不再引用 q_s
并且可以直接分配 q。
在控制状态机中,分配 next_state
到 current_state
的过程同样可以更新:
process (ck)
begin
if ck'event and ck = '1' then -- or rising_edge(ck)
current_state <= next_state;
end if;
end process;
只是为了便于阅读。使用 not ck'stable
形式来表示时钟事件并不常见,请注意您似乎也错过了实现 reg8
的含义,可能在 reg4
和 automat
中也是如此。
IEEE 标准 1076.6-2004 中演示了受保护表达式作为边沿敏感时钟的综合资格,
6.1.3.6 使用保护块的边缘敏感存储。
我正在尝试制作一个 4 位乘法器。这是我的顶层设计:
这是两个模块:
然而,当我尝试对此进行模拟时,我没有得到任何输出。我的测试平台:
ARCHITECTURE behavior OF sim3 IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT multiplicator
PORT(
a : IN std_logic_vector(3 downto 0);
b : IN std_logic_vector(3 downto 0);
reset : IN std_logic;
clk : IN std_logic;
start : IN std_logic;
prod : OUT std_logic_vector(7 downto 0);
ready : OUT std_logic
);
END COMPONENT;
--Inputs
signal a : std_logic_vector(3 downto 0) := (others => '0');
signal b : std_logic_vector(3 downto 0) := (others => '0');
signal reset : std_logic := '0';
signal clk : std_logic := '0';
signal start : std_logic := '0';
--Outputs
signal prod : std_logic_vector(7 downto 0);
signal ready : std_logic;
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: multiplicator PORT MAP (
a => a,
b => b,
reset => reset,
clk => clk,
start => start,
prod => prod,
ready => ready
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
wait for clk_period;
reset<='1';
wait for clk_period;
reset<='0';
a<="0011";
b<="0010";
start <='1';
wait for clk_period*10;
end process;
END;
当我将开始设置为“1”时,模拟就停止了。我不知道为什么。我收到以下错误:
ERROR: at 20 ns(10000): Iteration limit 10000 is reached. Possible zero delay oscillation detected where simulation can not advance in time because signals can not resolve to a stable value in File "D:/faculta/PL II/multiplicator/reg8.vhd" Line 45. Please correct this code in order to advance past the current simulation time.
我看不出那一行有什么问题:
q_s <= "00000000" WHEN reset='1' ELSE d WHEN reset='0' and load='1' ELSE q_s;
有什么帮助吗?
不要使用带加载使能的寄存器,使用时钟边沿寄存器。迭代限制是 ISIM 中的增量循环限制。在 b
中引入一个“1”,你会得到一个引人注目的振荡器,一个带有增量周期延迟和反转(求和)的循环。使 num4、reg4 和 reg8 时钟边沿以其负载驱动,这似乎与 Lab10 兼容,它显示时钟的使用(以及 @scary_jeff 的 VHDL 源代码,尽管以 BIT 类型表示std_logic)。这种反馈现象在 William Kafig 的书 VHDL 101 Everything you need to know to get started 的第 4 章中提到。
Google 翻译有帮助。似乎从来没有人为他们的作业提供讲义。
如果您查看 reg4
中对 q_s
赋值的原始实现:
block1:
block (ck = '1' and not ck'stable)
begin
q_s <= guarded "0000" when reset = '1' else
d when reset = '0' and load = '1' else
q_s;
end block block1;
我会将其翻译成可综合的过程语句而不是块语句,明确 reg4
(和 reg8
)是一个时钟寄存器:
block1:
process (ck)
begin
if rising_edge(ck) then
if reset = '1' then
q_s <= (others => '0');
elsif load = '1' then
q_s <= d;
end if;
end if;
end process;
原来有效的原因是一个块语句可以有一个保护语句。
这一变化明确了 q_s
是一个同步复位的时钟寄存器。
您可能还注意到我们不再引用 q_s
并且可以直接分配 q。
在控制状态机中,分配 next_state
到 current_state
的过程同样可以更新:
process (ck)
begin
if ck'event and ck = '1' then -- or rising_edge(ck)
current_state <= next_state;
end if;
end process;
只是为了便于阅读。使用 not ck'stable
形式来表示时钟事件并不常见,请注意您似乎也错过了实现 reg8
的含义,可能在 reg4
和 automat
中也是如此。
IEEE 标准 1076.6-2004 中演示了受保护表达式作为边沿敏感时钟的综合资格, 6.1.3.6 使用保护块的边缘敏感存储。