搜索
bottom↓
回复: 6

请教一个vhdl问题?

[复制链接]

出0入211汤圆

发表于 2009-11-24 10:52:28 | 显示全部楼层 |阅读模式
两个进程
prosess                           ---1号进程
...
temp1<=temp1+1;

end process

prosess                           ---2号进程
...
temp1<="0000000000000000";

end process

是不能这么做的,但是一个程序里面要实现这种思想该怎么办呢?

具体的就是,1号进程就是一个计数,二号进程过了1S中之后将temp1清零

cpld以往用的时候都是画画图,现在想学学vhdl,赐教?谢谢

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

发表于 2009-11-24 11:08:41 | 显示全部楼层
为什么不在一个进程里搞定呢?

出0入211汤圆

 楼主| 发表于 2009-11-24 11:48:55 | 显示全部楼层
process(second(0),d_in)
begin
  if(d_in'event and d_in='1')then
  pin_temp<=pin_temp+1;
  end if;
  
end process;

在一个进程里面就是上面这种了,second(0)这个是1S信号,d_in是计数输入信号

现在上面这段程序就能实现对d_in的计数,但是当S信号来了之后我要对d_in清零啊,怎么操作呢?
process(second(0),d_in)
begin
  if(d_in'event and d_in='1')then
  pin_temp<=pin_temp+1;
  end if;
  if(second(0)'event and second(0)='1')then
  pin_temp<="0000000000000000";
  end if;
end process;

象上面这么写又会报错,该怎么办呢?

出0入4汤圆

发表于 2009-11-24 12:07:45 | 显示全部楼层
楼主的程序从硬件角度来分析:pin_temp 是一个多bits的触发器, 可以由D触发器实现. OK.
但是d_in和second(0)都是上升沿的时钟信号,这样需要双时钟的D触发器. 现实中没有双时钟驱动的D触发器. 故例子失败!
故外接一个高频时钟(clk)来处理. 用这个时钟来检测d_in,second的边缘跳变. clk的频率按照精度要求确定.

process( rst, clk )    -- 复位和时钟
variable d, s : std_logic;
begin
  if( rst = '0' ) then
     pin_temp<="0000000000000000";
     d := '0';
     s := '0';
  elsif( clk'event and clk='1' ) then
     if( s='0' and second(0)='1') then
        pin_temp<="0000000000000000";
     elsif( d='0' and d_in='1' ) then
        pin_temp<=pin_temp+1;
      end if;
      
      s := second(0);
      d := d_in;
  end if;
end process;

出0入0汤圆

发表于 2009-11-24 21:05:59 | 显示全部楼层
entity counter32 IS
port( d_in             :in bit;  
          clr               :in bit;  
          pin_temp   :buffer  integer   );
end counter32;

architecture maxcpld of conter32 is
begin
process(clr,d_in,pin_temp)--pin_temp可有可无,没有的话有警告
begin
  if (clr=0)  then--clr=0清零
  pin_temp<=0;
  else
          if(d_in'event and d_in='1')then
          pin_temp<=pin_temp+1;
          else
          pin_temp<=pin_temp;
          end if;   
  end if;
end process;
end maxcpld;

出0入0汤圆

发表于 2009-12-2 14:21:37 | 显示全部楼层
楼主想实现什么样的功能呢?

出0入0汤圆

发表于 2010-3-4 10:41:45 | 显示全部楼层
回复【3楼】qinxg
-----------------------------------------------------------------------


(原文件名:1.png)

请教一下,图中从上到下依次记为Reset,Set,Q。要求Reset、Set的上升沿有效,不用到外部时钟可以实现吗?
另外,我写了这样一段程序:
entity test is
port(
                S    : in std_logic ;
                R    : in std_logic ;
                Q          : out std_logic
                );
end test;

architecture Behavioral of test is
signal temp_S,temp_R : std_logic ;
signal temp_S0,temp_R0 : std_logic ;
signal temp_Q : std_logic ;
signal temp : std_logic_vector(1 downto 0);
begin
        temp_S <= not S;
        temp_S0 <= temp_S and S ;
        temp_R <= not R;
        temp_R0 <= temp_R and R ;
        temp <= temp_R0 & temp_S0;
                       
        process(temp)
        begin       
          case temp is
            when   "01"=>temp_Q<='1';
            when   "10"=>temp_Q<='0';
            when  others => null;
          end case;
        end process;
        Q <= temp_Q ;
end Behavioral;
编译时出了以下这么多的警告,仿真结果就是上面的图形,但实际自然是不行了:
WARNING:Xst:737 - Found 1-bit latch for signal <temp_Q>.这个能理解
WARNING:Xst:1710 - FF/Latch  <temp_Q> (without init value) has a constant value of 0 in block <test>.
WARNING:Cpld:1006 - Design 'test' has no inputs.
WARNING:Cpld:997 - Error during loading TIMESPEC AUTO_TS_F2F =
WARNING:Cpld:310 - Cannot apply TIMESPEC AUTO_TS_P2P =
WARNING:Cpld:997 - Error during loading TIMESPEC AUTO_TS_P2F =
WARNING:Cpld:310 - Cannot apply TIMESPEC AUTO_TS_F2P =
还请抽空帮我看一看,
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-24 19:32

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表