各位朋友,大家好!
我刚学习
FPGA,选择的是VHDL语言,试着编写了一个二分频和四分频的程序,二分频成功了,但四分频却有问题,代码如下:
library ieee;
use ieee.std_logic_1164.all;
en
tity divclk is
port
(
-- Input ports
inclk : in std_logic;
outclk : out std_logic
);
end divclk;
architecture one of divclk is
signal tmp : std_logic;
signal count : integer;
begin
process(inclk)
begin
if(inclk'event and inclk = '1') then
count <= count + 1;
if(count = 2) then
tmp <= not tmp;
count <= 0;
end if;
end if;
outclk <= tmp;
end process;
end one;
输出时钟outclk总是保持低电平,看了半天没有找到错误,还请各位帮忙指教一下!拜托了。
use ieee.std_logic_1164.all;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity divclk is
port
(
-- Input ports
inclk : in std_logic;
outclk : out std_logic
);
end divclk;
architecture one of divclk is
signal tmp : std_logic;
signal count : std_logic_vector(1 downto 0);
begin
process(inclk)
begin
if(inclk'event and inclk = '1') then
if(count = "01") then
count <= (others=>'0');
tmp <= not tmp;
else
count <= count + 1;
end if;
end if;
end process;
outclk <= tmp;
end one;
一周热门 更多>