我对VHDL编程很陌生,这是我的第一个项目--构建一个具有常规/反向计数顺序功能的二进制计数器。我的计划很简单:
flag。curr_s。ctl信号,然后切换curr_s并重置count的值-该值被设置为存储我的最后一个进程的计数。然而,现在问题是Quartus II返回了错误消息:
错误(10028):无法解析bi_counter.vhd(35)上的多个净“bi_counter.vhd”常量驱动程序 错误(10029):bi_counter.vhd上的恒定驱动程序(46) 错误(10028):无法解析bi_counter.vhd(35)上的多个净“bi_counter.vhd”常量驱动程序
..。
错误(10028):无法解析bi_counter.vhd(35)上的多个净“bi_counter.vhd”常量驱动程序
我谷歌了一下,还有一些规则,比如不允许在多个进程中更改signal的值,但问题是我将count声明为共享变量,而不是信号--这不应该遇到这样的错误。我打算这样做,因为我想使用count作为变量在进程之间交换信息--这有意义吗?如果没有,有什么解决办法吗?
这是我的代码:
--
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.numeric_std.all;
--
entity bi_counter is
port(
master_clk, ctl, rst: in std_logic;
q: out std_logic_vector(7 downto 0)
);
end bi_counter;
--
architecture behv of bi_counter is
shared variable curr_s: std_logic := '0'; -- 0 for incremental, 1 for reverse counting
shared variable count: integer := -1;
shared variable master_count: natural := 0;
signal flag: std_logic;
begin
p_freq_div: process(master_clk, rst)
begin
if rst = '0' then
master_count := 0;
elsif master_clk'event and master_clk='1' then
master_count := master_count + 1;
if master_count = 24000000 then
flag <= not flag;
master_count := 0;
end if;
end if;
end process p_freq_div;
p_count: process(flag)
begin
if curr_s = '1' then
count := count + 1;
q <= conv_std_logic_vector(count, 8);
else
count := count - 1;
q <= conv_std_logic_vector(count, 8);
end if;
end process p_count;
p_switch: process(ctl)
begin
if ctl'event and ctl='1' then
curr_s := not curr_s;
if curr_s = '0' then
count := 0;
else
count := 1000;
end if;
end if;
end process p_switch;
end behv;发布于 2014-12-08 18:52:42
你写道:
我谷歌了一下,有一些规则,比如不允许在多个进程中更改信号的值,但问题是我将计数声明为共享变量,而不是信号--这不应该遇到这样的错误。
这条“规则”并不仅仅是为了让你的生活更加艰难。
想想你想做什么。你试图合成一些东西,把它放在你的设备上,这个值是你试图从两个独立的进程中分配的(尽管它们可能是相关的,你知道它们应该如何工作,但它们仍然是独立的)。不管你使用什么语言元素--信号,变量,任何东西--一旦你到达只有物理电路的设备,它就变得无关紧要了。也就是说,你可能没有违反任何语言规则,但你违反了一条物理规则。
您的输出可以用以下形式表示:如果有条件,那么输出一些条件,如果其他条件,输出其他条件,等等,这可以放在一个过程中,这就是我建议您所做的。
此外,正如Russell建议的那样,您可能不应该使用共享变量,特别是像以前那样绕过语言规则。
https://stackoverflow.com/questions/27363894
复制相似问题