版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、VHDL Model of a Finite State Machine BCD to Excess-3 code converter (Mealy) Traffic light controller (Moore) Serial to parallel data converter (Moore)Finite state machine Contains combinational logic Storage elements Edge-triggeredCombinational LogicState Flip FlopsInputsOutputsClockPresent StateNex
2、t State Mealy machine: Output = function of (Present State, Inputs)Moore machine: Output = function (Present State only)BCD to Excess-3 Code Converter Excess-3 code (X3): Add 3 to Binary Coded Decimal (BCD) Input: BCD, Least significant bit (LSB) first Output: Excess-3 code, LSB firstBCDExcess-30000
3、001100010100001001010011011010011100Code ConverterInputOutputCodeConverter00001001Mealy FSMS0S1S2S3S4S5S60/11/00/10/0, 1/11/00/0, 1/11/00/10/0, 1/10/1, 1/0No carryCarry S0: Reset state S1, S3, S5: No carry state S2, S4, S6: Carry state X/Y: Input/OutputTrace on BCD-Excess 3 Code Converter FSMS0S1S2S
4、3S4S5S60/11/00/10/0, 1/11/00/0, 1/11/00/10/0, 1/10/1, 1/0No carryCarry Input: 0110 Output: 1001 States traversed:S0, S1, S4, S6, S0VHDL Model of BCD-X3 FSM (Next State Logic)entity MealyFSM is port (x, reset, clock: in bit;z: out bit );end MealyFSM;architecture RTL of MealyFSM istype s_type is (s0,
5、s1, s2, s3, s4, s5, s6);signal state, nextstate: s_type;BeginstateFSM: process (clock, reset)begin if ( reset = 1 ) then state = s0; elsif ( clockevent and clock = 1) then state = nextstate; end if;end process stateFSM;Defines storage elementRising edge triggeredAsynchronous resetVHDL Model of BCD-X
6、3 FSM (Output Logic)outputFSM: process ( state, x )begin z = 0; nextstate if x = 0 then z = 1; nextstate = s1; else z = 0; nextstate if x = 0 then z = 1; nextstate = s3; else z = 0; nextstate if x = 0 then z = 0; nextstate = s4; else z = 1; nextstate if x = 0 then z = 0; nextstate = s5; else z = 1;
7、nextstate if x = 0 then z = 1; nextstate = s5; else z = 0; nextstate if x = 0 then z = 0; nextstate = s0; else z = 1; nextstate if x = 0 then z = 1; nextstate null; end case;end process outputFSM;end RTL;Output is a combinational function of input and stateSynthesized BCD2X3 ConverterOutputNext stat
8、e logicTraffic Light ControllerStreet a is the main street and street b is the side streetSa=1: Vehicle approaching on street aSb=1: Vehicle approaching on street bLight on a stays green until vehicle on bThen light on b changes green and changes back after 50 secondsIf another car on b and no car o
9、n a then light on b remains green for 10 more secondsWhen a is green remains green for at least 60 secondsTraffic Light ControllerClockSaSbRbGaYaRaYbGbSaSbTraffic Light Controller Moore FSMClock cycle period = 10 secondsSa=1: Vehicle approaching on street aSb=1: Vehicle approaching on street bS0GaRb
10、S1GaRbS2GaRbS3GaRbS4GaRbS5GaRbS12RaYbS11RaGbS10RaGbS9RaGbS8RaGbS7RaGbS6YaRbSbSbSaSbSa+SbTraffic Light Controller VHDL Modelentity traffic_light is port ( clk, Sa , Sb: in bit;Ra, Rb, Ga, Gb, Ya, Yb: out bit );end traffic_light;architecture behave of traffic_light issignal state, nextstate: integer r
11、ange 0 to 12;type light is ( R,Y, G );-signal lightA, lightB: light;beginprocess( clk )beginif ( clkevent and clk = 1 ) thenstate = nextstate;end if;end process;State transition on clock edgeTraffic Light Controller VHDL Model (Cont.)-lightA = R when Ra =1 else Y when Ya = 1 else G when Ga =1;-light
12、B = R when Rb =1 else Y when Yb = 1 else G when Gb =1;process ( state, Sa, Sb )beginRa =0; Rb=0; Ga=0;Gb=0; Ya=0; Yb Ga = 1; Ra=0; Ya=0;Rb = 1;Gb=0;Yb=0; nextstate Ga = 1; Rb=1;if Sb = 1then nextstate Ya = 1; Rb = 1; nextstate Ra =1; Gb =1; nextstate Ra = 1; Gb = 1;if (Sa =1 or Sb =0) then nextstate
13、 Ra = 1; Yb =1; nextstate NULL;end case;end process;end behave;Output and next state logicSerial-to-Parallel Data (S2PD) Converter4-bit serial-to-parallel converterSynchronous reset initializes the state machine from any stateA denotes valid data at input port DZ generates parallel dataSerial-to-Par
14、allel data converterClockADDoneZRS2PD Converter Moore FSMR: ResetA: Valid dataS3S4S2S0S5RS1RRRRRR & AR + AR + AR & ARRS2PD Converter VHDL Modelentity spdc is port ( clk, R , A, D: in bit;Z: out bit_vector ( 3 downto 0 ) ; Done: out bit );end spdc;architecture fsm_rtl of spdc istype state_type is ( S
15、0, S1, S2, S3, S4, S5 );signal state: state_type;signal shift_reg: bit_vector ( 3 downto 0 );beginprocess ( state )begincase state iswhen s0 to s4 = Done Done = 1; Z if R = 1 or A = 0 then state = S0;elsif R = 0 and A = 1 then state shift_reg = D & shift_reg ( 3 downto 1 );if R = 0 then state = S2;
16、elsif R = 1 then state shift_reg = D & shift_reg ( 3 downto 1 );if R = 0 then state = S3; elsif R = 1 then state shift_reg = D & shift_reg ( 3 downto 1 );if R = 0 then state = S4; elsif R = 1 then state shift_reg = D & shift_reg ( 3 downto 1 );if R = 0 then state = S5; elsif R = 1 then state if R =
17、0 and A = 1 then state = S1;elsif R = 1 or A = 0 then state NULL;end case; end if;end process;end fsm_rtl;Output and next state logicVHDL Modeling of FSMsController design shouldAvoid asynchronous feedback, race conditionsSplit large countersInitialize design to a known stateMinimize number of latch
18、esFull specify all signals in a combinational processA flow-through latch is implied when a signal or variable in a combinational process is not fully specifiedPrefer case over IF-THEN-ELSEIF statement operates on a priority encoded basisHWDesign a controller to dispense a package of gum when 25 cents are deposited. The machine has a single coin slot and only accepts, quarters, dimes and nickels (no pennies). Further, the machine accepts exact amount only (i.e. it does not give out change).Draw the state machine. Identif
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 江蘇省泰州市姜堰區(qū)2024-2025學(xué)年七年級上學(xué)期期中地理試題(含答案)
- 數(shù)據(jù)中心項目投資計劃書
- 贛南師范大學(xué)《審計學(xué)》2021-2022學(xué)年第一學(xué)期期末試卷
- 2024年電動開顱設(shè)備項目投資申請報告代可行性研究報告
- 阜陽師范大學(xué)《幼兒歌曲彈唱》2022-2023學(xué)年第一學(xué)期期末試卷
- 福建師范大學(xué)協(xié)和學(xué)院《跨國公司經(jīng)營與管理》2021-2022學(xué)年第一學(xué)期期末試卷
- 《股權(quán)轉(zhuǎn)讓合同》-企業(yè)管理
- 福建師范大學(xué)《漆畫人物創(chuàng)作大創(chuàng)作》2023-2024學(xué)年第一學(xué)期期末試卷
- 醫(yī)美行業(yè)研究框架關(guān)注上游高景氣賽道
- 福建師范大學(xué)《廣告史》2021-2022學(xué)年第一學(xué)期期末試卷
- 2024-2030年中國鉀長石行業(yè)運行動態(tài)與產(chǎn)銷需求預(yù)測報告
- 第四章-護(hù)理人際關(guān)系倫理
- 針灸室暈針應(yīng)急預(yù)案演練方案
- 第2章 第5節(jié) 科學(xué)探究:電容器2023-2024學(xué)年新教材高二物理必修第三冊同步課堂高效講義配套教學(xué)設(shè)計(魯科版2019)
- 電動汽車充電設(shè)施及場站測試評價規(guī)范第1部分:總則
- 二次系統(tǒng)安全防護(hù)事故應(yīng)急預(yù)案格式(標(biāo)準(zhǔn)版)
- 餐飲技能大賽(中式面點師賽項)理論考試題及答案
- 部編版2023-2024學(xué)年度六年級上冊語文期中測試卷(附答案)
- 2023-2024學(xué)年北京西城區(qū)八中高三(上)期中數(shù)學(xué)試題及答案
- 村集體所有房屋買賣合同書(35篇)
- 江蘇省南京市2024-2025學(xué)年高三上學(xué)期第一次學(xué)情調(diào)研英語試題含答案
評論
0/150
提交評論