Chinaunix首页 | 论坛 | 博客
  • 博客访问: 484009
  • 博文数量: 104
  • 博客积分: 3045
  • 博客等级: 少校
  • 技术积分: 1230
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-29 10:18
文章分类

全部博文(104)

文章存档

2011年(72)

2010年(1)

2009年(1)

2008年(30)

分类:

2008-09-30 20:57:11

library ieee;
use ieee.std_logic_1164.all;
entity mux2 is
 port(a,b,s: in std_logic;
   y : out std_logic);
end mux2;
architecture one of mux2 is
 begin
 process(s,a,b)
 begin
  if s='0' then y<=a;
  else y<=b;
  end if;
 end process;
end one ;
 
********************************************************************
library ieee;
use ieee.std_logic_1164.all;
package my_pkg is 
元件体外配置 
component mux2
 port(a,b,s: in std_logic;
   y: out std_logic);
 end component;
 
过程调用语句
 procedure diff(signal d:bit_vector(7 downto 0);
     signal clk: bit;
     signal q; out bit_vector(7 downto 0));
 
 begin
 wait until clk='1';
 q<=d;
 end diff;
 
子函数声明
 FUNCTION odd_par8(di: std_logic_vector(7 downto 0))
   return std_logic is
   variable temp: std_logic;
   begin
    temp:='0';
    for k in 7 downto 0 loop
     temp := di(k) xor temp;
    end loop;
   return temp;
 end odd_par8;
  
end my_pkg;
**********************************************************************
如果调用my_pkg  只需要use work.my_pkg.all就可以调用自己声明的各种函数或变量等。
阅读(1250) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~