导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→[求助]请教VHDL高手。谢谢!!![caicaipp]

 *第13575篇: [求助]请教VHDL高手。谢谢!!!

  
楼 主:caicaipp 2003年6月17日18:20
 [求助]请教VHDL高手。谢谢!!!
急啊!!!!!!!!!!!!!!!!
我想做一个计数器,(假设是8位的)
现在有一个信号是 STD_LOGIC 类型的 (是输入量,标号位 u 吧)
一个时钟 clk
目的,当 u 改变时( 跳变 0->  1 或者是 1->  0 )  ——这个我不知道怎么做?
计数器清零
否则,时钟的上升沿,计数器 加 1 

请教高手。
谢谢各位。


[/size][/size][/size]

  
2楼:weihua_z 2003年6月17日19:32
 process(clk,u)
vari

process(clk,u)
variable cnt:integer range 0 to 7;  ----三位二进制整数,可改为八位。
begin
          if  u'event then     ----采用异步方式。
                  cnt:=0;
          elsif clk'event and clk='1' then
                  cnt=cnt+1;
          end if;       
end process;
  
3楼:caicaipp 2003年6月17日19:51
 谢谢你
不过这里这个
  .....

谢谢你
不过这里这个
  .......
  if u'event then   --好像编译不能通过的  有错误的
再请教
谢谢
  
4楼:huzimax 2003年6月17日22:29
 定义一个信号UT
process(cl

定义一个信号UT
process(clk)
variable cnt:integer range 0 to 7;  ----三位二进制整数,可改为八位。
begin
          if clk'event and clk='1' then
                 ut   <= u;
             if ut = u then
                cnt:=0;
            else
              cnt:=cnt+1;
            end if;
          end if;       
end process;
  
5楼:caicaipp 2003年6月17日23:05
 if  ut/=u  then 
 c

if  ut/=u  then 
 cnt:=0 ;

good 
不错
节省了我不少的资源,谢谢
谢谢各位!


>>>>>>对该主题发表你的看法

本主题贴数5,分页: [第1页]


[上一篇主题]:请教请教

[下一篇主题]:下载的某些*.bin文件怎样转成安装文件