第八章 综合 (Synthesis)
综合:将较高层次的抽象描述转换到较低级别抽象描述的一种方法,即将设计的 VHDL描述转化为底层电路表示。
8.1 综合概述步骤:分析 VHDL程序、检测语法错误?将设计描述转化为数据结构
将设计行为描述转化为寄存器传输级 (RTL)描述工 艺 库
R T L 描 述属 性约 束 条 件综 合 器 门 级 网 表综合过程示意图
RTL,register transmission level 寄存器传输级
8.1.1 RTL级描述是以规定设计中采用各种寄存器形式为主要特征,然后在寄存器之间插入一些必要的组合逻辑电路寄 存 器 寄 存 器
C L K
C L K
组 合 逻 辑 电 路输 入输 出时 钟
RTL级描述的基本逻辑图例:用元件例化语句表示 RTL级描述(数据延时电路)
多 路 选 择 器
d f f 1 d f f 2
D DQ
Q
Q BQ B
C L K C L K
c lk
d in
e n a b le
d o u t
数据延时电路的逻辑电路图
library ieee;
use ieee.std_logic_1164.all;
entity data_delay is
port(din:in std_logic;
clk:in std_logic;
enable:in std_logic;
dout:out std_logic);
end data_delay;
architecture one of data_delay is
component dff
port(d,in std_logic;
clk,in std_logic;
q,out std_logic);
end component;
signal q_tmp1,q_tmp2,std_logic;
begin
dff1,dff port map(din,clk,q_tmp1);
dff2,dff port map(q_tmp1,clk,q_tmp2);
dout<=q_tmp1 whenenable=‘1’ else q_tmp2;
end one;
采用寄存器的推论方式表示 RTL级描述
library ieee;
use ieee.std_logic_1164.all;
entity data_delay is
port(din:in std_logic;
clk:in std_logic;
enable:in std_logic;
dout:out std_logic);
end data_delay;
architecture one of data_delay is
signal q1,q2,std_logic;
begin
reg_p:process
begin
wait until clk’event and clk=‘1’;
q1<=din;
q2<=q1;
end process reg_p;
dout<=q1 when enable=‘1’ else q2;
end one;
8.1.2 约束约束的目的:有效的控制优化输出和映射工艺约束内容:门级电路所占用的面积范围、延迟、功耗和可测性等
8.1.3 属性属性的作用:对设计的执行环境进行规定。
属性内容:负载、驱动、到达时间等
8.1.4 工艺库工艺库中含有综合过程为建立设计作正确选择的全部信息,如含有 ASIC单元的逻辑功能、含有该单元的面积范围、输入到输出的定时关系等
8.2 综合过程
采用 processing/start/start analysis & synthesis
或 processing/start/start analysis & elaboration指令进行分析和综合
采用 Tools/netlist viewer/RTL viewer
或 Tools/netlist viewer/Technology map viewer查看原理图第九章 存储器设计范例
9.1 只读存储器 (ROM)
逻辑功能:在地址信号的选择下从指定存储单元中读取相应的数据例,16× 8只读存储器
rom的电路符号
addr[3…0]
data[7…0]
en –使能端
data –数据输出端
rom
enaddr – 地址选择信号输入端
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity rom is
port(en:in std_logic;
addr,in std_logic_vector(3 downto 0);
data:out std_logic_vector(7 downto 0));
end rom;
architecture one of rom is
type memory is array(0 to 15) of std_logic_vector(7 downto 0);
signaldata1:memory:=(?10101001?,?11111101?,?11101001?,
11011100?,?10111001?,?11000010?,?11000101?,
00000100?,?11101100?,?10001010?,?11001111?,
00110100?,?11000001?,?10011111?,?10100101?,
01011100?);
signal addr1,integer range 0 to 15;
begin
addr1<=conv_integer(addr);
process (en,addr1,addr,data1)
begin
if en=‘1’ then
data<=data1(addr1);
else
data<=?ZZZZZZZZ?;
end if;
end process;
end one;
9.2 随机存储器 RAM
功能:在地址信号的选择下对指定的存储单元进行相应的读 /写操作例,32× 8的随机存储器
ram的电路符号
addr[4…0]
wr
rd
cs
datain[7…0]
dataout[7…0]
ram
addr – 地址选择信号输入端
wr – 写信号输入端
rd – 读信号输入端
cs – 片选信号输入端
datain – 数据写入端
dataout – 数据输出端
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ram is
port(wr,rd,cs:in std_logic;
addr,in std_logic_vector(4 downto 0);
datain:in std_logic_vector(7 downto 0);
dataout:out std_logic_vector(7 downto 0));
end ram;
architecture one of ram is
type memory is array(0 to 31) of std_logic_vector(7 downto 0);
signal data1:memory;
signal addr1,integer range 0 to 31;
begin
addr1<=conv_integer(addr);
process (wr,cs,addr1,datain,data1) --写操作
begin
if cs=‘0’ and wr=‘1’ then
data1(addr1)<=datain;
end if;
end process;
process (rd,cs,addr1,datain,data1) --读操作
begin
if cs=‘0’ and rd=‘1’ then
dataout<=data1(addr1);
else
dataout<=?ZZZZZZZZ?;
end if;
end process;
end one;
9.3 堆栈堆栈:是一种执行?后入先出?算法的存储器压入( push):数据一个一个存入存储器的过程;
弹出( pop):把数据一个一个的从存储器中读出的过程堆栈指示器:一个存放地址指针的寄存器。地址指针总是指向最后一个压入堆栈的数据所在的数据单元。
例,8字节堆栈
8字节堆栈的电路符号
clr
push
pop
clk
din[7…0]
empty
full
dout[7…0]
lifoclr – 清零端
push – 压栈信号输入端
pop – 出栈信号输入端
clk – 时钟
din – 数据写入端
dout – 数据输出端
empty – 栈空信号输出端
full – 栈满信号输出端
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity lifo is
port(clr,push,pop,clk:in std_logic;
empty,full,out std_logic;
din:in std_logic_vector(7 downto 0);
dout:out std_logic_vector(7 downto 0));
end lifo;
architecture one of lifo is
type memory is array(0 to 8) of std_logic_vector(7 downto 0);
begin
process (clk,clr) --写操作
variable stack:memory;
variable cnt:integer range 0 to 8; --堆栈指针
begin
if clr=‘1’ then
dout<=(others=>’0’);
cnt:=0;
full<=‘0’;
elsif clk’event and clk=‘1’ then
if push=‘1’ and pop=‘0’ and cnt/=8 then --压栈
empty<=‘0’;
stack(cnt)<=din; --存入数据
cnt=cnt+1; --指针加 1
elsif pop=‘1’ and push=‘0’ and cnt/=0 then --出栈
full<=‘0’;
dout<=stack(cnt);
cnt=cnt-1;
elsif cnt=‘0’ then
empty<=‘1’;
dout<=(others=>’0’);
elsif cnt=8 then
full<=‘1’;
end if;
end if;
end process;
end one;
9.4 FIFO(先入先出存储器)
FIFO:是一种单向数据传输物理器件,它只允许数据从输入端流向输出端。
其读 /写端口不需要地址线,只需要数据线与读写控制线例,8字节 FIFO
8字节 FIFO的电路符号
clk
clr
wr
rd
din[7…0]
empty
full
dout[7…0]
fifoclr – 清零端
wr – 写信号输入端
rd – 读信号输入端
clk – 时钟
din – 数据写入端
dout – 数据输出端
empty – 栈空信号输出端
full – 栈满信号输出端
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity fifo is
port(clr,wr,rd,clk:in std_logic;
empty,full,out std_logic;
din:in std_logic_vector(7 downto 0);
dout:out std_logic_vector(7 downto 0));
end fifo;
architecture one of fifo is
type memory is array(0 to 7) of std_logic_vector(7 downto 0);
begin
process (clk,clr) --写操作
variable a,b:integer range 0 to 7; --地址标志位
variable data:memory;
variable x,y:std_logic; --存储空间状态控制信号,满为 1,空为 0
begin
if clr=‘1’ then
dout<=(others=>’0’);
a:=0; b:=0;
x:=‘0’; y:=‘0’;
elsif clk’event and clk=‘1’ then
if wr=‘1’ and rd=‘0’ and x=‘0’ then --写入数据
data(a):=din;
a:=a+1;
y:=‘1’;
empty<=‘0’;
if a=b then
x:=‘1’;
end if;
elsif rd=‘1’ and wr=‘0’ and y=‘1’ then --读出数据
dout<=data(b);
b:=b+1;
x:=‘0’;
full<=‘0’;
if a=b then
y:=‘1’;
end if;
elsif x=‘0’ and y=‘0’ then
empty<=‘1’;
dout<=(others=>’0’);
elsif x=‘1’ and y=‘1’ then
full<=‘1’;
end if;
end if;
end process;
end one;