当前位置:文档之家› 16第7章 层次化设计

16第7章 层次化设计

第七章大型设计中的层次结构7.1 设计方法概述CAD: Computer Aided DesignCAD技术是电子信息技术发展的杰出成果,它的发展与应用引发了一场工业设计和制造领域的革命。

EDA: Electronic Design Automation采用CAD技术进行电子系统和专用集成电路设计的技术。

EDA技术可面向三个不同的层次,即系统级、电路级和物理实现级。

现代EDA技术的特征:高级语言描述系统仿真(system simulation)综合优化(synthesis)传统的电子系统设计基本上采用自底向上(bottom-up)的设计方法,利用SPICE完成模拟验证。

这种方法要求设计者具有丰富的设计经验。

大部分电子系统的设计工作需要设计专家人工完成,同时任何一次设计方案的修改,都意味着一次详细设计过程的重复,再加上模拟验证速度较慢,因此无论在设计时间还是在设计精度上都不十分令人满意。

采用人工的自底向上设计方法,已很难满足当今电子系统的设计要求。

现在EDA采用的(top-down)的自顶向下的设计方法有效地实现了设计周期、系统性能和系统成本之间的最佳权衡。

这是一种层次化的设计方法。

设计在尽可能高的层次上开始进行,从而使设计者能在更大的空间内进行设计搜索,理解整个系统的工作状态,完成设计的权衡和相关的设计决策。

自上而下的设计方法,首先从系统设计入手,从顶层进行功能方框图划分和结构设计,这时的设计与工艺无关。

在方框图一级先进行仿真和纠错,用VHDL语言对高层次的系统行为级进行描述并在系统级进行验证。

然后,用逻辑综合优化工具生成具体门级逻辑电路的EDIF(Electronic Design Interchange Format,电子设计转换格式)网表,对应的物理实现级可以是PCB板或者是ASIC芯片。

设计的仿真和调试过程主要是在高层次完成,一方面有利于早期发现结构设计上的错误,避免设计工作的浪费,同时也减少了逻辑仿真的工作量。

自顶向下的设计方法方便了从系统级划分和管理整个项目;简化了设计队伍的管理;减少了不必要的重复;提高了设计的一次成功率。

同时,自顶向下的设计方法还提供整个设计过程中的各设计阶段的统一规范管理,包括系统的测试和各层次的模拟验证。

7.2数字系统设计与VHDL语言(1)系统设计主要解决:系统算法:总体算法行为、结构描述;系统设计划分:软硬件划分、单元划分、层次划分;软硬件结构:软硬件设计、实现结构;通信协议制定:板间、单元间、模块间的通信协议;(2)VHDL描述能力:(3)数字系统建模手段真值表:布尔方程、逻辑表达式状态图:状态机系统行为模型:行为描述算法行为模型:算法描述7.3 基本设计单元1、设计实体(实体说明entity构造体architecture)entity是设计的基本模块和设计的初级单元。

在层次化设计中,顶层有顶级实体,含在顶级实体中的较低层次的描述为低级实体。

靠元件例化把顶层实体和底层实体连接起来。

2、块blockblock语句的功能是将一大段并行语句代码,划分为多个block块。

它类似于在传统电路设计时,将一个大规模的电原理图,分割成多张子原理图的表示方法。

电原理图的分割关系,和VHDL 程序中用block块分割结构体的关系,是一一对应的。

block语句的语法格式为:块标号:block [(块保护表达式)][说明语句];begin[并发语句];End block标号名;块保护表达式是可选项,是一个布尔表达式。

只有保护表达式其为真时,该块中的语句才被启动执行。

否则,就不被执行。

用block语句形式设计一个“二选一”数据选择器的程序片段Architecture connect of mux isSignal tmp1,tmp2,tmp3: bit;beginCale:blockbegintmp1<=d0 and sel;tmp2<=d1 and (not sel);tmp3<=tmp1 or tmp2;q<=tmp3;end block cale;end connect;3、元件component程序包中的元件定义和使用4、函数function5、过程procedure6、程序包package程序包(package)是常用子程序和公用数据类型的集合,由程序包说明区域和程序包包体两部分组成,是构造设计的工具箱。

程序包说明区域可说明子程序、类型、常量和元件等。

7、库libraryieee;altera;lpm;std;work8、配置configuration1)、一个实体可以有多个构造体,通过配置语句可以建立实体-构造体之间的一一对应的连接关系。

2)、配置指出设计的每部分用哪一种元件,是把元件具体安装到实体的最基本的设计单元。

3)、配置为所配置的结构体指定具体安装元件的类属参数值,配置提供快速修改参数的能力,每当参数改变时,只需对配置重新编辑。

当一种实体、结构体的组合编辑到库中时就产生一个可仿真的对象。

程序包中的元件定义和使用下面的程序设计一个n位移位寄存器。

步骤:1、设计一个d触发器dff1;library ieee;use ieee.std_logic_1164.all;entity dff1 isport(clk,d:in std_logic;q:out std_logic);end entity dff1;architecture dff1 of dff1 isbeginprocess(clk)beginif rising_edge(clk) thenq<=d;end if;end process;end architecture dff1;2、设计一个程序包myflop,说明元件dff1(如何在程序包中说明元件?)library ieee;use ieee.std_logic_1164.all;package myflop iscomponent dff1 isport(clk,d:in std_logic;q:out std_logic);end component dff1;end package myflop;3、元件例化,完成n位移位寄存器的设计(顶层设计):library ieee;use ieee.std_logic_1164.all;entity register8 isgeneric(n:integer:=8);port(clk,data_in:in std_logic;data_out:out std_logic);end entity register8;use work.myflop.all;architecture gen of register8 issignal x:std_logic_vector(n downto 0);beginx(0)<=data_in;reg_gen: for i in 0 to n-1 generateu1: dff1 port map(clk,x(i),x(i+1));end generate reg_gen;data_out<=x(n);end architecture gen;7.4大型设计的一般步骤1、把描述电路可能用到的新的数据类型、子类型、常数定义在一个程序包中。

2、如果需要对新的数据类型、子类型进行运算符重载、则将重载运算符、函数、过程定义在一个程序包中。

3、根据电路功能要求,构造基本元件程序包,基本元件是指设计中反复使用的公共元件。

4、将电路按功能划分为子电路1)、确定每个子电路的接口(端口说明);2)、描述每个子电路的功能(构造体);3)、子电路模拟(局部模拟);5、描述子电路之间的连接关系(算法描述)6、顶层设计(完成元件的组装)7、整体功能模拟(前验)8、下载编程9、pcb版功能调试(后验)设计一个模为60的8421BCD计数器,并用数码管显示。

设计思路:●将问题分解为:1)一个模为60的8421BCD计数器;输出的高四位代表十位数,低四位代表个位数。

2)设计一个七段译码器;●计数器和译码器收录到公用程序包;●用元件例化来实现顶层设计。

程序1、模为60的8421BCD计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity cntm60 is port( clk,reset,load,enable:in std_logic;d:in std_logic_vector(7 downto 0);co:out std_logic;qh:buffer std_logic_vector(3 downto 0);ql :buffer std_logic_vector(3 downto 0));end cntm60;architecture behav of cntm60 isbeginp1:process(clk,reset)beginif reset='1' thenqh<="0000";ql<="0000";elsif rising_edge(clk) thenif load='1' thenqh<=d(7 downto 4);ql<=d(3 downto 0);elsif enable='1' thenif ql=9 thenql<="0000";if qh=5 thenqh<="0000";elseqh<=qh+1;end if;elseql<=ql+1;end if ;end if ;end if ;end process p1;co<='1' when qh="0101" and ql="1001"else '0';end architecture behav;程序2、设计七段译码器library ieee;use ieee.std_logic_1164.all;entity decode is port(data: in std_logic_vector(3 downto 0); decout:out std_logic_vector(6 downto 0)); end decode;architecture flow of decode isbegindecout<="1111110" when data="0000" else "0110000" when data="0001" else "1101101" when data="0010" else "1111001" when data="0011" else "0110011" when data="0100" else "1011011" when data="0101" else "0011111" when data="0110" else "1110000" when data="0111" else "1111111" when data="1000"else "1111011";end;程序3、设计程序包library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all; package cntpkg iscomponent cntm60 is port(clk,reset,load,enable:in std_logic;d:in std_logic_vector(7 downto 0);co:out std_logic;qh:buffer std_logic_vector(3 downto 0); ql:buffer std_logic_vector(3 downto 0)); end component;component decode is port(data: in std_logic_vector(3 downto 0); decout:out std_logic_vector(6 downto 0)); end component;end cntpkg;程序4、设计顶层文件library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity count60 isport(clk,reset,load,enable:in std_logic;d:in std_logic_vector(7 downto 0);co:out std_logic;q1:out std_logic_vector(6 downto 0);q2:out std_logic_vector(6 downto 0)); end count60;use tpkg.all;architecture arch of count60 issignal qa,qb: std_logic_vector(3 downto 0); beginu1:cntm60 port map(clk,reset,load,enable,d,co,qa,qb);u2:decode port map(qa,q1);u3:decode port map(qb,q2);end arch;。

相关主题