打印
[Quartus]

求助大神 看一下程序

[复制链接]
869|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
rhythmszn|  楼主 | 2015-11-11 18:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
一个可自动可手动的交通灯
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity control is
port(clk:in std_logic;
hold:in std_logic_vector(2 downto 0);
ared,agreen,ayellow,bred,bgreen,byellow:out std_logic);
end control;
  architecture behavior of control is
type state_type is(s0,s1,s2,s3);
signal current_state,next_state:state_type;
signal counter:std_logic_vector(2 downto 0);

begin
synch:process
begin
wait until clk'event and clk='1';
if hold="000"
  then counter<="000";
  elsif hold="001"
  then counter<="010";
  elsif hold="010"
  then counter<="100";
  elsif hold="011"
  then counter<="101";
else
if counter<5 then
counter<=counter+1;
else
counter<=(others=>'0');
end if;
end if;
end process;

process
begin
wait until clk'event and clk='1';
current_state<=next_state;
end process;
state_trans:process(current_state)
begin
case current_state is
when s0=>
if hold="000"
  then counter<="000";
  elsif hold="001"
  then counter<="010";
  elsif hold="010"
  then counter<="100";
  elsif hold="011"
  then counter<="101";
else
if counter<1 then
next_state<=s0;
else
next_state<=s1;
end if;
end if;

when s1=>
if hold="000"
  then counter<="000";
  elsif hold="001"
  then counter<="010";
  elsif hold="010"
  then counter<="100";
  elsif hold="011"
  then counter<="101";
else
if counter<2
then next_state<=s1;
else
next_state<=s2;
end if;
end if;

when s2=>
if hold="000"
  then counter<="000";
  elsif hold="001"
  then counter<="010";
  elsif hold="010"
  then counter<="100";
  elsif hold="011"
  then counter<="101";
else
if counter<4 then
next_state<=s2;
else
next_state<=s3;
end if;
end if;

when s3=>
if hold="000"
  then counter<="000";
  elsif hold="001"
  then counter<="010";
  elsif hold="010"
  then counter<="100";
  elsif hold="011"
  then counter<="101";
else
if counter<5 then
next_state<=s3;
else
next_state<=s0;
end if;
end if;
end case;
end process;

output:process(current_state)
begin
case current_state is
when s0=>
  ared<='0';
  agreen<='1';
  ayellow<='0';
  bred<='1';
  bgreen<='0';
  byellow<='0';
  
when s1=>
  ared<='0';
  agreen<='0';
  ayellow<='1';
  bred<='1';
  bgreen<='0';
  byellow<='0';
  
  when s2=>
  ared<='1';
  agreen<='0';
  ayellow<='0';
  bred<='0';
  bgreen<='1';
  byellow<='0';
  
when s3=>
  ared<='1';
  agreen<='0';
  ayellow<='0';
  bred<='0';
  bgreen<='0';
  byellow<='1';
  end case;
  end process;
  end behavior;



错误显示Error (10029): Constant driver at control.vhd(41)
Error (10028): Can't resolve multiple constant drivers for net "counter[1]" at control.vhd(16)
Error (10028): Can't resolve multiple constant drivers for net "counter[0]" at control.vhd(16)
Error: Can't elaborate top-level user hierarchy
Error: Quartus II 64-Bit Analysis & Synthesis was unsuccessful. 5 errors, 22 warnings
        Error: Peak virtual memory: 315 megabytes
        Error: Processing ended: Wed Nov 11 18:27:03 2015
        Error: Elapsed time: 00:00:01
        Error: Total CPU time (on all processors): 00:00:01
Error: Quartus II Full Compilation was unsuccessful. 7 errors, 22 warnings

相关帖子

沙发
liudanwei| | 2015-11-14 16:23 | 只看该作者
counter在两个进程中都有赋值

使用特权

评论回复
板凳
玄德| | 2015-11-15 16:34 | 只看该作者

不同进程操作同一个变量。
它不知道该听谁的,所以逻辑有误。

重新规划控制逻辑吧。



使用特权

评论回复
评分
参与人数 1威望 +1 收起 理由
奇异熊 + 1 赞一个!
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝