集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 7553|回复: 10

用Vhdl写的分频器的代码问题!

[复制链接]
tim 发表于 2010-6-27 23:51:31 | 显示全部楼层 |阅读模式
用Vhdl写的分频器的代码问题!
l

ibrary ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity fdiv is
port(clk , and3 :in   std_logic;--位同步时钟与逻辑门3的控制信号
   freclk: out std_logic);
end fdiv;
architecture fp of fdiv is
signal cnt:integer range 0 to 31;
begin
process(clk,and3)
begin
  if and3='0' then freclk='0';
elsif(clk'eventand clk='1')then
   if(cnt=cnt'high)then
    cnt<=0;
    freclk<='1';
   else
  cnt<=cnt+1;
  freclk<='0';
   end if;
end if;
end if;
end process;
end fp;

错误提示:Error: VHDL syntax error at fdiv.vhd(6) near text ?
Error: VHDL syntax error at fdiv.vhd(6) near text "?; expecting ";"
Error: VHDL syntax error at fdiv.vhd(6) near text ?
Error: VHDL error at fdiv.vhd(8): entity fdiv is used but not declared
Error: VHDL error at fdiv.vhd(9): object integer is used but not declared
Error: VHDL syntax error at fdiv.vhd(13) near text "="; expecting "'" or "(" or "."
Error: VHDL error at fdiv.vhd(16): object cnt is used but not declared
Error: VHDL error at fdiv.vhd(17): object freclk is used but not declared
Error: VHDL error at fdiv.vhd(19): object cnt is used but not declared
Error: VHDL error at fdiv.vhd(20): object freclk is used but not declared
Error: VHDL error at fdiv.vhd(15): object cnt is used but not declared
Error: VHDL error at fdiv.vhd(14): object clk is used but not declared
Error: VHDL error at fdiv.vhd(13): object and3 is used but not declared
Error: VHDL syntax error at fdiv.vhd(23) near text "if"; expecting "process"
Error: VHDL error at fdiv.vhd(11): object clk is used but not declared
Error: VHDL error at fdiv.vhd(11): object and3 is used but not declared
Error: Quartus II Analysis & Synthesis was unsuccessful. 16 errors, 0 warnings
    Error: Processing ended: Wed May 23 10:02:13 2007
    Error: Elapsed time: 00:00:02
ups 发表于 2010-6-28 00:22:42 | 显示全部楼层
将<br>
if and3='0' then freclk='0';<br>
&nbsp; &nbsp;&nbsp;&nbsp;elsif(clk'event&nbsp;&nbsp;and clk='1')then<br>
&nbsp; &nbsp;&nbsp; &nbsp; if(cnt=cnt'high)then<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; cnt&lt;=0;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; freclk&lt;='1';<br>
改为<br>
if and3='0' then freclk='0';<br>
&nbsp; &nbsp;&nbsp;&nbsp;elsif(clk'event&nbsp;&nbsp;and clk='1')then<br>
&nbsp; &nbsp;&nbsp; &nbsp; if(cnt=31)then<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; cnt&lt;=0;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; freclk&lt;='1';
CHANG 发表于 2010-6-28 05:02:31 | 显示全部楼层
建议好好学习下VHDL<br>
library ieee;<br>
use ieee.std_logic_1164.all;<br>
use ieee.std_logic_arith.all;<br>
<br>
entity fdiv is<br>
&nbsp; &nbsp; &nbsp; &nbsp; port(<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clk,and3&nbsp; &nbsp; &nbsp; &nbsp; : in&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;std_logic;--位同步时钟与逻辑门3的控制信号<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; freclk&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : out&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std_logic<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br>
end fdiv;<br>
<br>
architecture fp of fdiv is<br>
<br>
signal cnt&nbsp;&nbsp;:integer range 0 to 31;<br>
<br>
begin<br>
&nbsp; &nbsp; &nbsp; &nbsp; process(clk,and3)<br>
&nbsp; &nbsp; begin <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(and3 = '0') then<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; freclk &lt;= '0';<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elsif(clk'event&nbsp;&nbsp;and clk = '1') then<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(cnt = cnt'high) then<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cnt &lt;= 0;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; freclk &lt;= '1';<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cnt &lt;= cnt + 1;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; freclk &lt;= '0';<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if;<br>
&nbsp; &nbsp; &nbsp; &nbsp; end process;<br>
end fp;
CHAN 发表于 2010-6-28 06:19:46 | 显示全部楼层
看看,参考
ngtim 发表于 2010-6-28 07:23:13 | 显示全部楼层
多了一个END IF;<br>
freclk付值了两次
UFP 发表于 2010-6-28 08:45:01 | 显示全部楼层
还有一点忘记说了:cnt要在process下面定义,我认为是这样你先尝试下。
CHAN 发表于 2010-6-28 10:13:56 | 显示全部楼层
也可能是文件名与实体名不同造成的
longt 发表于 2010-6-28 10:34:21 | 显示全部楼层
看来论坛上热心的人也还挺多的嘛!!!!!!!!!!!!!!
encounter 发表于 2010-6-28 12:31:11 | 显示全部楼层
'?'表示有非法字符,所自己动手调试,很多提示错误就很容易看懂了;<br>
if语句的几种用法一定要看仔细了。
longt 发表于 2010-6-28 13:21:48 | 显示全部楼层
应该是文件名与实体名不同造成的。
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

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

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-4 00:59 , Processed in 0.075097 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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