1、EDA 123 4 51.Function VALUE)(AND OR NOT)2.2.1 1 2 3 4 FUNCTION RETURN FUNCTION RETURN IS BEGIN;RETURN END FUNCTION;-,52.2.2 PACKAGE BODY packexp ISFUNCTION max-(a,b:IN STD_LOGIC_VECTOR)RETURN STD_LOGIC_VECTOR ISBEGINIF a b THEN RETURN a;ELSE RETURN b;END IF;END FUNCTION max;-FUNCTION END;-PACKAGE BO
2、DYLIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;PACKAGE packexp IS-FUNCTION max-(a,b:IN STD_LOGIC_VECTOR)RETURN STD_LOGIC_VECTOR;-FUNCTION*(a,b:INTEGER)RETURN INTEGER;END;-2.2.2(ARCHITECTURE demo OF func ISFUNCTION sam(x,y,z:STD_LOGIC)RETURN STD_LOGIC IS-在结构体说明部分定义函数功能BEGINRETURN(x AND y)OR;END FUNCTION
3、sam;BEGIN-结构体描述部分开始PROCESS(a)BEGINm(0)=sam(a(0),a(1),a(2);m(1)=sam(a(2),a(0),a(1);m(2)=sam(a(1),a(2),a(0);END PROCESS;END ARCHITECTURE demo;LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY func ISPORT(a:IN STD_LOGIC_VECTOR(0 to 2);m:OUT STD_LOGIC_VECTOR(0 to 2));END ENTITY func;3.1 VHDL 2 3.3ARCHITEC
4、TURE bhv OF axamp IS BEGINout1=max(dat1,dat2);-并行函数调用PROCESS(dat3,dat4)BEGINout2=max(dat3,dat4);-顺序函数调用END PROCESS;END;LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE WORK.packexp.ALL;-要调用某函数需打开定义该-函数的程序包ENTITY axamp ISPORT(dat1,dat2:IN STD_LOGIC_VECTOR(3 DOWNTO 0);dat3,dat4:IN STD_LOGIC_VECTOR(3 DOWNTO 0);out1,out2:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);END;4.4.1 RELOAD 4.2 4.4.2 5.VHDL