Your First ahdl design - Address Decoder subdesign decode 1 (a3.0]: input chip enable: output; 嫩 egin chip enable=(a3.0]==H"7") Chip enable =a0 al a2 &!a3 Copyright 1997 Altera Corporation 2/22/2021P11 favara
Copyright © 1997 Altera Corporation 2/22/2021 P.11 Your First AHDL design -- Address Decoder Chip_enable = a0 & a1 & a2 & !a3 SUBDESIGN decode1 ( a[3..0] : input; chip_enable : output; ) begin chip_enable = (a[3..0] == H"7"); end;
Why I use AHDL instead of Graphic ■ Easy to Modify Document during the coding ■ want to decode h"A”notH"7” Chip enable= lao al la2 a3 subdeSign decode 1 (a3.0]: input chip enable chip enable: output begin chip enable =(a3.0]==HA") Need more effort to modify end Self explain the function Copyright 1997 Altera Corporation Only thing to change Abera 2/22/2021P12 favara
Copyright © 1997 Altera Corporation 2/22/2021 P.12 Why I use AHDL instead of Graphic ◼ Easy to Modify ◼ Document during the coding ◼ I want to decode H”A” not H”7” SUBDESIGN decode1 ( a[3..0] : input; chip_enable : output; ) begin chip_enable = (a[3..0] == H"A"); end; Self Explain the Function Only thing to change Need more effort to modify Chip_enable = !a0 & a1 & !a2 & a3
More subdesign decoded (a3.0]: input chip enable: output, begin chip enable=(a3.0]-=B"1x0x") end Some bit can be ignore for comparsion Copyright 1997 Altera Corporation 2/22/2021P13 favara
Copyright © 1997 Altera Corporation 2/22/2021 P.13 More SUBDESIGN decode1 ( a[3..0] : input; chip_enable : output; ) begin chip_enable = (a[3..0] == B"1x0x"); end; Some bit can be ignore for comparsion
Something you need to know ■ Addition:+ ■ Subtraction:- Numeric Equality ■ Not equal to:! ■ Greater than:> Greater than or equal to: > ■ Less than:< a Less than or equal to: < ■ Logical or:# ■ Logical AND:& Copyright 1997 Altera Corporation 2/22/2021P14 favara
Copyright © 1997 Altera Corporation 2/22/2021 P.14 Something you need to know ◼ Addition : + ◼ Subtraction : - ◼ Numeric Equality : == ◼ Not equal to : != ◼ Greater than : > ◼ Greater than or equal to : >= ◼ Less than : < ◼ Less than or equal to : <= ◼ Logical OR : # ◼ Logical AND : &
Use Constant Function Use Constant if the same number, text string, or arithematic expression is repeated several times in a file ■ Advantage Modify one place will modify all Only one statement needs to be changed CONSTANT O ADDRESS=H" Define ConStant subdESIGn decode before SUbdESIGN ( a[3.0]: input keyword chip enable: output; begin chip_enable=(a[3.0]f=IO_ADDRESS) if (a[3.0==l0 ADDRESS) then Copyright 1997 Altera Corporation 2/22/2021P end favara
Copyright © 1997 Altera Corporation 2/22/2021 P.15 Use Constant Function ◼ Use Constant if the same number, text string, or arithematic expression is repeated several times in a file ◼ Advantage – Only one statement needs to be changed CONSTANT IO_ADDRESS = H"A"; SUBDESIGN decode1 ( a[3..0] : input; chip_enable : output; ) begin chip_enable = (a[3..0] == IO_ADDRESS); if (a[3..0] == IO_ADDRESS) then ……... end; Define CONSTANT before SUBDESIGN keyword Modify One Place will modify all