版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、AHDL訓(xùn)練教程,哈爾濱工業(yè)大學(xué)威海校區(qū) 戴伏生,什么是 AHDL,Altera Hardware Description Language 由 Altera公司開(kāi)發(fā) 集成到Altera的軟件 Max+Plus II 用語(yǔ)言描述硬件來(lái)代替圖形 修改更容易 易于維護(hù) 非常適合于 復(fù)雜的組合邏輯 BCD 到 7段轉(zhuǎn)換 地址解碼 狀態(tài)機(jī) 其他你想要的.,繼續(xù).,就象圖形輸入一樣容易 強(qiáng)有力的HDL (硬件描述語(yǔ)言) VHDL, Verilog HDL 等等.,怎樣用ADHL,用任何文本編輯器建立這個(gè)文件 Altera 軟件 Max+Plus II 提供文本編輯器,輸入你的 AHDL 設(shè)計(jì)文件,繼續(xù).
2、,用 name.TDF保存你的ADHL文件,繼續(xù).,編譯期間的錯(cuò)誤定位,方便的錯(cuò)誤定位,通常的AHDL格式,SUBDESIGN decode1 ( input_pin_name : INPUT; input_bus_name15.0 : INPUT; output_pin_name : OUTPUT; output_bus_name : OUTPUT; ) BEGIN ouptut_pin_name = input_pin_name; output_bus_name = input_bus_name; END;,關(guān)鍵字,定義I/O口,邏輯,AHDL 格式,你的第一個(gè)AHDL設(shè)計(jì) 地址解碼器,C
3、hip_enable = a0 chip_enable : output; ) begin chip_enable = (a3.0 = H7); end;,為什么我用AHDL代替圖形,容易編輯 Document during the coding 我想解碼 H”A” 不是 H”7”,SUBDESIGN decode1 ( a3.0 : input; chip_enable : output; ) begin chip_enable = (a3.0 = HA); end;,Self Explain the Function,唯一的改動(dòng),需要更多的工作去修改,Chip_enable = !a0 c
4、hip_enable : output; ) begin chip_enable = (a3.0 = B1x0 x); end;,一些無(wú)關(guān)位寫(xiě)X忽略,需要你知道的一些事情,加 : + 減 : - 數(shù)字恒等 : = 不等于 : != 大于 : 大于或等于 : = 小于 : 小于或等于 : = 邏輯或 : # 邏輯與 : SUBDESIGN decode1 ( a3.0 : input; chip_enable : output; ) begin chip_enable = (a3.0 = IO_ADDRESS); if (a3.0 = IO_ADDRESS) then . end;,在 SUBD
5、ESIGN 關(guān)鍵字之前定義 CONSTANT,實(shí)現(xiàn)組合邏輯,out1 = a0 out3.0 : output; ) begin out0 = a0 ,總線操作的更多內(nèi)容,總線操作 a9.0, b9.0 a = b; a7.4 = b9.6; a9.8 = VCC; a9.8 = 1; a9.8 = 2; a9.8 = 3; a3.0 = GND a3.0 = 0; temp = b0 a2.1 = temp,a7=b9, a6=b8, a5=b7, a4=b6,a9.8 connect to VCC,a9.8 = B”01”,a9.8 = B”10”,a9.8 = B”11”,a3.0 co
6、nnect to GND,a3.0 = B”0000”,a2 = temp, a1 = temp,高級(jí)總線操作,總線Bus b3.0 b3, b2, b1, b0 (有四個(gè)成員) MSB 是 b3, LSB 是b0 陣列ARRAY BUS a3.02.0 a3_2, a3_1, a3_0, a2_2, a2_1, a2_0, a1_2, a1_1, a1_0, a0_2, a0_1, a0_0 (有12個(gè)成員) MSB 是 a3_2, LSB 是 a0_0,真值表,i3.0 Segment 7 0 0 1 1 2 2 F F,做任何改動(dòng)都很容易,IF-THEN-ELSE,SUBDESIGN p
7、riority ( low, medium, high : input; highest_level3.0 : output; ) begin if ( high = B”1”) then highest_level = B”1000”; elsif (medium = B”1”) then highest_level = B”0100”; elsif (low = B”1”) then highest_level = B”0010”; else highest_level = B”0001”; end if; end;,需要 4 LCELL,CASE 段,SUBDESIGN decoder
8、(low, medium, high : input; highest_level3.0 : output; ) variable code2.0 : node; begin code2=high; code1=medium; code0=low; case code is when 4 = highest_level = B”1000”; when 2 = highest_level = B”0100”; when 1 = highest_level = B”0010”; when others = highest_level = B”0001”; end case; end;,這個(gè)段落怎么
9、用,For 循環(huán),CONSTANT num_of_bit = 8; SUBDESIGN numbit ( anum_of_bit.0 : input; bnum_of_bit.0 : output; ) begin b8 = a0; b7 = a1; b6 = a2; b5 = a3; b4 = a4; b3 = a5; b2 = a6; c1 = a7; b0 = a8; end;,寄存器邏輯,SUBDESIGN flip_flop ( d, clk : input; q : output;) begin q = dff(d,clk, ,); end;,更多的細(xì)節(jié),寄存器的更多內(nèi)容,怎樣和寄
10、存器一起使用總線 怎樣使用其他觸發(fā)器 DFFE (D-FF帶使能端) TFF/TFFE JKFF/JKFFE SRFF/SRFFE,寄存器總線,SUBDESIGN bus_reg ( clk, d7.0 : input; q7.0 : output; ) variable ff7.0 : dff; begin ff.clk = clk; ff.d = d; q = ff.q; end;,D觸發(fā)器帶使能Enable/重設(shè)Preset/清除Clear,SUBDESIGN flip_flop_enable ( clock, data, enable, preset, clear : input; q
11、out : output; ) variable temp : dffe; begin temp.d = data; temp.clk = clock; temp.clrn = clear; temp.prn = preset; temp.ena = enable; qout = temp.q; end;,D,CLK,CLRN,PRN,ENA,Q,其他類(lèi)型的觸發(fā)器,如何用幫助菜單,Q : 我不知道Altera DFF/JKFFE, 怎么辦? A : Altera幫助菜單是查找信息的好地方。 Q : 我怎樣用幫助菜單? A :這個(gè)很容易 很有趣。,DFFE,怎樣用幫助菜單,三態(tài)緩沖器,SUBDE
12、SIGN tri_state (a, enable : input; b : output;) begin b = tri(a, enable); end;,SUBDESIGN tri_state ( a, enable : input; b : output;) variable temp : tri; begin temp.in = a; temp.oe = enable; b = temp.out; end;,更多的細(xì)節(jié),OPNDRN - Open Drain Buffer,SUBDESIGN opn_drn (enable : input; b : output;) begin b =
13、 opndrn(enable); end;,SUBDESIGN tri_state ( enable : input; b : output;) variable temp : opndrn; begin temp.in= enable; b = temp.out; end;,更多的細(xì)節(jié),用AHDL 有示范性但是用AHDL 更有力,訓(xùn)練,AHDL,input,bidir,clk, enable : input; io : bidir;,設(shè)計(jì)8 位計(jì)數(shù)器很容易,SUBDESIGN 8bits (clk : input; q7.0 : output; ) variable temp7.0 : df
14、f; begin temp.clk = clk; temp.d = temp.q +1 ; q = temp.q; end;,狀態(tài)機(jī),SUBDESIGN simple ( clk, reset, jump : input; q : output; ) variable ss : MACHINE WITH STATES (S0,S1); begin ss.clk = clk; ss.reset = reset; case ss is when s0 = q = gnd; if (jump) then ss = s1; end if; when s1 = q = vcc; if (jump) th
15、en ss = s0; end if; end case; end;,狀態(tài)機(jī)圖表,注意:所有的狀態(tài)機(jī)的變量都必須 和時(shí)鐘關(guān)聯(lián)。,jump=1,jump=1,q = 0,q = 1,jump=0,jump=0,關(guān)于狀態(tài)機(jī)更多內(nèi)容,SUBDESIGN stepper ( reset, ccw, cw, clk : input; phase3.0 : output;) variable ss : MACHINE OF BITS (temp3.0) WITH STATES ( s0 = B”0001”, s1 = B”0010”, s2 = B”0100”, s3 = B”1000”); begin
16、ss.clk = clk; if (reset) then ss = s2; end if; phase = temp;,TABLE ss, ccw, cw = ss; s0, 1, x = s3; s0, x, 1 = s1; s1, 1, x = s0; s1, x, 1 = s2; s2, 1, x = s1; s2, x, 1 = s3; s3, 1, x = s2; s3, x, 1 = s0; END TABLE; end;,注意:不需要聲明什么是TEMP, 它作為DFF被自動(dòng)聲明。,用戶可以控制這些狀態(tài)位。,訓(xùn)練,SUBDESIGN stepper ( reset, ccw, c
17、w, clk : input; phase3.0 : output;) variable ss : MACHINE OF BITS (temp3.0) WITH STATES ( s0 = B”0001”, s1 = B”0010”, s2 = B”0100”, s3 = B”1000”); begin ss.clk = clk; if (reset) then ss = s2; end if; phase = temp;,TABLE ss, ccw, cw = ss; s0, 1, x = s3; s0, x, 1 = s1; s1, 1, x = s0; s1, x, 1 = s2; s2
18、, 1, x = s1; s2, x, 1 = s3; s3, 1, x = s2; s3, x, 1 = s0; END TABLE; end;,你可以到CASE段編輯真值表,狀態(tài)機(jī)沒(méi)有恢復(fù)態(tài),SUBDESIGN recover ( clk, go : input; ok : output;) variable sequence : MACHINE OF BITS (q2.0) with STATES ( idle, one, two, three, four, illegal1, illegal2, illegal3); begin sequence.clk = clk; case sequence is when idle = if (go) then sequence = one; end if; when one = sequence = two; when two = sequence = three; when three = sequence = four; end case; ok = (sequence = four); end;
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030全球鍍銅光亮劑行業(yè)調(diào)研及趨勢(shì)分析報(bào)告
- 2025年全球及中國(guó)母嬰健康產(chǎn)后護(hù)理行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 2025年全球及中國(guó)敏捷滲透測(cè)試行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 2025年全球及中國(guó)LTCC用導(dǎo)電銀漿行業(yè)頭部企業(yè)市場(chǎng)占有率及排名調(diào)研報(bào)告
- 2025建筑安裝工程承包合同范本版
- 教室租賃合同范本
- 2025工礦企業(yè)大型成套設(shè)備采購(gòu)合同范本
- 裝修設(shè)計(jì)合同范本大全
- 2025勞動(dòng)合同試用期法律疑難問(wèn)題詳解
- 門(mén)店合伙協(xié)議合同范本
- 2024年1月高考適應(yīng)性測(cè)試“九省聯(lián)考”數(shù)學(xué) 試題(學(xué)生版+解析版)
- JT-T-1004.1-2015城市軌道交通行車(chē)調(diào)度員技能和素質(zhì)要求第1部分:地鐵輕軌和單軌
- (高清版)WST 408-2024 定量檢驗(yàn)程序分析性能驗(yàn)證指南
- (正式版)JBT 11270-2024 立體倉(cāng)庫(kù)組合式鋼結(jié)構(gòu)貨架技術(shù)規(guī)范
- DB11∕T 2035-2022 供暖民用建筑室溫?zé)o線采集系統(tǒng)技術(shù)要求
- 《復(fù)旦大學(xué)》課件
- 針灸與按摩綜合療法
- Photoshop 2022從入門(mén)到精通
- T-GDWJ 013-2022 廣東省健康醫(yī)療數(shù)據(jù)安全分類(lèi)分級(jí)管理技術(shù)規(guī)范
- 校本課程生活中的化學(xué)
- DB43-T 2775-2023 花櫚木播種育苗技術(shù)規(guī)程
評(píng)論
0/150
提交評(píng)論