




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





moore_bits.vhd Mon^ Apr^27 16:56:29^2009
Page 1
3 -- Module Name: moore_bits - Behavioral 4 ---------------------------------------------------------------------------------- 5 library IEEE; 6 use IEEE.STD_LOGIC_1164.ALL; 7 8 entity moore_bits is 9 Port ( clock : in STD_LOGIC; 10 X : in STD_LOGIC; 11 R : in STD_LOGIC; 12 Y : out STD_LOGIC); 13 end moore_bits; 14 15 architecture Behavioral of moore_bits is 16 type state_type is (START, Got0, Got01, Got010); 17 signal state, next_state: state_type; 18 begin 19 -- State register process 20 process(clock, R, next_state) is 21 begin 22 if RISING_EDGE(clock) then 23 if R='1' then 24 state <= START; 25 else 26 state <= next_state; 27 end if; 28 end if; 29 end process; 30 31 -- Next state process 32 process(state, X) is 33 begin 34 case state is 35 when START => 36 if X='0' then 37 next_state <= Got0; 38 else 39 next_state <= START; 40 end if; 41 when Got0 => 42 if X='1' then 43 next_state <= Got01; 44 else 45 next_state <= Got0; 46 end if; 47 when Got01 => 48 if X='0' then 49 next_state <= Got010; 50 else 51 next_state <= START; 52 end if; 53 when Got010 => 54 if X='0' then 55 next_state <= Got0; 56 else 57 next_state <= Got01; 58 end if; 59 when others => next_state <= START; 60 end case; 61 end process;
moore_bits.vhd Mon^ Apr^27 16:56:29^2009
Page 2
63 -- Output process 64 Y <= '1' when state = Got010 else '0'; 65 end Behavioral; 66 67
mealy_bits.vhd Mon^ Apr^27 16:47:07^2009
Page 2