




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、 9. Introduction to VHDL 9.1 A simple example in VHDL 9.2 Stylistic issues 9.3 The IEEE library 9.4 Conditionals in VHDL 9.5 Handling multi-bit signals 1 9.1 A simple example in VHDL1. EntityWe will start off with a NAND gate. The first thing is to say what the device looks like to the outside world
2、. This basically means describing its port map, i.e. the signals that flow in and out of it. 2 9.1 A simple example in VHDLTo describe this in VHDL, we use an entity declaration. ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC ); END;Each of the signals in the port map is declared as
3、having a mode and a type. The mode can be IN or OUT, and simply says whether the signal is an input or an output.3 9.1 A simple example in VHDLThe type STD_LOGIC represents a signal that bit can a value of 0, 1, X or U. STD_LOGIC is the normal way to describe logic signals that appear at the input o
4、r output of gates, or at wires in between them.X means unknownU means uninitialized, i.e. a signal that has not yet been assigned any valid logical value.4 9.1 A simple example in VHDL2. Architecture Now that we have described the inputs and outputs, we need to say what the device does, i.e. how its
5、 outputs respond to its inputs. ARCHITECTURE simple OF nandgate ISBEGIN c = a NAND b;END;The ARCHITECTURE statement says what goes on inside nandgate. 5 9.1 A simple example in VHDLAfter the ARCHITECTURE statement comes the word BEGIN. This introduces the main body of the architecture, which explain
6、s how the outputs relate to the inputs. At the end of the body comes the END statement, which says that we have reached the end of the body.How the outputs relate to the inputs is described by c = a NAND b;The symbol = means that the signal c gets the value of a NANDed together with the value of b.
7、Whenever a or b change their value, this statement causes the value of c to be updated. 6 9.1 A simple example in VHDLIf we want to check that our description is functioning correctly, we can feed it into a simulator, a program that predicts how the outputs would change in response to changes in the
8、 input. 7 9.1 A simple example in VHDL3. BEGIN and END statementsVHDL uses the keywords BEGIN and END to indicate the beginning and end of a block respectively. 4. SemicolonsVHDL uses the semicolon to indicate the end of a statement. 8 9.2 Stylistic issues1. CaseVHDL is not case sensitive. 2. Spaces
9、 and indents Any number of spaces can be used between words without affecting the meaning of the code. 3. Returns Putting in a carriage return makes no difference to the function of the code. 9 9.2 Stylistic issues4. Annotating END statementsIn a long description, in order to keep track, we can put
10、the name of what we intend to end after the END statement. ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC);END ENTITY nandgate;ARCHITECTURE simple OF nandgate ISBEGIN c = a NAND b;END ARCHITECTURE simple;10 9.2 Stylistic issues5. CommentsComments are text that we introduce into the V
11、HDL description in order to help a person reading to the code to understand what is happening. Comments are introduced by two dashes. Everything between the two dashes and the end of line is regarded as a comment.11 9.3 The IEEE library1. Opening libraries A large number of features and extensions t
12、o the capabilities of the VHDL language are bundled into a library called “IEEE”. The IEEE library is made available by the statement: LIBRARY IEEE;The IEEE library contains many sub-libraries, which in turn contain many features. VHDL sub-libraries are called packages. 12 9.3 The IEEE libraryIn ord
13、er to say which features of which packages we wish to access, we use :USE IEEE.XXXX.YYYYXXXX is the name of the required package YYYY is the name of the specific feature that is to be usedUSE IEEE.XXXX.ALL Often we simply make all features within a package visible by using the VHDL keyword ALL:13 9.
14、3 The IEEE library2. Using STD_LOGIC The standard logic definitions are held in a sub-library called std_logic_1164. The full listing for a NAND gate is: LIBRARY ieee;USE ieee.std_logic_1164.all;ENTITY nandgate IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC );END ENTITY nandgate;ARCHITECTURE simple
15、OF nandgate ISBEGIN c = a NAND b;END ARCHITECTURE simple;14 9.4 Conditionals in VHDLSometimes we want to assign a signal in a way that is conditional on something else happening. Exp1: This device is called equals. It has two inputs a and b and one output c. If the two inputs are equal then the outp
16、ut is 1. If the two inputs are unequal, then the output is 0.15 9.4 Conditionals in VHDLLIBRARY ieee;USE ieee.std_logic_1164.ALL;ENTITY equals IS PORT ( a, b: IN STD_LOGIC; c: OUT STD_LOGIC);END ENTITY equals;ARCHITECTURE number1 OF equals ISBEGIN c = 1 WHEN a=b ELSE 0;END ARCHITECTURE number1;The V
17、HDL description 16 9.5 Handling multi-bit signals1. STD_LOGIC_VECTORs STD_LOGIC_VECTOR can be thought as an array of STD_LOGIC signals. Exp2: Use VHDL to describe the quadruple 2-input OR gate. 17 9.5 Handling multi-bit signalsLIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY orgate IS PORT ( a, b: IN
18、 STD_LOGIC_VECTOR(0 TO 3); c: OUT STD_LOGIC_VECTOR(0 TO 3);END ENTITY orgate;ARCHITECTURE number OF orgate ISBEGIN c = a OR b;END ARCHITECTURE number;18 9.5 Handling multi-bit signals2. STD_LOGIC_VECTOR values The value of an STD_LOGIC is indicated by a 0, 1, X or U enclosed in single quotes. Assign
19、ment statement is: a = 1;The value of an STD_LOGIC_VECTOR is indicated by a string of values enclosed in double quotes. Assignment statement is:a = ”1110”;19 9.5 Handling multi-bit signals3. AggregatesAnother way to specify the value of a STD_LOGIC_VECTOR is to use an aggregate. An aggregate is a gr
20、oup values, separated by commas. a = ( 1,1,1,0); 20 9.5 Handling multi-bit signals(1) Positional assignmenta 1, 0 = 1, 3 = 0, 2 = 1);the 0th value listed goes in the 0th position, the first goes in the first position and so on. (2) Named association 21 9.5 Handling multi-bit signals4. Direction of n
21、umbering a: STD_LOGIC_VECTOR ( 0 TO 3) If a is declared as:As a result, the individual bit positions within a are numbered as 22 9.5 Handling multi-bit signals5. Arithmetic on STD_LOGIC_VECTORsExp3: It has two inputs, a and b, both of which represent four-bit binary numbers. There is a single one-bit output g, which represents the “greater than” condition. When ab then g=1; otherwise g=0. The way that
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 設(shè)施運(yùn)營績效評價(jià)體系構(gòu)建考核試卷
- 企業(yè)勞務(wù)派遣優(yōu)勢分析考核試卷
- 投資保護(hù)與東道國政策環(huán)境適應(yīng)性分析考核試卷
- 全球低碳經(jīng)濟(jì)政策協(xié)調(diào)與合作考核試卷
- 部編九年級語文月考試卷
- 2025年中國LED背鏡燈數(shù)據(jù)監(jiān)測研究報(bào)告
- 2025年中國CD片盒數(shù)據(jù)監(jiān)測報(bào)告
- 2025年中國2.4-二氯氯芐數(shù)據(jù)監(jiān)測報(bào)告
- 2025至2030年中國黃旗蟒市場分析及競爭策略研究報(bào)告
- 2025至2030年中國除草劑氟磺胺草醚原藥市場分析及競爭策略研究報(bào)告
- 社會(huì)責(zé)任工作管理制度
- 2024-2025學(xué)年廣東省新部編版七年級歷史第二學(xué)期期末模擬卷(含答案)
- 2025年新疆維吾爾自治區(qū)公務(wù)員錄用考試面試真題試卷:無領(lǐng)導(dǎo)小組討論邊疆穩(wěn)定與發(fā)展試題
- 2025年高考湖南卷物理真題(解析版)
- 七年級下冊地理知識點(diǎn)總結(jié)(考點(diǎn)清單)(背記版)七年級地理下學(xué)期期末復(fù)習(xí)(人教2024版)
- 2025至2030中國汽車物流行業(yè)深度發(fā)展研究與企業(yè)投資戰(zhàn)略規(guī)劃報(bào)告
- 2025年四川富潤招聘筆試沖刺題(帶答案解析)
- 公司物流內(nèi)部管理制度
- 公司資料部門管理制度
- 2025年數(shù)學(xué)中考專題復(fù)習(xí)課件:7.30 尺規(guī)作圖
- 人教部編版五年級下冊語文期末復(fù)習(xí)現(xiàn)代文閱讀(含課內(nèi)、課外)專項(xiàng)訓(xùn)練(三)(含答案)
評論
0/150
提交評論