案例
模16计数器
输入48M,输出用数码管显示
分频
模16
译码
模2
多选
P1
P2
P4
P5
P3
48MHz
CLK10HZ
库、程序包
实体(Entity)
结构体
(Architecture)
进程或其它并行结构
配置(Configuration)
外部与内部:
器件或
子系统
ARCHITECTURE
Process Process
ENTITY
Sequential
Process
Combinational Process
ports
ports
component
ports
ports
library IEEE;
use ;
use ;
use ;
entity count10 is
port(clk: in std_logic;
dout:out std_logic_vector(6 downto 0);
dclk1:out std_logic);
end count10;
实体声明
端口模式:IN、OUT、INOUT、BUFFER
位(bit)
bit 表示一位的信号值。
放在单引号中,如‘0’或‘1’。
variable a, b : bit:=‘0’;
位矢量(bit_vector)
bit_vector 是用双引号括起来的一组位数据。
constant data:bit_vector(3 downto 0):=“1010”
整数(integer)
可实现的整数范围为: -(231-1)to (231-1)
VHDL综合器要求对具体的整数作出范围限定,
signal count:integer range 0 to 15:=0;
信号 count将被综合成由四条信号线
数据类型
标准逻辑位与矢量:
std_logic , std_logic_vector类型
为九值逻辑,如下:
(‘U’,‘X’,‘0’,‘1’,‘Z’,‘W’,‘L’,‘H’,‘-’)
‘U’:未初始化的, ‘X’:强未知的,
‘0’:强0, ‘1’:强1,
‘Z’:高阻态, ‘W’:弱未知的,
‘L’:弱0, ‘H’:弱1,
‘-’:忽略
结构体(由并发语句构成)
Architecture
并发语句
并发语句
信号
信号
信号
并发语句
Architecture
并发语句
并发语句
信号
信号
信号
并发语句
library IEEE;
use ;
use ;
use ;
entity count16 is
port(clk: in std_logic;
dout:out std_logic_vector(6 downto 0);
sel:out std_logic_vector(2 downto 0);
ncs:out std_logic);
end count16;
architecture Behavioral of count10 is
signal clk1k,clk10hz: std_logic:=‘0’;
signal u,v,w: integer range 0 to 9:=0;
signal s: integer range 0 to 7:=0;
设计输入举例
begin
t1: process(clk)
variable q: integer range 1 t0 2400000:=0;
variable p: integer range 1 t0 24000:=0;
begin
if clk'event and clk='1' then
if q=2400000 then
q:=1;clk10hz<=not clk10hz;
else
q:=q+1;
end if ;
if p=24000 then
p:=1;clk1k<=not clk1k;
else
p:=p+1;
end if ;
end if;
end process;
现代电子技术综合实验报告-VHDL 来自淘豆网www.taodocs.com转载请标明出处.