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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 4409|回复: 3

[求助] 帮我看看这个计数器为什么总是提示Syntax error near "process"

[复制链接]
发表于 2012-5-21 10:42:19 | 显示全部楼层 |阅读模式

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

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

x
entity data_gen is
PORT( clk: in std_logic;
   rst: in std_logic;
   countut integer range 0 to 255
   );
end data_gen;
architecture Behavioral of data_gen is
begin
  process(clk,rst)
  
  variable counter:integer range 0 to 255;
  
  begin
  
   if (rst = '1') then
   
     counter <= (others => '0');
     
   else if (clk'event and clk = '1') then
   
     if (counter=255) then
      counter <= 0 ;
     else
      counter <= counter+1;
     end if;
   else
     counter <= counter;
   end if;
   
   count <= counter;
  
  end process;
end Behavioral;
发表于 2012-5-21 11:25:32 | 显示全部楼层
你的counter定义的是integer,赋值语句不能用<=,而是:=
 楼主| 发表于 2012-5-22 10:29:29 | 显示全部楼层
回复 2# 回家上自习


    library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity data_gen is
PORT( clk: in std_logic;
   rst: in std_logic;
   count : out integer
   );
end data_gen;
architecture count_255 of data_gen is
begin
  process(clk,rst)
  
  variable counter:integer :=0 ;
  
  begin
  
   if (rst = '1') then
   
     counter := 0;
     
   else if (clk'event and clk = '1') then
   
     if (counter = 255) then
      counter := 0 ;
     else
      counter := counter+1;
     end if;
   else  
     counter := counter;
   end if;
   
   count <= counter;
  end process;
  
end count_255;

我如果给PROCESS加上一个标号P1,进程结束 时end process p1;就会报两个错误, Syntax error near "process".Syntax error near "count_255".去掉进程的标号以后只有一个Syntax error near "process".
不知道是为什么总提示process的语法错误,求高人指点!
 楼主| 发表于 2012-5-22 10:53:38 | 显示全部楼层
回复 3# 乐烁橙


    else if (clk'event and clk = '1') then
错在这里:elsif (clk'event and clk = '1') then
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

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

GMT+8, 2024-10-3 21:34 , Processed in 0.019616 second(s), 8 queries , Gzip On, Redis On.

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