硬件描述语言VHDL及其应用.ppt

上传人:本田雅阁 文档编号:3296847 上传时间:2019-08-08 格式:PPT 页数:180 大小:1.28MB
返回 下载 相关 举报
硬件描述语言VHDL及其应用.ppt_第1页
第1页 / 共180页
硬件描述语言VHDL及其应用.ppt_第2页
第2页 / 共180页
硬件描述语言VHDL及其应用.ppt_第3页
第3页 / 共180页
硬件描述语言VHDL及其应用.ppt_第4页
第4页 / 共180页
硬件描述语言VHDL及其应用.ppt_第5页
第5页 / 共180页
点击查看更多>>
资源描述

《硬件描述语言VHDL及其应用.ppt》由会员分享,可在线阅读,更多相关《硬件描述语言VHDL及其应用.ppt(180页珍藏版)》请在三一文库上搜索。

1、硬件描述语言VHDL及其应用,哈工大微电子中心 王 进 祥,电话:6415979-806,2019/8/8,2,一、目的,了解目前电子设计系统方法及流程 了解/掌握综合与验证工具 能用VHDL设计复杂功能电路,二、内容,高层次设计概述 如何写优化的VHDL代码 examples SoC设计方法学 设计工具使用,三、如何学习本课程,带着实际课题学习,多提问题,一起分析、讨论,2019/8/8,3,一、高层次设计概述,EDA工具发展 设计方法 深亚微米设计问题 测试综合(可测性设计) Top-down设计流程 硬件描述语言 综合 VHDL设计小结,2019/8/8,4,1.1 EDA工具发展,20

2、19/8/8,5,1.1 EDA工具发展(Cont.),CAD: 逻辑图输入、逻辑模拟、电路模拟、版图设计和版图验证分别进行,需要对两者结果进行多次比较、修改。设计规模较小,CAE: 集逻辑图输入、逻辑模拟、测试码生成、电路模拟、版图设计、版图验证等工具一体,构成一个较完整的IC设计系统,EDA: HDL取代逻辑输入,逻辑网表由综合工具自动产生,可管理性增强,易于维护和数据交换,SoC: 采用深亚微米工艺生产技术,基于平台设计和IP复用技术,时序收敛性为首要目标,2019/8/8,6,自顶向下设计方法(Top-down) :系统行为设计 结构设计 逻辑设计 电路设计 版图设计,1.2 设计方法

3、,自底向上设计方法(Bottom-up): 系统功能划分 单元设计 功能模块设计 子系统设计 系统总成,基于平台设计方法(Platform-based): SoC设计普遍采用的方法,SoC平台和IPIntellectual Property,其它设计: 嵌入式设计方法,层次式设计方法等,2019/8/8,7,1.3 深亚微米设计问题,连线延时 时序模型 器件模型 信号完整性 电磁干扰 功耗 设计工具,综合优化工具,布图规划工具,SDF,PDEF,SDF标准数据格式,PDEF物理设计交换格式,2019/8/8,8,1.4 测试综合,目的: 集成电路的测试简单化 嵌入可测试结构,加速可测性设计 产

4、品制造前就可评价设计的可测性 消除冗余逻辑 诊断不可测的逻辑结构,内容: 测试嵌入、设计规则检查、测试码生成、故障模拟/诊断和输出测试图样,测试综合包括了使测试成功的每一步骤:如加入带测试因素的电路,对逻辑综合增加约束条件以满足测试要求及对高级语言描述的可测结构的综合等都可归结为测试综合,2019/8/8,9,1.4 测试综合(Cont.),方法: Full Scan Partial Scan BIST Boundary Scan,标准/规范: IEEE 1149 IEEE P1500 VSIA Related Spec.,SoC可测试设计: IP可测试设计 Glue Logic可测试设计 测

5、试存取结构,分类: 1Pass 2Pass,2019/8/8,10,1.5 Top-down设计流程,PLANNING,SYNTHESIS,FLOORPLAN, P&R,EXTRACTION,LVS/DRC,TIMING,LTL,2019/8/8,11,1.6 硬件描述语言,VHDL & Verilog VHDL Object EntityI/O界面描述 Architecture 功能定义 Process 行为模块 Library VHDL Object的集合 Package 数据类型、子程序、子单元的集合 Configuration Architecture/Parameter选择,2019

6、/8/8,12,1.6 硬件描述语言(Cont.),VHDL中的端口:In Out Inout Buffer,Entity,2019/8/8,13,1.7 综合,Definition:Synthesis = Translation + Optimization,HDL code gtech logic netlist,min(Speed X Area X Power),Optimization & technology Mapping,Behavioral Synthesis: Scheduling and Allocation Algorithm,2019/8/8,14,1.8 VHDL设计

7、小结,一个完整的设计由一些子单元相互连接而成 每个子单元有一个Entity和至少一个Architecture 单元间数据传递是通过在Entity中描述中所声明的端口进行,通信端口的信号类型、端口宽度以及端口方向要匹配 一个Architecture可包括Behavioral、Dataflow和Structure风格语句 子单元(Component)在使用之前要声明,2019/8/8,15,1.8 VHDL设计小结(Cont.),RS(255, 223)码译码器Top框图,2019/8/8,16,1.8 VHDL设计小结(Cont.),RS(255, 223)码译码器详细模块图,2019/8/8,

8、17,1.8 VHDL设计小结(Cont.),2019/8/8,18,1.8 VHDL设计小结(Cont.),2019/8/8,19,1.8 VHDL设计小结(Cont.),component xor8 port(in1, in2 : in bit8; xout : out bit8); end component; signal ctlN1m1, ctlN1, ctl254, ctl255 : std_logic; signal ctlobf, synfb : std_logic; signal fbo, dout, synout, lstsfe, bout : bit8; signal c

9、ntout : rsInt; signal iffto, syndout : bit8; signal bmfo : rsbit8_vector(0 to N2 - 1);,5,2019/8/8,20,1.8 VHDL设计小结(Cont.),begin u1 : control port map(reset, clk, ctlN1m1, ctlN1, ctl254, ctl255, ctlobf, synfb, cntout); u2 : syndrome port map(reset, clk, decin, synfb, syndout); u3 : bmexpand port map(r

10、eset, clk, syndout, cntout, synout, lstsfe, bout); u4 : bmfftbuf port map(reset, clk, ctl255, synout, lstsfe, bmfo); u5 : ifft port map(reset, clk, ctlN1m1, ctlN1, ctl254, bmfo, iffto); u6 : fftobuf port map(reset, clk, ctlobf, iffto, fbo); u7 : decbuf port map(reset, clk, decin, dout); u8 : xor8 po

11、rt map(fbo, dout, decout); end structural;,6,2019/8/8,21,二、如何写优化的VHDL代码,数据类型 并发/顺序赋值语句 小结 Process语句 资源共享 其它,2019/8/8,22,2.1 数据类型,2019/8/8,23,2.1 数据类型(Cont.),2019/8/8,24,2.1.1 赋值语句,i/ signal t, s : bit; s = 1; - s = t;,ii/ signal c : bit_vector(0 to 3); signal d : bit_vector(3 downto 0); c = “1011”;,

12、d = c; - ok ? c(0 to 3) = d(0 to 3) ok?,d = c; - ok ! c(0 to 3) = d(0 to 3) No!,2019/8/8,25,iii/ signal s, t, w, m : bit; signal c : bit_vector(0 to 3); c = “1011”; c = s ,c 1, 1 - s, 2- 1, 3 - 1); -Ok,2.1.1 赋值语句(Cont.),2019/8/8,26,iv/ signal a_vec : bit_vector(0 to 11); a_vec = B”1100_0011_0011_110

13、0”; a_vec = “1100001100111100”; a_vec = X”C33C”; a_vec = X”C3_3C”;,2.1.1 赋值语句(Cont.),2019/8/8,27,二进制B(Binary) 八进制O(Octal) 十六进制X(Hexadecimal),位串中的进制表示:,2.1.1 赋值语句(Cont.),2019/8/8,28,v/ signal A, B, C : bit_vector(3 downto 0); C = A and B;,2.1.1 赋值语句(Cont.),2019/8/8,29,vi/ slice of array entity VHDL i

14、s port(A : in bit_vector(0 to 7); outp : out bit); end VHDL; architecture E1 of VHDL is begin outp = A(5); end;,signal C : bit_vector(0 to 7); C(4) = 1; C(0 to 3) = “1001”;,2.1.1 赋值语句(Cont.),2019/8/8,30,vii/ Composite data type type date is record year : integer range 1980 to 2030; month : integer r

15、ange 1 to 12; day : integer range 1 to 30; end record; subtype bit8 is bit_vector(7 downto 0);,2.1.1 赋值语句(Cont.),2019/8/8,31,vii/ Composite data type signal weekday, today : date; weekday.year = 2003; weekday.monty = 2; weekday.day = 14; today = weekday;,2.1.1 赋值语句(Cont.),2019/8/8,32,2.1.2 数据类型转换,强类

16、型语言:VHDL具有丰富的数据类型,不同类型的对象(信号、变量)不能直接赋值,经常转换的数据类型:std_logic, bit, std_ulogic, boolean, signed unsigned, std_logic_vector, bit_vector,数据类型转换三种方法:类型标记转换法、 函数转换法和常数转换法,2019/8/8,33,类型标记转换法,std_logic and std_ulogic, std_logic_vector and signed std_logic_vector and unsigned integer and real等,signal a std_l

17、ogic_vector(0 to 7); signal b unsigned(0 to 7); b = unsigned(a);,2.1.2 数据类型转换(Cont.),2019/8/8,34,函数转换法,std_logic and bit std_ulogic and bit, boolean and bit, std_logic_vector and bit_vector integer and std_logic_vector/unsigned等,signal a std_logic_vector(0 to 7); signal b integer range 0 to 255; a =

18、 to_stdlogicvector(X”AF”); b = conv_ingeter(a);,2.1.2 数据类型转换(Cont.),2019/8/8,35,type typeconv_type is array(std_ulogiclow to std_ulogichigh) of bit; constant typeconv : typeconv_type := (0 | L = 0, 1 | H = 1, others = 0); signal s : std_ulogic; signal a : bit; a = typeconv(s);,常数转换法,2.1.2 数据类型转换(Con

19、t.),2019/8/8,36,How to transform bit type to boolean type?,signal bitty : bit; signal booly : boolean; booly = (bitty = 1);,Discussion,2.1.2 数据类型转换(Cont.),2019/8/8,37,2.1.3 逻辑运算与关系运算,运算符: and, or, not, xor, nand, nor =, /=, , =,Discussion: What is the result of the following relational statement?,20

20、19/8/8,38,2.1.4 算术操作,运算符: +, , *, mod, /, rem,操作数类型: std_logic_vector, integer, signed, unsigned,use ieee.std_logic_unsigned.all;,2019/8/8,39,2.1.4 算术操作(Cont.),signal a, b : std_logic_vector(3 downto 0); q1 = unsigned(a) + unsigned(b); q2 = unsigned(a) + signed(b); q3 = signed(a) + signed(b); q4 = a

21、 + b; q5 = (0 ,2019/8/8,40,2.1.5 连字符和聚集,连字符:concatenation operator 聚集: aggregates,signal A, B : std_logic_vector(3 downto 0); signal C : std_logic_vector(7 downto 0); signal D : std_logic; C = A ,2019/8/8,41,C(7) 1, 6 = D, 5 downto 2 = 1, others = 0); C = “00000000”; -初始化,C 0);,2.1.5 连字符和聚集(Cont.),2

22、019/8/8,42,2.2 并发/顺序赋值语句,并发赋值语句在architecture的begin和end之间,与书写顺序无关,每一条并发语句均可用一个process语句等价,顺序赋值语句只能在process和子程序的begin和end之间,它除信号赋值语句外,还有变量赋值,2019/8/8,43,2.2.1 并发赋值语句,D = A + E; A = B + C;,2019/8/8,44,2.2.1 并发赋值语句(Cont.),A = B + A;,并发赋值语句:,C = A; C = B;,组合逻辑环路!,Multi-driver, need resolved function,2019

23、/8/8,45,2.2.2 顺序赋值语句,D = A + E; A = B + C;,2019/8/8,46,2.2.2 顺序赋值语句(Cont.),C = A; C = B;,A = B + A;,组合进程:No! 时序进程:Ok!,2019/8/8,47,2.3 小结,一个设计由entity和architecture描述 数据对象类型有bit, boolean, integer, std_logic等标准类型和用户自定义类型 并发语句执行与书写顺序无关(order independent) VHDL是一种强类型语言(类型不能自动相互转换) 元件例化语句不能在process中,if语句和fo

24、r语句用于并发语句时,只能是generate语句,并发语句无变量赋值语句,2019/8/8,48,2.3 小结(Cont.),entity shift is port( reset, clk : in std_logic; din : in std_logic; dout : out std_logic); end shift; architecture str of shift is component dff port(reset, clk : in std_logic; d : in std_logic; q : out std_logic); end component;,signal

25、 tv : std_logic_vector(0 to 7); begin for I in 0 to 7 generate if I = 0 generate u1 : dff port map(reset, clk, din, tv(0); end generate; if I 0 and I = 7 generate u2 : dff port map(reset, clk, tv(I 1), tv(I); end generate; end generate; dout = tv(7); end str;,2019/8/8,49,2.4 process,描述电路功能或行为。由于综合后的

26、电路对所有输入信号变化敏感,因此所有被读信号均应包含在敏感表中,否则,综合前的模拟结果与综合后的模拟结果不一致!,2019/8/8,50,2.4.1 syntax,process_label : process(sensitivity list) declarations; begin statements; - if, loop, case, subprogram call etc end process process_label;,2019/8/8,51,2.4.1 syntax,P1 : process(A, B) Begin D = A or B and C; End process

27、 P1;,P1 : process(A, B, C) Begin D = A or B and C; End process P1;,2019/8/8,52,2.4.2 communication among process,architecture example,2019/8/8,53,2.4.3 if then else语句综合,i/. 引入寄存器,entity dff is port (d : in std_logic; clk : in std_logic; q : out std_logic); End dff;,architecture rtl of dff is begin i

28、nfer_reg : process(d, clk) begin if (clkevent and clk = 1) then q = d; end process infer; end rtl;,2019/8/8,54,2.4.3 if then else语句综合(Cont.),ii/. 引入锁存器,Infer_latch : process(A, B) begin if (A = 1) then x = B; end process infer_infer_latch;,Infer_latch : process(A, B) Begin x = 0; if (A = 1) then x =

29、 B; end process infer_infer_latch;,隐含了A = 0时 x = x; 不完全的else,2019/8/8,55,2.4.3 if then else语句综合(Cont.),iii/. 组合电路,entity comb is port(a, b : in bit; select : in bit; y : out bit); end comb;,architecture arch of comb is begin process(a, b, select) begin if (select = 1) then y = b; else y = a; end if;

30、 end process; end arch;,2019/8/8,56,2.4.3 if then else语句综合(Cont.),iv/. 异步复位,process(reset, clk, d) Begin if (reset = 0) then q = 0; elsif (clkevent and clk = 1) then q = d; end if; end process;,2019/8/8,57,2.4.3 if then else语句综合(Cont.),v/. 三态逻辑,signal s, sel, data : std_logic; process(sel, data) Beg

31、in if (sel = 1) then s = data; else s = Z; end if; end process;,1,2019/8/8,58,2.4.3 if then else语句综合(Cont.),v/. 三态逻辑,architecture beh of tribuf is signal asel, bsel, a, b, s : std_logic; begin pa : process(asel, a) begin s = Z; if (asel = 1) then s = a; end if; end process pa;,2,pb : process(bsel, b

32、) begin s = Z; if (bsel = 1) then s = b; end if; end process pb; end beh;,Multi driver!,2019/8/8,59,2.4.3 if then else语句综合(Cont.),Discussion,signal a, b, use_b : bit; process(a, b, use_b) Begin if (use_b = 1) then s = b; elseif(use_b = 0) then s = a; end if; end process;,1,Latch?,2019/8/8,60,2.4.3 i

33、f then else语句综合(Cont.),Discussion,signal a, b, use_b : std_logic; process(a, b, use_b) Begin if (use_b = 1) then s = b; elseif(use_b = 0) then s = a; end if; end process;,2,Latch?,2019/8/8,61,2.4.3 if then else语句综合(Cont.),Discussion,else assert false report “invalid use_b” severity error; end if; en

34、d process;,3,what?,signal a, b, use_b : std_logic; process(a, b, use_b) Begin if (use_b = 1) then s = b; elseif(use_b = 0) then s = a;,2019/8/8,62,2.4.3 if then else语句综合(Cont.),vi/. 在一个进程中,一个信号只能对应一个三态驱动,process(b, ub, a, ua) Begin dout = Z; if (ub = 1) then dout = b; end if; if (ua = 1) then dout =

35、 a; end if; end process;,2019/8/8,63,2.4.3 if then else语句综合(Cont.),vii/. Z值使用规则,如:dout = Z and din;,如:if (sel = Z) then 相当于 if false then,2019/8/8,64,2.4.3 if then else语句综合(Cont.),vii/. if then else语句小结,2019/8/8,65,2.4.4 case 语句,i/. syntax,case (expression) is when value = statements; when value | v

36、alue = statements; when value1 to value2 = statements; when others = statements; end case;,2019/8/8,66,2.4.4 case 语句(Cont.),ii/. case 语句规则,任意value互不相同,如无others分枝,必须穷尽所有可能的表达式值,如有others分枝,必须至少有一个表达值未列出,任意分枝中的语句可以有多条,2019/8/8,67,2.4.4 case 语句(Cont.),entity decoder is port(din : in std_logic_vector(0 t

37、o 2); q : out std_logic_vector(0 to 7); end decoder; architecture ex of decoder is begin process(din) begin case (din) when “000” = q q q = “00000100”;,when “011” = q q q q q q = “-”; end case; end process; end ex;,2019/8/8,68,2.4.5 for loop语句,i/. 语法,loop_label : for loop_var in range loop sequentia

38、l statements; end loop loop_label;,说明:loop_label可选,loop_var不需声明,综合时,循环语句将unrolled,Why loop statement ?,2019/8/8,69,2.4.5 for loop语句(Cont.),entity parsum is port(word : in std_logic_vector(0 to 7); par : out std_logic); end parsum; architecture addxor of parsum is begin process(word) variable ts : st

39、d_logic; begin ts : = 0;,for I in wordrange loop ts := ts xor word(I); end loop; par = ts; end process; end addxor;,Discussion: 如果ts为信号,结果是什么?,2019/8/8,70,2.4.6 数据对象,constant variable signal,i/. constant and variable,constant mask : std_logic_vector(0 to 7) := “00000000”; constant led_zero : bit_vec

40、tor(0 to 7) := X”7E”; variable tsum : std_logic_vector(3 downto 0);,2019/8/8,71,2.4.6 数据对象(Cont.),ii/. signal and variable,相同点:值可变,可综合为逻辑或线,不同点:变量赋值有立即性,且只用于process和subprogram中(VHDL-1076-87),而信号除此之外,还可用于并行语句中,应用:简单计算 signal 复杂计算 variable 中间结果 variable,2019/8/8,72,2.4.6 数据对象(Cont.),signal a, b, c, x,

41、 y : short process(a, b, c) begin c = a; x = c + 2; c = b; y = c + 4; end process;,signal a, b, x, y : short process(a, b, c) variable c : short; begin c := a; x = c + 2; c := b; y = c + 4; end process;,2019/8/8,73,2.4.6 数据对象(Cont.),signal,variable,2019/8/8,74,2.4.6 数据对象(Cont.),entity sigvar is port

42、(a, b, c, d : std_logic; q : out std_logic; end sigvar; architecture sig of sigvar is signal int : std_logic; Begin process(a, b, c, d, int) begin int = a and b and c; q = int or d; end process; end sig;,entity sigvar is port(a, b, c, d : std_logic; q : out std_logic; end sigvar; architecture sig of

43、 sigvar is Begin process(a, b, c, d) variablel int : std_logic; begin int := a and b and c; q = int or d; end process; end sig;,2019/8/8,75,2.4.7 wait 语句,wait until, wait, wait on, wait for,wait语句表明了信号激活process的条件,在process中,如有wait语句,敏感表必须取消,在process中,如既无wait语句,也无敏感表,则不能正确模拟,综合工具仅支持wait until语句(引入寄存器

44、)!,2019/8/8,76,2.4.7 wait 语句(Cont.),library ieee; Use ieee.std_logic_1164.all; entity count4 is port(updown : in std_logic; clk : in std_logic; dout : out integer range 0 to 15); end count4;,architecture behave of count4 is signal cnt : integer range 0 to 15; begin process begin wait until clkevent

45、and clk = 1;,if (updown = 1) then if (cnt = 15) then cnt = 0; else cnt = cnt + 1; end if; else if (cnt = 0) then cnt = 15; else cnt = cnt 1; end if; end if; end process; end behave;,2019/8/8,77,2.5 资源共享,硬件资源: 关系运算:=,/=,= 算术运算:+,*,/,每个运算符均要消耗大量的硬件资源,并产生延时!,如何用最小的资源实现相同的功能 ?,2019/8/8,78,2.5 资源共享(Cont.

46、),i/. if (sel_a = 1) then z = a + t; end if; if (sel_a = 0) then z = b + t; end if; ,1,2019/8/8,79,2.5 资源共享(Cont.),i/. z = a + t when sel_a = 1 else b + t; 或 if (sel_a = 1) then z = a + t; else z = b + t; end if;,2,2019/8/8,80,2.5 资源共享(Cont.),ii/. dout := 0; found := false; for k in 1 to 4 loop if(f

47、ound = false) then if (a(k) = 1) then dout := b(k) + c(k); found := true; end if; end if; end loop;,1,2019/8/8,81,2.5 资源共享(Cont.),ii/. t1 := 0; t2 := 0; found := false; for k in 1 to 4 loop if(found = false) then if (a(k) = 1) then t1 := b(k); t2 := c(k); found := true; end if; end if; end loop; dou

48、t := t1 + t2;,2,2019/8/8,82,2.5 资源共享(Cont.),iii/. 多进程 P1 : process begin wait until clkevent and clk = 1; if (sel = “00”) then reg_0 = dA + dB; end if; end process P1;,1,P2 : process begin wait until clkevent and clk = 1; if (sel = “01”) then reg_1 = dA - dB; end if; end process P2;,2019/8/8,83,2.5 资源共享(Cont.),iii/. 多进程 P3 : process begin wait until clkevent and clk = 1; if (sel = “10”) then reg_2 = dB - dA; end if; end process P1;,2,dout = reg_0 when sel = “00” else reg_1 when sel = “01” else reg_2 when sel = “10” else 0;,资源:3个加法器/减法器,资源共享不能在多进程间实现!,2019/8/8,84,2.5 资源共享(Cont.),

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1