VHDL:进程和计数器不工作
VHDL : process and counter does not work
我正在尝试使用 process 语句在 vhdl 中编程。下面是我的 vhdl 代码
begin
dcm_clk PORT MAP(
CLKIN1_IN => clk,
RST_IN => reset,
CLKOUT0_OUT => clk0_fast,
CLKOUT1_OUT => clk0_dac,
CLKOUT2_OUT => clk90_fast, --13.33MHz ; div =60
CLKOUT3_OUT => clk_mux --26.67MHz ; div =30
);
process(clk_mux, reset)
begin
if (reset = '0') then
if rising_edge(clk_mux) then
if count_m = 0 then -- 0
MUX_0 <= '1';
count_m <= count_m + 1;
elsif count_m = 29 then
MUX_0 <= '0';
count_m <= count_m + 1;
elsif count_m = 57 then
MUX_0 <= '1';
count_m <= count_m + 1;
elsif count_m = 86 then
MUX_0 <= '0';
count_m <= count_m + 1;
elsif count_m = 115 then
count_m <= (others => '0');
end if; -- end count_m
end if; -- end clock
end if; -- end reset
count_m 的值似乎停留在值“1”。我不明白为什么计数器没有增量。任何帮助深表感谢。测试平台的输出如下所示
您的未标记进程仅针对 count_m 的四个特定值递增 count_m,而 count_m = 1 不是其中之一。
尝试:
UNLABELLED_PROCESS:
process (clk_mux, reset)
begin
if (reset = '0') then
if rising_edge(clk_mux) then
count_m <= count_m + 1;
if count_m = 0 then -- 0
MUX_0 <= '1';
-- count_m <= count_m + 1;
elsif count_m = 29 then
MUX_0 <= '0';
count_m <= count_m + 1;
elsif count_m = 57 then
MUX_0 <= '1';
-- count_m <= count_m + 1;
elsif count_m = 86 then
MUX_0 <= '0';
-- count_m <= count_m + 1;
elsif count_m = 115 then
count_m <= (others => '0');
end if; -- end count_m
end if; -- end clock
end if; -- end reset
end process;
它的作用是每隔 clk_mux 递增 count_m,当值为 115 时,将其分配给全“0”。
这给出了类似的东西:
如果我的时钟周期算术正确。请注意,count_m + 1 到 count_m 的赋值被 count_m = 115 的 if 语句覆盖。您还可以看到 MUX_0 是一个触发器,它的输出在指定更改的 count_m 值的下一个 clk_mux 上升沿之后更改。
调试帮助应该提供回答 reader 通过提供 Minimal, Complete, and Verifiable example 来重新创建特定错误的能力。
在这种情况下,这是 clk_mux 的第二个过程,四个具有必要初始值的信号声明(缺少任何重置操作)都在一个实体和体系结构对中:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity no_mcve is
end entity;
-- dcm_clk PORT MAP(
-- CLKIN1_IN => clk,
-- RST_IN => reset,
-- CLKOUT0_OUT => clk0_fast,
-- CLKOUT1_OUT => clk0_dac,
-- CLKOUT2_OUT => clk90_fast, --13.33MHz ; div =60
-- CLKOUT3_OUT => clk_mux --26.67MHz ; div =30
-- );
architecture foo of no_mcve is
signal count_m: unsigned (9 downto 0) := (others => '0');
signal clk_mux: std_logic := '0'; -- clock
signal mux_0: std_logic := '0';
signal reset: std_logic := '0';
begin
UNLABELLED_PROCESS:
process (clk_mux, reset)
begin
if (reset = '0') then
if rising_edge(clk_mux) then
count_m <= count_m + 1;
if count_m = 0 then -- 0
MUX_0 <= '1';
-- count_m <= count_m + 1;
elsif count_m = 29 then
MUX_0 <= '0';
count_m <= count_m + 1;
elsif count_m = 57 then
MUX_0 <= '1';
-- count_m <= count_m + 1;
elsif count_m = 86 then
MUX_0 <= '0';
-- count_m <= count_m + 1;
elsif count_m = 115 then
count_m <= (others => '0');
end if; -- end count_m
end if; -- end clock
end if; -- end reset
end process;
CLOCK:
process
begin
wait for 19.25 ns;
clk_mux <= not clk_mux;
if now > 7.3 us then
wait;
end if;
end process;
end architecture;
我正在尝试使用 process 语句在 vhdl 中编程。下面是我的 vhdl 代码
begin
dcm_clk PORT MAP(
CLKIN1_IN => clk,
RST_IN => reset,
CLKOUT0_OUT => clk0_fast,
CLKOUT1_OUT => clk0_dac,
CLKOUT2_OUT => clk90_fast, --13.33MHz ; div =60
CLKOUT3_OUT => clk_mux --26.67MHz ; div =30
);
process(clk_mux, reset)
begin
if (reset = '0') then
if rising_edge(clk_mux) then
if count_m = 0 then -- 0
MUX_0 <= '1';
count_m <= count_m + 1;
elsif count_m = 29 then
MUX_0 <= '0';
count_m <= count_m + 1;
elsif count_m = 57 then
MUX_0 <= '1';
count_m <= count_m + 1;
elsif count_m = 86 then
MUX_0 <= '0';
count_m <= count_m + 1;
elsif count_m = 115 then
count_m <= (others => '0');
end if; -- end count_m
end if; -- end clock
end if; -- end reset
count_m 的值似乎停留在值“1”。我不明白为什么计数器没有增量。任何帮助深表感谢。测试平台的输出如下所示
您的未标记进程仅针对 count_m 的四个特定值递增 count_m,而 count_m = 1 不是其中之一。
尝试:
UNLABELLED_PROCESS:
process (clk_mux, reset)
begin
if (reset = '0') then
if rising_edge(clk_mux) then
count_m <= count_m + 1;
if count_m = 0 then -- 0
MUX_0 <= '1';
-- count_m <= count_m + 1;
elsif count_m = 29 then
MUX_0 <= '0';
count_m <= count_m + 1;
elsif count_m = 57 then
MUX_0 <= '1';
-- count_m <= count_m + 1;
elsif count_m = 86 then
MUX_0 <= '0';
-- count_m <= count_m + 1;
elsif count_m = 115 then
count_m <= (others => '0');
end if; -- end count_m
end if; -- end clock
end if; -- end reset
end process;
它的作用是每隔 clk_mux 递增 count_m,当值为 115 时,将其分配给全“0”。
这给出了类似的东西:
如果我的时钟周期算术正确。请注意,count_m + 1 到 count_m 的赋值被 count_m = 115 的 if 语句覆盖。您还可以看到 MUX_0 是一个触发器,它的输出在指定更改的 count_m 值的下一个 clk_mux 上升沿之后更改。
调试帮助应该提供回答 reader 通过提供 Minimal, Complete, and Verifiable example 来重新创建特定错误的能力。
在这种情况下,这是 clk_mux 的第二个过程,四个具有必要初始值的信号声明(缺少任何重置操作)都在一个实体和体系结构对中:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity no_mcve is
end entity;
-- dcm_clk PORT MAP(
-- CLKIN1_IN => clk,
-- RST_IN => reset,
-- CLKOUT0_OUT => clk0_fast,
-- CLKOUT1_OUT => clk0_dac,
-- CLKOUT2_OUT => clk90_fast, --13.33MHz ; div =60
-- CLKOUT3_OUT => clk_mux --26.67MHz ; div =30
-- );
architecture foo of no_mcve is
signal count_m: unsigned (9 downto 0) := (others => '0');
signal clk_mux: std_logic := '0'; -- clock
signal mux_0: std_logic := '0';
signal reset: std_logic := '0';
begin
UNLABELLED_PROCESS:
process (clk_mux, reset)
begin
if (reset = '0') then
if rising_edge(clk_mux) then
count_m <= count_m + 1;
if count_m = 0 then -- 0
MUX_0 <= '1';
-- count_m <= count_m + 1;
elsif count_m = 29 then
MUX_0 <= '0';
count_m <= count_m + 1;
elsif count_m = 57 then
MUX_0 <= '1';
-- count_m <= count_m + 1;
elsif count_m = 86 then
MUX_0 <= '0';
-- count_m <= count_m + 1;
elsif count_m = 115 then
count_m <= (others => '0');
end if; -- end count_m
end if; -- end clock
end if; -- end reset
end process;
CLOCK:
process
begin
wait for 19.25 ns;
clk_mux <= not clk_mux;
if now > 7.3 us then
wait;
end if;
end process;
end architecture;