当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

黑龙江大学物理科学与技术学院:《EDA教程——EDA技术及应用》第六章 VHDL中属性的描述及定义语句(蔡喜平)

资源类别:文库,文档格式:PPT,文档页数:24,文件大小:159KB,团购合买
一、属性:指设计实体、结构体、数据类型、信号等对象的特定特征。 二、VHDL的预定义属性分类: 1、数值类属性; 2、函数类属性; 3、信号类属性; 4、数据类型类属性; 5、数据区间类属性。
点击下载完整版文档(PPT)

第六章VD中属性的描语句 属性:指设计实体、结构体、数据类型、信号等对象的特定特征。 VHDL的预定义属性分类: 数值类属性; 函数类属性 信号类属性 ●数据类型类属性; ●数据区间类属性 表示一个对象属性的书写格式: 对象”属性名 61数值类属性 用于返回有关常用数据类型、数组类型或块的特定值;还可用于返回数组的 长度或者数据类型的上下界等。 数值类属性分为三个子类: 数据类型的数值属性; 数组的数值属性; 曾块的数值属性

第六章 VHDL中属性的描述及定义语句 属性:指设计实体、结构体、数据类型、信号等对象的特定特征。 VHDL的预定义属性分类: ⚫数值类属性; ⚫函数类属性; ⚫信号类属性; ⚫数据类型类属性; ⚫数据区间类属性。 表示一个对象属性的书写格式: 对象’属性名 6.1 数值类属性 用于返回有关常用数据类型、数组类型或块的特定值;还可用于返回数组的 长度或者数据类型的上下界等。 数值类属性分为三个子类: 数据类型的数值属性; 数组的数值属性; 块的数值属性

611数值类型的数值属性 ●用来返回一个数据类型或子类型的边界值,此边界值通常是指上下限和左右限 ●数据类型的数值属性 (1)’lef返回一个数据类型或子类型最左端的值,即类型的左边界; (2)righ返回一个数据类型或子类型最右端的值,即类型的右边界 (3)’high:返回一个数据类型或子类型的高端值,即类型的上限值; (4)’low:返回一个数据类型或子类型的低端值,即类型的下限值; 如:定义一个数据类型 type numberis integer range 0 to 7; num ber left=o number’ right=7 number high=7 number low=0 如: type wordis array(15 downto O)of std_logic; word left= 15 word right=0 word high=15 wor Ow 0

6.1.1 数值类型的数值属性 ⚫用来返回一个数据类型或子类型的边界值,此边界值通常是指上下限和左右限 ⚫数据类型的数值属性: (1)’left: 返回一个数据类型或子类型最左端的值,即类型的左边界; (2)’right: 返回一个数据类型或子类型最右端的值,即类型的右边界; (3)’high: 返回一个数据类型或子类型的高端值,即类型的上限值; (4)’low: 返回一个数据类型或子类型的低端值,即类型的下限值; 如:定义一个数据类型 type number is integer range 0 to 7; number’left = 0 number’right = 7 number’high = 7 number’low = 0 如: type word is array (15 downto 0) of std_logic; word’left = 15 word’right = 0 word’high = 15 word’low = 0

●数据类型的数值属性并不限定数值的数据类型,适用于任何一种标量类型 例:枚举类型定义: type weekis(sunday, monday, tuesday, wednsday, thursay, friday, saturday); subtype sub_weekl is week range wednsday to friday subtype sub_week 2 is week range friday downto wednsday; 可得如下关系式: week left sunday weeknight=saturday week high =saturday weck’low= sunday sub_week1" leftwednsday Lb week 1’ight= friday sub_week1 high=friday sub_week1" low=wednsday sub week2 left=fric sub_week2 right=wednsday sub_week2 high=friday sub week2 low=wednsday

⚫数据类型的数值属性并不限定数值的数据类型,适用于任何一种标量类型 例:枚举类型定义: type week is (sunday, monday, tuesday, wednsday, thursay, friday, saturday); subtype sub_week1 is week range wednsday to friday; subtype sub_week2 is week range friday downto wednsday; 可得如下关系式: week’left = sunday week’right=saturday week’high= saturday week’low = sunday sub_week1’left=wednsday sub_week1’right=friday sub_week1’high=friday sub_week1’low=wednsday sub_week2’left=friday sub_week2’right=wednsday sub_week2’high=friday sub_week2’low=wednsday

612数组的数值属性 作用:返回数组类型的长度值 VHDL中预定义的数组的数值属性: length:返回一个限定性数组的长度值,即数组中元素的个数; 如:定义如下几个数组类型: type wordis array (15 downto o) of std_ logic, type dwordis array (31 downto O)of std _logic type matrixis array(0 to 7, 0 to 5)of std logic 可返回如下数值属性 word length=16 dword length=32 matrix length 1)=8 matrix length (2=6 matrix length=8

6.1.2 数组的数值属性 作用:返回数组类型的长度值 VHDL中预定义的数组的数值属性: ‘length:返回一个限定性数组的长度值,即数组中元素的个数; 如:定义如下几个数组类型: type word is array (15 downto 0) of std_logic; type dword is array (31 downto 0) of std_logic; type matrix is array ( 0 to 7, 0 to 5) of std_logic; 可返回如下数值属性: word’length = 16 dword’length =32 matrix’length(1) = 8 matrix’length(2) = 6 matrix’length = 8

例: library ieee; useieee.std_logic_1164.all; entity compare 1s port(input; in std_logic_vector(7 downto O); Input2: integer; g: out std _ logic) end compare, architecture rt1 of compare is function vector_to_int(a: in std_logic_vector)return integers variableresult, tmp: integer: =0; egin foriin a low to a' length-1loop tmp: =0; if (a(i)=1 )then tmp:=2*-a’low); eIs assert(a(i)=0) report no conversion severity warnings end if result=result+tmp; end loop return(result); end vector to int

library ieee; use ieee.std_logic_1164.all; entity compare is port(input1:in std_logic_vector(7 downto 0); input2: in integer; q: out std_logic); end compare; architecture rt1 of compare is function vector_to_int (a: in std_logic_vector) return integer is variable result, tmp: integer:=0; begin for i in a’low to a’length-1 loop tmp:=0; if (a(i)=‘1’) then tmp:=2 ** (i-a’low); else assert( a(i)=‘0’) report “no conversion” severity warning; end if; result:=result+tmp; end loop return (result); end vector_to_int; 例:

begin process (inputl) begin if (vector_to_int(input1)>input2) then q else end if: end process end rtl; 例:串入/并出移位寄存器 输入端口的数据在时钟边沿的作用下逐级向后移动,达到一定位数后并行输出。 ●原理图编辑法 74164 CLRN SHFT REG

begin process (input1) begin if (vector_to_int(input1)>input2) then q<=‘1’; else q<=‘0’; end if; end process; end rt1; 例:串入/并出移位寄存器 输入端口的数据在时钟边沿的作用下逐级向后移动,达到一定位数后并行输出。 ⚫原理图编辑法 SHIFT REG. CLRN CLK B A QD QC QA QF QH QG QE QB 74164 inst VCC A INPUT VCC B INPUT VCC CLRN INPUT VCC CLK INPUT OUTPUT Q[0] OUTPUT Q[1] OUTPUT Q[2] OUTPUT Q[3] OUTPUT Q[4] OUTPUT Q[5] OUTPUT Q[6] OUTPUT Q[7]

VCC A INPUT VCC B INPUT VCC CLRN INPUT GND CLK INPUT QA OUTPUT QB OUTPUT QC OUTPUT QD OUTPUT QE OUTPUT QF OUTPUT QG OUTPUT QH OUTPUT AND2 2 CLRN D PRN Q DFF 3 CLRN D PRN Q DFF 4 CLRN D PRN Q DFF 5 CLRN D PRN Q DFF 6 CLRN D PRN Q DFF 7 CLRN D PRN Q DFF 8 CLRN D PRN Q DFF 9 CLRN D PRN Q DFF 10 74164 TITLE MacroFunction COMPANY ALTERA CORPORATION DESIGNER Applications Engineering NUMBER 1.00 REV A DATE Tue May 18 16:25:49 1999 SHEET 1 OF 1

●文本输入法 Sipo clk-时钟 dout4…0 cl-清零端 din-数据输入端 kdn dout[4Q-数据输出端 带有同步清零的5位串入并出 移位寄存器的电路符号 library ieee; use ieeestd_logic_1164. all; Useieee. std _logicunsigned. all; entity sipo 1s port(ck, din, clr: in std_ logic, dout: out std_ logic_vector(4 downto O) end sipo;

带有同步清零的5位串入/并出 移位寄存器的电路符号 sipo clk dout[4…0] clr clk –时钟 clr – 清零端 dout[4…0] – 数据输出端 din din- 数据输入端 library ieee; use ieee.std_logic_1164.all; Use ieee.std_logic_unsigned.all; entity sipo is port(clk, din, clr: in std_logic; dout: out std_logic_vector(4 downto 0)); end sipo; ⚫文本输入法

rchitecture one of sipo is signal g: std_ logic_vector(5 downto 0 B g process(clk) if clk’ event andclk=‘1’then if 1 then g<=000000 elsif g(5=‘0then-设置q(5为标志位,当q(5=0时移位结束 q<=11110&din; else q<=q 4 downto O)&din; end if: endif: process; process( be In if q 5)="0 the dout<=q(4 downto O) else dout<=“ZZZ”;-移位过程中输出设置为高阻 endif: process; d

architecture one of sipo is signal q: std_logic_vector(5 downto 0); Begin process (clk) begin if clk’event and clk=‘1’ then if clr=‘1’ then q<=“000000”; elsif q(5)=‘0’then --设置q(5)为标志位,当q(5)=0时移位结束 q<=“11110”&din; else q<=q(4 downto 0)&din; end if; end if; end process; process(q) begin if q(5)=‘0’ then dout<=q(4 downto 0); else dout<=“ZZZZZ”; --移位过程中输出设置为高阻 end if; end process; end one;

例:并入/串出移位寄存器 输入端口为并行输入,而输出的数据在时钟边沿的作用下由输出端口逐个输出 ●文本输入法 pISo clkx-时钟 clk dout clr-清零端 din[3-0 din[3…0-数据输入端 dout-数据输出端 cIt 带有异步清零的4位并入串出 移位寄存器的电路符号 library ieee; use ieee std logic 1164.all use ieee std _logic_unsigned. all; entity piso 1s port(ckk, clr: in std_logic; din: in std_logic_vector( 3 downto O); dout out std _logic) end piso;

例:并入/串出移位寄存器 输入端口为并行输入,而输出的数据在时钟边沿的作用下由输出端口逐个输出 带有异步清零的4位并入/串出 移位寄存器的电路符号 piso clk dout clr clk –时钟 clr – 清零端 dout – 数据输出端 din[3…0] din[3…0]- 数据输入端 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity piso is port(clk, clr: in std_logic; din: in std_logic_vector(3 downto 0); dout: out std_logic); end piso; ⚫文本输入法

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共24页,试读已结束,阅读完整版请下载
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有