久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 8052|回復: 0
打印 上一主題 下一主題
收起左側

用wait until 用法和子程序的編輯與調用

[復制鏈接]
跳轉到指定樓層
樓主
ID:51090 發表于 2014-9-29 17:09 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
1.--VHDL中,wait until clk='1' 可代clk'event and clk='1'做上升沿,
--wait until clk='0' 可代clk'event and clk='1'做下降沿。用法如下:
--74hc161功能芯片的VHDL程序:
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity d_ff is
Port(clk,cr,ld:in std_logic;
     d:in std_logic_vector(3 downto 0);
      q:out std_logic_vector(3 downto 0));
end;
architecture dd of d_ff is
signal s,ss:std_logic_vector(3 downto 0);
begin
  process
   begin  
  
    wait until clk='1';    --這句意思是等待到clk等于1時完成下面語句
       if ld='0' then s<=d;
         else s<=s+1 ;
       end if;
    if cr='0' then
      s<="0000";
    end if;
  end process
;
  q<=s;
end dd;
2--子程序也是很多編程語言中常用的程序模塊,VHDL子程序用法如下:
  1)---------------子程序function的用法--------
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity full_adder is
Port(a,b,cin:in std_logic;
     sum,co:out std_logic);      
end;
architecture add of full_adder  is
Function sam1(x,y:std_logic)return std_logic is   --子程序1,sam1為程序名
   begin                           --x,y為子程序變量,冒號后面是變量類型
   return (x xor y);          --子程序返回值
  end sam1;  --結束子程序1
  function sam2(x,y:std_logic)return std_logic is    --子程序2
   begin
   return (x and y);
  end sam2;   --結束子程序1
signal s1,co1,s2,co2,ss:std_logic;
begin
  process(a,b,cin)
   begin   
     s1<=sam1(a,b);   --調用子程序1
     co1<=sam2(a,b); --調用子程序2
     s2<=sam1(s1,cin);
     co2<=sam2(s1,cin);   
   end process;  
   sum<=s2;
   co<=co1 or co2;  
end dd;
  2)---------------子程序Procedure的用法---------
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity d_ff is

Port(a,b,cin:in std_logic;
     sum,co:out std_logic);      
end;
architecture dd of d_ff is

---------------------------------------
Procedure sam(x,y:in std_logic;
                z,w: out std_logic) is   --這個子程序用法變量必須設置方向
   begin
   z:=x xor y;  --賦值必須采用變量Veriable格式:=
   w:=x and y;
   end sam;
begin
  process(a,b,cin)
  variable s1,s2,co1,co2:std_logic;--運行過程中需要的話,必須使用局部變量,在Process后設置。
   begin
   sam(a,b,s1,co1);
   sam(cin,s1,s2,co2);
    sum<=s2;
   co<=co1 or co2;      
   end process;      
end dd;
3.程序塊Block的編輯與使用
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY ppp IS
PORT(a,b,c,D,clk: IN STD_LOGIC;
     y,s,co,Q: OUT STD_LOGIC);
END ppp;
ARCHITECTURE Behave OF ppp IS
signal tmp1,tmp2,tmp3,tmp4,s1,c1,s2,c2:STD_LOGIC;
BEGIN
g1:BLOCK
BEGIN
process(clk)
begin
tmp1 <= a and b;
tmp2<= a and (b or (not c));
tmp3<=c xor(not( a and b));
if clk'event and clk='1' then
y<=tmp3 or (tmp2 and tmp1);
end if;
end process;
END BLOCK g1;
g2:block
begin
   s1<= a xor b;
   c1<= a and b;
   s<=s1 xor c;
   c2<=s1 and c;
   co<=c1 or c2;
end block g2;
G3:block
  begin
   process(D,clk)
    begin
    if clk'event and clk='1' then
      Q<=D;
    end if;
    end process;
  end block g3;
END Behave;
4. for  i  in  0 to 7  loop 語句
------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity fulladder is
Port(D:in std_logic_vector(7 downto 0);
     clk:in std_logic;
     Q:out std_logic_vector(7 downto 0));
end;
architecture add of fulladder is
begin
process(D,clk)
begin
for i in 0 to 7 loop
   if clk'event and clk='1' then
   q(i)<=d(i);
   end if;
end loop;
end process;
end;
-------------------------------------------------------------------
5.quartusII11.0程序綜合通過后要生成圖像按下圖操作

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲国产欧美在线人成 | 国产精品成人在线播放 | 欧美日韩第一页 | 国产精品亚洲成在人线 | 黄色网址在线免费播放 | 一区二区国产精品 | 日韩成人免费视频 | 欧美日韩在线一区二区 | 久久成人激情 | 国产色黄 | 免费看91| www.亚洲成人网 | 黑人巨大精品 | 欧美电影免费观看高清 | 国产亚洲成av人在线观看导航 | jlzzjlzz欧美大全 | 男女视频91 | 综合色播| 99久久婷婷国产综合精品电影 | 成人av免费播放 | 成人免费网站视频 | 国产高清视频在线播放 | 欧美日韩亚洲一区 | 精品成人在线视频 | 一道本不卡视频 | 欧美另类日韩 | 热久久久久 | 国产精品久久久久久亚洲调教 | 精品成人一区二区 | 一区二区三区四区视频 | 欧美九九九 | 区一区二在线观看 | 在线免费毛片 | 国产精品高潮呻吟久久 | 欧美午夜精品久久久久久浪潮 | 伊人超碰 | 中文字幕免费 | av网站在线免费观看 | 日日操日日舔 | 欧美1区2区| www.成人.com |