VHDL求解,一段计数程序。小弟不是伸手党,但实在没辙了。先谢过大神了。

architectureartofcountissignalsecg,secs:std_logic_vector(3downto0);--secg,是个位,secs是十位... architecture art of count is
signal secg,secs: std_logic_vector(3 downto 0);--secg,是个位,secs是十位。
signal co: std_logic;
begin
process(cl_r,clk,add) is
begin
if cl_r='0' then
secg<="0000";secs<="0000";co<='0';
elsif clk='1'and clk'event then
if secg="1001" and secs="0101" then
secg<="0000";secs<="0000";co<='1';
elsif secg="1001" then
secs<=secs+1;secg<="0000";co<='0';
elsif secg<"1001" then
secg<=secg+1;
end if;
end if;
if add'event and add='1' then--想要add按一次,secg就加1.
secg<= secg+1;
end if;
c<=co;
ssec<=secs;
gsec<=secg;
end process;
end architecture;

错误:
Error (10820): Netlist error at count.vhd(28): can't infer register for secg[0] because its behavior depends on the edges of multiple distinct clocks
Error (10820): Netlist error at count.vhd(28): can't infer register for secg[1] because its behavior depends on the edges of multiple distinct clocks
Error (10820): Netlist error at count.vhd(28): can't infer register for secg[2] because its behavior depends on the edges of multiple distinct clocks
Error (10820): Netlist error at count.vhd(28): can't infer register for secg[3] because its behavior depends on the edges of multiple distinct clocks
Error (10822): HDL error at count.vhd(19): couldn't implement registers for assignments on this clock edge
Error (10822): HDL error at count.vhd(28): couldn't implement registers for assignments on this clock edge
展开
 我来答
斯里哇啦
2012-10-16 · TA获得超过210个赞
知道小有建树答主
回答量:342
采纳率:100%
帮助的人:305万
展开全部
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY count IS
PORT(clk : IN STD_LOGIC;
cl_r : IN STD_LOGIC;
add : IN STD_LOGIC;
c : OUT STD_LOGIC;
ssec : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
gsec : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
);
END count;
architecture art of count is
signal secg,secs: std_logic_vector(3 downto 0);--secg,是个位,secs是十位。
signal co: std_logic;
begin
process(clk,cl_r,add) is
begin
if cl_r='0' then
secg<="0000";
secs<="0000";
co<='0';
elsif clk='1'and clk'event then
if(add='1')then
secg<= secg+1;
else
if secg="1001" and secs="0101" then
secg<="0000";
secs<="0000";
co<='1';
elsif secg="1001" then
secs<=secs+1;
secg<="0000";
co<='0';
elsif secg<"1001" then
secg<=secg+1;
end if;
end if;
end if;
c<=co;
ssec<=secs;
gsec<=secg;
end process;
end architecture;

不能同时为secg设置两个触发条件
更多追问追答
追问
劳大哥费心了,但是你放在IF语句里面,但是不管有没有ADD,只要来一个上升沿都会加1啊,这样没额外加。
追答
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY count IS
PORT(clk : IN STD_LOGIC;
cl_r : IN STD_LOGIC;
add : IN STD_LOGIC;
c : OUT STD_LOGIC;
ssec : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
gsec : OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
);
END count;
architecture art of count is
signal secg,secs: std_logic_vector(3 downto 0);
signal co: std_logic;
begin
process(clk,cl_r,add) is
begin
if cl_r='0' then
secg<="0000";
secs<="0000";
co<='0';
elsif clk='1'and clk'event then
if(add='1')then
secg<= secg+1;
end if;
if secg="1001" and secs="0101" then
secg<="0000";
secs<="0000";
co<='1';
elsif secg="1001" then
secs<=secs+1;
secg<="0000";
co<='0';
elsif secg<"1001" then
secg<=secg+1;
end if;
end if;
c<=co;
ssec<=secs;
gsec<=secg;
end process;
end architecture;

那天都上床睡觉了 睡着前突然想到写错了..后来没法改了就补了条评论
这次应该差不多 可以试试
WangShiFeng08
2012-10-16
知道答主
回答量:2
采纳率:0%
帮助的人:2857
展开全部
你这太乱了,要养成好的习惯,大小写,空格什么的。
个人觉得主要原因是在一个Process中,不能有两个判别上升沿的语句,在你的程序中判断了clk和add两个信号值的上升沿,所以会错误。
可以把判断add的上升沿去掉,然后定义两个中间信号
Sginal:add1,add2:STD_LOGIC;
add1<=add;
add2<=add1;
IF(add1 AND NOT add2 = '1')THEN
这样的方式来避免在同一个Process中有两个判断上升沿的现象。

不知对错,仅供参考。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式