|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
设计一个16位的计数器对CLK1计数,上位机通过STRB对当前的计数值进行锁存,CS为计数器的片选,RD为读选通,读取锁存后的计数值
在QUARTUS中仿真,结果正确,可下载到CPLD后,发现即使CLK1没有输入信号,计数器也在计数,即语句CLK1 'event AND CLK1='1'好像没有起作用,counter1<=counter1+'1';一直在运行
下面是程序,请帮我看看原因在哪,我用的型号是MAXII
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity counter is
port(
CS: in std_logic;
STROBE: in std_logic;
CLK1: in std_logic;
CLR: in std_logic;
RD: in std_logic;
DATA: out std_logic_vector(15 downto 0)
);
end counter;
architecture behavior of sixcounter is
signal counter1: std_logic_vector(15 downto 0):=x"0000"; --计数值
signal counter1_temp: std_logic_vector(15 downto 0):=x"0000"; --锁存值
begin
COUNT1: process(CS,CLR,CLK1) --计数
begin
if(CLR='0' AND CS='0') then
counter1<=x"0000";
elsif(CLK1 'event AND CLK1='1') then
if(counter1=x"FFFF") then
counter1<=x"0000";
else counter1<=counter1+'1';
end if;
end if;
end process COUNT1;
STRB: process(CS,STROBE) --锁存
begin
if(STROBE 'event AND STROBE='1') then
if(CS='0') then
counter1_temp<=counter1;
end if;
end if;
end process STRB;
READDATA: process(CS,RD) --读取
begin
if(CS='0' AND RD='0') then
DATA<=counter1_temp(15 downto 0);
else DATA<="ZZZZZZZZZZZZZZZZ";
end if;
end process READDATA;
end behavior; |
|