library ieee;--库使用说明
use ieee.std_logic_1164.all;--开发该库程序包所有项目 use ieee.std_logic_unsigned.all;--开发该库程序包所有项目
entity cent4b is--定义实体
port(clk:in std_logic;--定义信号量及端口模式数据类型 rst:in std_logic; ena:in std_logic; pst:in std_logic;
data:in std_logic_vector(3 downto 0);--同上 outy:out std_logic_vector(3 downto 0); cout:out std_logic); end cent4b;--结束实体定义
architecture behav of cent4b is--结构体描述 signal cqi:std_logic_vector(3 downto 0); begin
p_reg:process(clk,rst,ena,pst)--进程语句 begin--进程描述开始
if rst='1' then cqi<=\"0000\"; elsif clk'event and clk='1' then if pst='1' then cqi<=data; elsif ena='1' then cqi<=cqi+1; else cqi<=cqi; end if; end if; outy<=cqi;
end process p_reg;--进程描述结束
cout<=cqi(0) and cqi(1) and cqi(2) and cqi(3);--进位输出 end behav;--结构体描述结束。 述结束。
library ieee;--库使用说明
use ieee.std_logic_1164.all;--开发该库程序包所有项目 use ieee.std_logic_unsigned.all;--开发该库程序包所有项目
entity cent4b is--定义实体
port(clk:in std_logic;--定义信号量及端口模式数据类型 rst:in std_logic; ena:in std_logic; pst:in std_logic;
data:in std_logic_vector(3 downto 0);--同上 outy:out std_logic_vector(3 downto 0); cout:out std_logic); end cent4b;--结束实体定义
architecture behav of cent4b is--结构体描述 signal cqi:std_logic_vector(3 downto 0); begin
p_reg:process(clk,rst,ena,pst)--进程语句 begin--进程描述开始
if rst='1' then cqi<=\"0000\"; elsif clk'event and clk='1' then if pst='1' then cqi<=data; elsif ena='1' then
if (cqi=\"1001\") then cqi<=\"0000\"; cout<='1';
else cqi<=cqi+1; end if; else cqi<=cqi; end if; end if; outy<=cqi;
end process p_reg;--进程描述结束 end behav;--结构体描述结束。
因篇幅问题不能全部显示,请点此查看更多更全内容