第一次上機安排_第1頁
已閱讀1頁,還剩43頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、第一次上機安排,第六周 周一晚(提高1、2,通信001~012)周二上(通信014~085)周四上(通信086~154)周四下(通信250~282,電信001~043)周五晚(電信044~125)第七周 周一下(電信125~216)周二上(電信217~302)周二下(電信302~385),VHDL硬件描述語言基礎,簡介基本結構基本數據類型設計組合電路設計時序電路設計狀態(tài)機大規(guī)模電路的層次化設計Functi

2、on and Procedure,簡介--背景,傳統(tǒng)數字電路設計方法不適合設計大規(guī)模的系統(tǒng)。工程師不容易理解原理圖設計的功能。眾多軟件公司開發(fā)研制了具有自己特色的電路硬件描述語言(Hardware Description Language,HDL),存在著很大的差異,工程師一旦選用某種硬件描述語言作為輸入工具,就被束縛在這個硬件設計環(huán)境之中。因此,硬件設計工程師需要一種強大的、標準化的硬件描述語言,作為可相互交流的設計環(huán)境。,簡介--

3、背景,美國國防部在80年代初提出了VHSIC(Very High Speed Integrated Circuit)計劃,其目標之一是為下一代集成電路的生產,實現階段性的工藝極限以及完成10萬門級以上的設計,建立一項新的描述方法。1981年提出了一種新的HDL,稱之為VHSIC Hardware Description Language,簡稱為VHDL,這種語言的成就有兩個方面:描述復雜的數字電路系統(tǒng)成為國際的硬件描述語言標準,VH

4、DL的優(yōu)點,用于設計復雜的、多層次的設計。支持設計庫和設計的重復使用與硬件獨立,一個設計可用于不同的硬件結構,而且設計時不必了解過多的硬件細節(jié)。有豐富的軟件支持VHDL的綜合和仿真,從而能在設計階段就能發(fā)現設計中的Bug,縮短設計時間,降低成本。更方便地向ASIC過渡VHDL有良好的可讀性,容易理解。,VHDL與計算機語言的區(qū)別,運行的基礎計算機語言是在CPU+RAM構建的平臺上運行VHDL設計的結果是由具體的邏輯、觸發(fā)器組

5、成的數字電路執(zhí)行方式計算機語言基本上以串行的方式執(zhí)行VHDL在總體上是以并行方式工作驗證方式計算機語言主要關注于變量值的變化VHDL要實現嚴格的時序邏輯關系,--eqcomp4 is a four bit equality comparatorLibrary IEEE;use IEEE.std_logic_1164.all;entity eqcomp4 isport(a, b:in std_logic_vector

6、(3 downto 0); equal :out std_logic);end eqcomp4;architecture dataflow of eqcomp4 isbegin equal <= ‘1’ when a=b else ‘0’;End dataflow;,VHDL 大小寫不敏感,eqcomp4.vhd,包,,實體,,構造體,,文件名和實體名一致,,,每行;結尾,,關鍵字begi

7、n,關鍵字end后跟實體名,關鍵字end后跟構造體名,,,,庫,,實體(Entity),描述此設計功能輸入輸出端口(Port)在層次化設計時,Port為模塊之間的接口在芯片級,則代表具體芯片的管腳,,,,A[3..0],B[3..0],,equal,Entity eqcomp4 isport(a, b: in std_logic_vector(3 downto 0); equal:out std_logic

8、 );end eqcomp4;,實體--端口的模式,輸入(Input)輸出(Output)雙向(Inout):可代替所有其他模式,但降低了程序的可讀性,一般用于與CPU的數據總線接口緩沖(Buffer):與Output類似,但允許該管腳名作為一些邏輯的輸入信號,Out與Buffer的區(qū)別,Entity test1 is port(a: in std_logic; b,c: out s

9、td_logic ); end test1; architecture a of test1 is begin b <= not(a); c <= b;--Error end a;,Entity test2 is port(a: in std_logic; b : buffer std_logic

10、; c: out std_logic ); end test2; architecture a of test2 is begin b <= not(a); c <= b; end a;,結構體(Architecture),描述實體的行為結構體有三種描述方式行為描述(behavioral)數據流描述

11、(dataflow)結構化描述(structural),結構體--行為描述,Architecture behavioral of eqcomp4 is begincomp: process (a,b) beginif a=b then equal <= ‘1’; else equal <=‘0’;end if; end process comp;end be

12、havioral ;,高層次的功能描述,不必考慮在電路中到底是怎樣實現的。,結構體--數據流描述描述輸入信號經過怎樣的變換得到輸出信號,Architecture dataflow1 of eqcomp4 is begin equal <= ‘1’ when a=b else ‘0’;end dataflow1;,Architecture dataflow2 of eqcomp4 is beginequal <

13、;= not(a(0) xor b(0)) and not(a(1) xor b(1)) and not(a(2) xor b(2)) and not(a(3) xor b(3));end dataflow2;,當a和b的寬度發(fā)生變化時,需要修改設計,當寬度過大時,設計非常繁瑣,結構體--結構化描述,archi

14、tecture struct of eqcomp4 isbegin U0:xnor2 port map(a(0),b(0),x(0)); U1:xnor2 port map(a(1),b(1),x(1)); U2:xnor2 port map(a(2),b(2),x(2)); U3:xnor2 port map(a(3),b(3),x(3)); U4:and4 port map(x(0),x(

15、1),x(2),x(3),equal);end struct;,類似于電路的網絡表,將各個器件通過語言的形式進行連接,與電路有一一對應的關系。一般用于大規(guī)模電路的層次化設計時。,三種描述方式的比較,VHDL標識符(Identifiers),基本標識符由字母、數字和下劃線組成第一個字符必須是字母最后一個字符不能是下劃線不允許連續(xù)2個下劃線保留字(關鍵字)不能用于標識符大小寫是等效的,VHDL數據對象(Data Objects

16、),常數(Constant)固定值,不能在程序中被改變增強程序的可讀性,便于修改程序在綜合后,連接到電源和地可在Library、Entity、Architecture、Process中進行定義,其有效范圍也相應限定Constant data_bus_width: integer := 8;,VHDL數據對象(Data Objects),信號(Signals)代表連線,Port也是一種信號沒有方向性,可給它賦值,也可當作輸入

17、在Entity中和Architecture中定義設定的初始值在綜合時沒有用,只是在仿真時在開始設定一個起始值。在Max+PlusII中被忽略。用 <= 進行賦值signal count:bit_vector(3 downto 0):=“0011”;,VHDL數據對象(Data Objects),變量(Variable)臨時數據,沒有物理意義只能在Process和Function中定義,并只在其內部有效要使其

18、全局有效,先轉換為Signal。用 := 進行賦值 variable result : std_logic := ‘0’;,信號與變量的區(qū)別,architecture rtl of start is signal count : integer range 0 to 7; begin process(clk) begin if (clk'event and clk='1&

19、#39;) then count <= count + 1; if(count=0) then carryout <= '1'; else carryout <= '0'; end if; end if; end proces

20、s; end rtl;,architecture rtl of start is begin process(clk)variable count : integer range 0 to 7;begin if (clk'event and clk='1') then count := count + 1; if(count=0) then

21、 carryout <= '1'; else carryout <= '0'; end if; end if; end process; end rtl;,信號與變量的區(qū)別,architecture a of start is signal tmp : std_logi

22、c;begin process(a_bus)begin tmp <= '1'; for i in 3 downto 0 loop tmp <= a_bus(i) and tmp; end loop; carryout <= tmp; end process;end a;,architecture a of start is beg

23、in process(a_bus) variable tmp:std_logic; begin tmp := '1'; for i in 3 downto 0 loop tmp := a_bus(i) and tmp; end loop; carryout <= tmp; end process;en

24、d a;,VHDL數據類型,標量類型(Scalar)枚舉(Enumeration)整數(Integer)浮點數(Float)物理(Physical)復合類型(Composite),VHDL數據類型--枚舉,列舉數據對象可能存在的值,一般用于定義狀態(tài)機的狀態(tài)Type states is (idle, start, running, pause, stop)Signal current_state : states;IEEE

25、1076標準中預定義了兩個枚舉類型Type boolean is (False, True)Type bit is (‘0’, ‘1’) Signal a : bit;,VHDL數據類型--枚舉,IEEE1164標準中預定義了一個枚舉類型Type std_logic is(‘U’, ‘X’,‘0’, ‘1’, ‘Z’, ‘W’, ‘L’, ‘H’, ‘-’);該

26、類型能比較全面地包括數字電路中信號會出現的幾種狀態(tài),因此一般情況把這種類型代替bitSignal a : std_logic;注意:這里的大小寫是敏感的,VHDL數據類型,整數、浮點數方便用于數值方面的運算:加減乘除整數范圍:-231 ~231 –1,經常用于計數器實數范圍:-1.0E38~+1.0E38,不被Max+PLusII支持Variable a : integer range –255 to +255;物理類

27、型主要用于調試,VHDL數據類型--復合類型,Array Types多個相同類型成員組成的隊列,一般用于定義數據總線、地址總線等。Signal a: std_logic_vector(7 downto 0);a <= B“00111010”; a <= X “3A”; 可自定義復合類型Type word is array (15 downto 0) of bit;Signal b : word;

28、Type table8x4 is array (0 to 7, 0 to 3) of bit;,VHDL數據類型--復合類型,Record Types相同或不同類型的元素組成,類似C中的結構具有模型抽象能力,用于描述一個功能模塊Type iocell is record Enable :bit; DataBus :bit_vector(7 downto 0); end record;

29、singal bus : iocell; bus.Enable <= ‘1’; bus.DataBus <= “00110110”;,VHDL數據類型及子類型Types And Subtypes,VHDL是強類型語言,必須用類型轉換函數才能進行不同類型之間的轉換type byte_size is integer range 0 to 255;signal a : byte_size;signal b :

30、integer range 0 to 255;if a=b then ……采用以下方式 subtype byte_size is integer range 0 to 255;,屬性(Attributes),提供Entity、Architecture、Type和Signals的信息。有許多預定義的值、信號和范圍的屬性一個最常用的屬性是’eventif clk’event and clk=‘1’ then’left,’

31、right, ’high, ’low,’lengthtype count is integer range 0 to 127count’left = 0; count’right = 127;count’high = 127; count’low = 0;count’length = 128;,VHDL運算符,邏輯運算符AND、OR、NAND、NOR、XOR、NOT關系運算符=、/=、、=算術運算符+、-、*、/并置

32、(連接)運算符&,組合電路--并行語句(Concurrent),并行語句位于Process外面,同時執(zhí)行,不分位置的先后順序并行語句包括:布爾等式: <=With-select-whenWhen-else布爾等式 A <= s(0) and s(1); B <= not(y);,組合電路--并行語句,With-select-when語句 With Sel_signal sele

33、ct Signal_name <= a when Sel_signal_1, b when Sel_signal_2, c when Sel_signal_3,… x when Sel_signal_x;,Signal s : std_log

34、ic_vector(1 downto 0);Signal a,b,c,d,x : std_logic;With s select x <= a when “00”, b when “01”, c when “10”, d when others;,組合電路--并行語句,When-else語句 Signal_name <= a w

35、hen condition1 else b when condition2 else c when condition3 else … x ;,x <= a when s=“00” else b when s=“01” else

36、 c when s=“10” else d;,Signal a,b,c,d:std_logic;Signal w,x,y,z:std_logic;x <= w when a=‘1’ else x when b=‘1’ else y when c=‘1’ else z when d=‘1’ else ‘0’;,組合電路--

37、并行語句,實現優(yōu)先級編碼器 encode <= “111” when D(7) = ‘1’ else “110” when D(6) = ‘1’ else “101” when D(5) = ‘1’ else “100” when D(4) = ‘1’ else

38、 “011” when D(3) = ‘1’ else “010” when D(2) = ‘1’ else “001” when D(1) = ‘1’ else “000” when D(0) = ‘1’ else “000”;,組合

39、電路--并行語句,When-else語句條件語句可以是一個簡單的表達式With-select-when則不能采用表達式作為條件 a <= “0000” when state=idle and state=‘1’ else “0001” when state=idle and state=‘0’ else b when state=running and state=‘1’ else

40、 a;,組合電路--順序語句(Sequential),Process,Function,Procedure中的語句都是順序執(zhí)行,以Process為例Process與Process之間,與其他并行語句之間都是并行的關系If-then-elseCase-when,組合電路--順序語句,If-then-elseIf(condition1) then do something; elsif(condition2)

41、then … else do something different; end if;,,組合電路--順序語句,Process(addr)Begin step <= ‘0’; if(addr = X “F”) then step <= ‘1’; end if;End process;,Process(addr)Begin if(addr = X

42、 “F”) then step <= ‘1’; else step <= ‘0’; end if;End process;,Process(addr)Begin if(addr = X “F”) then step <= ‘1’; end if;End process;,Step <= addr(3) *

43、addr(2) * Addr(1) * addr(0) + step,組合電路--順序語句,用于作地址譯碼InRam = X “0000” and addr = X “4000” and addr = X “4008” and addr = X “8000” and addr = X “C000” then EEPRom <= ‘1’; end if;,組合電路--順序語句,Case-when

44、case sel_signal is when value_1 => (do sth) when value_2 => (do sth) … when value_last => (do sth) end case;,組合電路--順序語句,實現數碼

45、管譯碼器Process(address) begin case address is when “0000” => decode decode decode decode decode <= X “00”; end case; end process;,幾種語句的比較,同步時序邏輯電路,Process(clk)begin

46、 if(clk’event and clk=‘1’) then q <= d; end if;end process;,Process(clk)begin if(clk=‘1’) then q <= d; end if;end process;,D觸發(fā)器,緩沖器,實現T觸發(fā)器,Process(clk)begin if(clk’event

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論