我有应该执行以下操作的VHDL代码:当按下KEY(0)(RESET)时,下一个上升时钟将启动该过程(50MHz)。它设置status_flag,并有一个新进程查看status_flag,并且每1000000(+ const)clk个周期,将更新一个称为DAC的值。我想随着clk-cntr的更新,它需要几个时钟周期,因此是常数。 (我使用了数据记录器,可以看到〜20.02ms)在第二个过程的底部,将clk-cntr重置为零。目标是在按下KEY(0)之后经历第二个过程,并等待下一次按下KEY。可以看到,我把status_flag注释掉了,因为编译器的响应是“无法解析多个常量驱动程序”。如何重置status_flag或类似代码以使代码等待KEY(0)?我正在使用实时响应,而不是模拟。
-- ---------------------------------------------------------------------
-- Global signals ------------------------------------------------------
-- ---------------------------------------------------------------------
CLK : in std_logic;
RESET : in std_logic;
);
结束实体test_top;
test_top的架构rtl是
shared variable status_flag : std_logic;
signal clk_cntr : unsigned(31 downto 0);
signal DAC : std_logic_vector(11 downto 0);
开始
DAC_Out_Rising_Edge: process(CLK)
begin
if rising_edge(CLK) then
if RESET = '1' then -- KEY(0) switch
status_flag := '1'; -- The encoder is triggered on the rising edge of the clock
end if;
end if;
end process;
Servo_routine: process(CLK)
begin
if rising_edge(CLK) then --
if (status_flag = '1') then
clk_cntr <= clk_cntr + 1;
if clk_cntr = 4 then
DAC <= "000000000000"; -- initialize value
end if;
if clk_cntr = 1000000 then
DAC <= "000000000010";
end if;
if clk_cntr = 2000000 then
DAC <= "000000000100";
end if;
if clk_cntr = 3000000 then
DAC <= "000000001000";
end if;
if clk_cntr = 4000000 then
DAC <= "000000010000";
end if;
if clk_cntr = 5000000 then
DAC <= "000000100000";
end if;
if clk_cntr = 6000000 then
DAC <= "000001000000";
end if;
if clk_cntr = 7000000 then
DAC <= "000010000000";
end if;
if clk_cntr = 8000000 then
DAC <= "000100000000";
end if;
if clk_cntr = 9000000 then
DAC <= "001000000000";
end if;
if clk_cntr = 1000000 then
DAC <= "000100000000";
end if;
if clk_cntr = 1100000 then
DAC <= "000010000000";
end if;
if clk_cntr = 1200000 then
DAC <= "000001000000";
end if;
if clk_cntr = 1300000 then
DAC <= "000000100000";
end if;
if clk_cntr = 14000000 then
DAC <= "000000010000";
end if;
if clk_cntr = 15000000 then
DAC <= "000000001000";
end if;
if clk_cntr = 16000000 then
DAC <= "000000000100";
end if;
if clk_cntr = 17000000 then
DAC <= "000000000010";
end if;
if clk_cntr = 18000000 then
DAC <= "000000000000";
end if;
if clk_cntr > 18000000 then
DAC <= "000000000000"; -- resets flags/data
clk_cntr <= (others => '0'); -- resets flags/data
if RESET = '0' then
--status_flag := '0'; -- The encoder is reset
end if;
end if;
end if;
end if;
end process;
答案 0 :(得分:1)
“多个常量驱动程序” 错误是SE中经常出现的问题。如果将其放在搜索框中,则会得到175个答案!
它们全部都用相同的解决方案完成:将所有分配移到一个过程中。
if RESET = '1' then
status_flag := '1'; // start
else
if clk_cntr > 18000000 then
status_flag := '0'; // stop
end if;
如果结束,