📄 pulse.txt
字号:
程序(1)
library ieee;
use ieee.std_logic_1164.all;
entity lcnt8 is --8位可自载加法计数器
port(clk,ld:in std_logic; --工作时钟/预置值加载信号
d:in integer range0 to 255;--8位分频预置数
cao:out std_logic); --计数溢出输出
end lcnt8;
architecture behav of lcnt8 is
signal count :integer range 0 to 255;--8位计数器设置
begin
process(clk)
begin
if clk'event and clk='1' then
if ld='1' then count <=d;--ld为高电平时加载预置数
else count<=count+1;
end if;
end if;
end process;
process(count)
begin
if count=255 then cao<='1';--计数满后,置位溢出位
else cao<='0';
end process;
end behav;
程序(2)
library ieee;
use ieee.std_logic_1164.all;
entity pulse is
port( clk:in std_logic;
a,b:in std_logic_vector(7 downto 0);
psout:out std_logic);
end pulse;
architecture mixed of pulse is
component lcnt8
port(clk,ld:in std_logic;
d:in std_logic_vector(7 downto 0);
cao:out std_logic);
end component;
signal cao1,cao2:std_logic;
signal ld1,ld2 :std_logic;
signal psint :std_logic;
begin
u1:lcnt8 port map(clk=>clk,ld=>ld1,
d=>a,cao=>cao1);
u2:lcnt8 port map(clk=>clk,ld=>ld2,
d=>b,cao=>cao2);
process(cao1,cao2)
begin
if cao1='1' then psint<='0';
elsif cao2'event and cao2='1' then psint<='1';end if;
end process;
ld1<=not psint;ld2<=psint;psout<=psint;
end mixed;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -