在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 3004|回复: 2

高手们帮忙看下我写的VHDL,大概知道是什么错误,但不清楚怎么改。。

[复制链接]
发表于 2007-1-6 20:27:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
Error (10028): Can't resolve multiple constant drivers for net "cnt[4]" at cabu.vhd(35)

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cabu is
generic(width:integer:=5);
port(
  data:in std_logic_vector(width-1 downto 0);
  lctl:in std_logic_vector(3 downto 0);
        lclk:in std_logic;
        rctl:in std_logic;
        wdir:in std_logic;
        ndir:in std_logic;
        clk: in std_logic;
        
        pulseut std_logic;
        finish:inout std_logic;
        
        eacc:in std_logic
        --precntut std_logic_vector(width-1 downto 0)
        );
end cabu;
architecture behave of cabu is
signal postcnt,cnt,curcnt,precnt:std_logic_vector(width-1 downto 0);
signal postv,velcnt,curv,minv,prev:std_logic_vector(width-1 downto 0);
signal accelerate,avcnt:std_logic_vector(width-1 downto 0);
signal accbool:std_logic;
signal rdir:std_logic;
begin
load:process(lclk)
begin
  if(lclk'event and lclk='1') then
   case lctl is
    when "0000" =>
     postcnt<=data;
    when "0001" =>
     cnt<=data;
    when "0010" =>
     curcnt<=data;
    when "0011" =>
     precnt<=data;
    when "0100" =>
     postv<=data;
    when "0101" =>
     velcnt<=data;
    when "0110" =>
     curv<=data;
    when "0111" =>
     minv<=data;
    when "1000" =>
     prev<=data;
    when "1001" =>
     accbool<=data(0);
    when "1010" =>
     accelerate<=data;
   
    when others =>
   end case;
  end if;
end process;

rdir<=wdir xor ndir;

run:process(clk)
begin
  if(clk'event and clk='1') then
   case rctl is
    when '0'=>--运行
     if rdir='0' then--正转
      if velcnt=2 then
       pulse<='1';
       velcnt<=velcnt-1;
       cnt<=cnt-1;
      
      elsif velcnt=1 then
       pulse<='0';
       if cnt=1 then
        finish<='1';--这一小段插补结束;
        
        precnt<=curcnt;
        cnt<=postcnt;
        curcnt<=postcnt;
        
        prev<=curv;
        velcnt<=postv;
        curv<=postv;
        
       else
      
       end if;
      elsif velcnt=0 then
          pulse<='0';
          velcnt<="00000";
      else
       velcnt<=velcnt-1;
       pulse<='0';
      end if;
     elsif rdir='1' then--反转
      
     end if;
    when '1'=>--停止
   end case;
  end if;
end process;
end behave;
发表于 2007-1-7 01:47:48 | 显示全部楼层

Some dicuess of your program

Forgive me, I can not type Chinese.
Your Problem is Share the Same signal at the same time , that because you use different Clock,
Load Process uses “lclk” ,and the Run Process used the “clk”.
We can consider the situation is that ,Just after Process Run modify the Value of one Signal, the Load Process convert the real Value, That will cause “classic Share Data Problem”

About Solution,
I want to know what is your really aim to accomplished in this program, Why you want to have 2 clocks, and the 2 process are separately or Happened by sequential.

En, Now I can give you a solution which I assume the two Process happen by the sequence of Load first and Run,
Just a Hint (Testing by Xilinx ISE 8.2 )

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity cabu is
generic(width:integer:=5);
port(
  data:in std_logic_vector(width-1 downto 0);
  lctl:in std_logic_vector(3 downto 0);
        lclk:in std_logic;    --load clk
        rctl:in std_logic;
        wdir:in std_logic;
        ndir:in std_logic;
        clk: in std_logic;
        
        pulseut ut std_logic;
        finish:inout std_logic;
        
        eacc:in std_logic
        --precntut std_logic_vector(width-1 downto 0)
        );
end cabu;

architecture behave of cabu is
signal postcnt,cnt,curcnt,precnt:std_logic_vector(width-1 downto 0);
signal postv,velcnt,curv,minv,prev:std_logic_vector(width-1 downto 0);
signal accelerate,avcnt:std_logic_vector(width-1 downto 0);
signal accbool:std_logic;
signal rdir:std_logic;
signal pulse :std_logic;

Type Ope_state_Type is (T0,T1,T2);  --define the operation state
signal Ope_state : Ope_state_Type;
signal Next_Ope_state : Ope_state_Type ;

begin


load:process(clk)
begin
case Ope_state is
when T0 =>    --do Load operation
   case lctl is
    when "0000" =>
     postcnt<=data;
    when "0001" =>
     cnt<=data;
    when "0010" =>
     curcnt<=data;
    when "0011" =>
     precnt<=data;
    when "0100" =>
     postv<=data;
    when "0101" =>
     velcnt<=data;
    when "0110" =>
     curv<=data;
    when "0111" =>
     minv<=data;
    when "1000" =>
     prev<=data;
    when "1001" =>
     accbool<=data(0);
    when "1010" =>
     accelerate<=data;
   
    when others =>
   end case;
   Next_Ope_State <= T1;

when T1 =>

   case rctl is
    when '0'=>
     if rdir='0' then
      if velcnt="0010" then
       pulse<='1';
       velcnt<= velcnt-'1';-- need to do logic operation
       cnt<=cnt-'1';
      
      elsif velcnt="0001" then
       pulse<='0';
       if cnt=1 then
        finish<='1';
        
        precnt <=curcnt;
        cnt <=postcnt;
        curcnt <=postcnt;
        
        prev<=curv;
        velcnt<=postv;
        curv<=postv;
        
       else
      
       end if;
      elsif velcnt="0000" then
          pulse<='0';
          velcnt<="00000";
      else
       velcnt<=velcnt-'1';
       pulse<='0';
      end if;
     elsif rdir='1' then
      
     end if;
    when '1'=>
        
        when others =>    ---consider the situation is that, the std_logic not just has the '1' and '0' also has the V ,X
   end case;
         next_Ope_state <= T0;
when others =>
end case;  -- end the case Ope_state
end process;

rdir<=wdir xor ndir;

clock_event : process( clk )
begin
if (clk'event and clk = '1') then
     Ope_state  <= Next_Ope_state;
end if;
end process;
end behave;
 楼主| 发表于 2007-1-7 13:05:15 | 显示全部楼层

回复 #2 lemony.vhdl 的帖子

Thank you for your help.
     The aim of my program is something like this: A counter and a
register,the register can be translated data when the counter is
counting,the counter subtract 1 when come a run clk,when it is 0,
the register give data to it.
    So,the main character of my program is the counter count without
halt.I must revolse how to translate data to register when counter is
counting.The lclk is not a clk,but like a enable port, active when want
to load data to register.
    thank you again,forgive me for my poor English.

[ 本帖最后由 lljdsp 于 2007-1-7 13:11 编辑 ]
vhdl功能图.jpg
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-11-17 18:33 , Processed in 0.027997 second(s), 12 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表