|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
自己在ISE(14.7)里写了个计数器的代码,综合之后查看的RTL图如下(项目用的CPLD实现):
自己搞不懂是哪里除了问题,想请各位大佬看一下?
代码如下:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
library UNISIM;
use UNISIM.VComponents.all;
entity cnt8bc is
port (
txclk: in std_logic;
grst: in std_logic;
enable: in std_logic;
load: in std_logic;
oe: in std_logic; --output enable
up_down: in std_logic; --up and down counter control
cnt_inout: inout std_logic_vector(7 downto 0)--inout req'd
);
end cnt8bc;
architecture archcnt8b of cnt8bc is
signal cnt : std_logic_vector (7 downto 0) := "00000000"; --cnt signal
signal cnt_in : std_logic_vector (7 downto 0) := "00000000"; --cnt_in signal
begin
count: process (grst, txclk)
begin
if grst = '1' then--asynchronous reset
cnt <= "00111010";
elsif (txclk'event and txclk = '1') then
if load = '1' then --synchronous data loaded
cnt <= cnt_in;--from cnt_out port
else
if enable = '1' then --synchronous count enable
if up_down = '1' then
cnt <= cnt + 1;
elsif up_down = '0' then
cnt <= cnt -1;
end if;
end if;
end if;
end if;
end process count;
oes_out: process (oe, cnt)--three-state buffers
begin
if oe = '0' then
cnt_inout <= (others => 'Z');
else
cnt_inout <= cnt;
end if;
end process oes_out;
oes_in: process (oe, cnt_inout)--three-state buffers
begin
if oe = '1' then
cnt_in <= (others => 'Z');
else
cnt_in <= cnt_inout;
end if;
end process oes_in;
end archcnt8b;
|
|