打印
[Actel FPGA]

求助:VHDL写的定时器程序

[复制链接]
2181|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
年轻不在|  楼主 | 2010-1-17 15:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
library ieee;
use ieee.STD_LOGIC_1164.ALL;
use ieee.STD_LOGIC_ARITH.ALL;
use ieee.STD_LOGIC_UNSIGNED.ALL;
entity dingshiqi is
TYPE time is range -1E8 to 1E8;
UNITS nasecs;
secs=1000000000 nasecs;
END UNITS;
Port ( clk : in std_logic;
Curptptime_secs:out time;
Curptptime_nasecs: out time);
--divclk : out std_logic);
end dingshiqi;
architecture Behavioral of dingshiqi is
signal counter0 : std_logic_vector(4 downto 0):="00000";
signal counter1 : std_logic_vector(7 downto 0):="11111111";
signal tempdivclk: std_logic:='0';
signal tempcurptptime_secs:time;
signal tempcurptptime_nasecs:time;
signal cv:std_logic_vector(4 downto 0):="00000";
begin
process(clk) --Divclk
begin
if clk'event and clk='1' then
if(counter0>="11111") then
counter0<="00000";
tempdivclk<=not tempdivclk;
else
counter0<=counter0+'1';
end if;
end if;
end process;
process(tempdivclk) --counter
begin
if tempdivclk'event and tempdivclk='1' then
if(counter1<="00000000") then
counter1<="11111111";
else
counter1<=counter1-'1';
cv<=counter1;
end if;
end if;
tempcurptptime_nasecs<=cv*64000+16384000;
end process;
Curptptime_nasecs<=tempcurptptime;
if Curptptime_nasecs>1000000000-1 then
Curptptime_nasecs<=Curptptime_nasecs-1000000000;
Curptptime_secs<=Curptptime_secs+1;
end if;
end Behavioral;
大家帮我看看,那里有问题啊,一直编译不通过。
编译出错是** Error: D:/ModelSim/examples/dingshiqi.vhd(7): near "TYPE": expecting: END

相关帖子

沙发
想实习去| | 2010-1-17 15:35 | 只看该作者
你这错误不少啊。首先时间类型在VHDL的标准程序包standard中是预定义了的,你这里没必要再弄了。另外随便看了看,比如: signal cv:std_logic_vector(4 downto 0):="00000";

这里很明显信号cv是五位的,而你下面的程序里: 

if(counter1<="00000000") then
counter1<="11111111";
else
counter1<=counter1-'1';
cv<=counter1;
把counter1赋给cv,counter1是八位的,明显是错误的。

使用特权

评论回复
板凳
beny5566| | 2010-1-17 15:36 | 只看该作者
仔细看看错误说明,
缺少一个end

使用特权

评论回复
地板
年轻不在|  楼主 | 2010-2-24 00:33 | 只看该作者
我的问题解决了,谢谢大家

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

106

主题

447

帖子

1

粉丝