我的VHDL代码应该执行以下操作:当按下键(0)(复位)时,下一个上升时钟开始处理(50 the )。它设置status_flag,一个新的进程查看status_flag,并且每隔1000000(+ const)个clk周期,一个名为DAC的值被更新。我想,当clk-cntr更新时,它需要几个时钟周期,因此常量。(我使用了数据记录器,我可以看到约20.02ms)在第二个进程的底部,clk-cntr被重置为零。目标是在按键(0)后执行第二个过程,并等待下一次按键。可以看出,我注释掉了status_flag,因为编译器的响应是" can 't resolve multiple constant drivers“。如何重置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;发布于 2018-07-18 16:26:43
在SE中,“多个常量驱动”错误是一个反复出现的问题。如果你把它放在搜索框里,你会得到175个答案!
它们都有相同的解决方案:将所有任务移到一个进程中。
if RESET = '1' then
status_flag := '1'; // start
else
if clk_cntr > 18000000 then
status_flag := '0'; // stop
end if;end if;
https://stackoverflow.com/questions/51391914
复制相似问题