微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > Can't resolve multiple constant drivers

Can't resolve multiple constant drivers

时间:10-02 整理:3721RD 点击:
大家好,我想请教一个问题,我在用Quartus II 仿真一个时钟程序的时候出现了一个问题,“Can't resolve multiple constant drivers  for net ....“ 请问这个是什么问题呢?但是用Modelsim仿真的时候就没有这个问题。请问一下这个程序有什么问题呢? 谢谢大家了 ,下面是我的一部分程序。
always @(negedge clk_1Hz)
if (!rst)
begin
sec<=0; min<=0; hour<=0; //初始化
end
else begin
if(sec==8'h59)
begin

sec<=0;
clk_min<=1;
end
else begin
if (sec[3:0]==4'b1001)
begin sec[3:0]<=0; sec[7:4]<=sec[7:4]+1;end
else sec[3:0]<=sec[3:0]+1; clk_min<=0;
end
end
decode47 M0(sec[3:0],a0,b0,c0,d0,e0,f0,g0);
decode47 M1(sec[7:4],a1,b1,c1,d1,e1,f1,g1);

/* minute*/
always @(posedge clk_min )
if(min==8'h59)
begin min<=0; clk_hour<=1;end
else begin
if (min[3:0]==4'b1001)
begin min[3:0]<=0; min[7:4]<=min[7:4]+1;end
else min[3:0]<=min[3:0]+1; clk_hour<=0;
end
decode47 M2(min[3:0],a2,b2,c2,d2,e2,f2,g2);
decode47 M3(min[7:4],a3,b3,c3,d3,e3,f3,g3);
/*hour*/
always @(posedge clk_hour )
if(hour==8'h23) hour<=0;
else if (hour[3:0]==9)
begin hour[7:4]<=hour[7:4]+1; hour[3:0]<=0; end
else hour[3:0]<=hour[3:0]+1;


decode47 M4(hour[3:0],a4,b4,c4,d4,e4,f4,g4);
decode47 M5(hour[7:4],a5,b5,c5,d5,e5,f5,g5);

我查了一下是同一信号 不能在不同得进程中赋值
但是同样得程序在Modelsim 中仿真的时候就没有出现这个问题
请问我是为什么呢?
如果修改的话,怎么修改呢?

“信号不能在多个并发进程中赋值”这是个代码的可综合方面的要求,也就是说一般综合工具会对此报错的,但从仿真角度上说是没有问题的,除非多个赋值造成冲突导致仿真无法继续,modelsim是纯粹的仿真工具,它不会关心代码是否可综合;据我所知,采用波形输入在quartus下进行时序仿真是需要先综合的,这样工具就会检查代码在可综合性方面的问题,因此会报你上述错误.只要将复位操作分开到每个寄存器描述进程中表达就行了.


谢谢了 !

Looks like there is a problem:
min & hour are driven by more than 1 processes:

1) always @(negedge clk_1Hz)
   if (!rst) begin
      sec<=0; min<=0; hour<=0; //初始化
   end ...
2) always @(posedge clk_min )
   if(min==8'h59) begin
   min<=0; clk_hour<=1;end...
3) always @(posedge clk_hour )
   if(hour==8'h23) hour<=0; ...

This is not allowed. To fix use one single process.

谢谢了,很好

这个我以前也做过

OK I know
Thank you

学习了。

这个问题我最近也遇到,,它我让我知道在并行语句汇中不能对同一信号进行赋值,原来是可综合的要求。又学了点东西

同一信号不能在不同得进程中赋值的解决办法
源程序:library ieee;
use ieee.std_logic_1164.all;
entity counter is
port(y,clk0:in std_logic;
    s1 :out std_logic);
end counter;
architecture rtl of counter is
signal en:std_logic;
begin
process(clk0)
variable i:integer;
begin
if(clk0'event and clk0='1')then
if(en='1')then
if(i=20)then
i:=0;
en<='0';
s1<=y;
else
s1<='0';
i:=i+1;
end if;
end if;
end if;
end process;
process(y)
begin
if(y'event and y='1')then
en<='1';
end if;
end process;
end rtl;
实现的功能:在输入y上升沿时计数,计数期间输出低电平,当计数到20个clk后计数结束,完后输出y的波形
出现的错误:Error (10028): Can't resolve multiple constant drivers for net "en" at test.vhd(30)

错误分析:误用Process经常会引起输出多驱动源的发生,即在两个以上的进程内对同一信号赋值操作。以下程序就出现了这类情况:
⑴ Proc_a: process(clk)
⑵ begin
⑶ if clk’event and clk=’1’ then
⑷ Dout<=Din_A;
⑸ end if
⑹ end process;;

⑻ Proc_b:process(sel_en)
⑼ begin
⑽ if sel_en=’1’ then
⑾ Dout<=Din_B;
⑿ end if;
⒀ end process;
进程Proc_a和Proc_b中都出现了对Dout的赋值语句,设计者原本的想法是,只要合理控制好clk和sel_en输入,使其不发生冲突,即clk上升沿时sel_en不为’1’;sel_en为’1’时,不出现clk的上升沿,这样Proc_a,Proc_b两个进程就不会发生冲突。但综合时,综合工具会将所有可能情况全部罗列进去,包括第⑶行和第⑽行同时成立的情况,此时对于Dout就有Din_A和Din_B两个输入驱动,Dout不知接收哪一个,因此该程序无法综合,改正的方法是只要将两个进程合并成一个即可
正确的程序:library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity test is
port(y,clk0: in std_logic;
    s1: out std_logic;
    debug_a: out std_logic);
end test;
architecture rtl of test is
signal en:std_logic;
signal i: integer range 0 to 30;--整形数据一定要指定范围,否则有意想不到的问题
signal temp:std_logic;
begin
process(clk0)
begin
if(clk0'event and clk0='1')then
   if(en='1')then
      if(i=20)then
         i<=0;
         s1<=y;
         debug_a<='1';
         temp<='1';
      else
         s1<='0';
         i<=i+1;
         debug_a<='0';
         temp<='0';
      end if;
   elsif (temp='1')  then
      s1<=y;temp<='0';
   else   s1<=y;
   end if;
end if;
end process;
process(y,temp)
begin
if (temp='1') then
    en<='0';
   
elsif  (y'event and y='1') then
    en<='1';           
end if;
end process;

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top