


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!



library IEEE; use IEEE.std_logic_1164.all; entity PROBLEM1 is port ( CLK: in STD_LOGIC; d: in STD_LOGIC; q: out STD_LOGIC_VECTOR (1 downto 0)); end; architecture PROBLEM1_arch of PROBLEM1 is type Sreg0_type is (S1, S2, S3, S4); signal Sreg0: Sreg0_type; begin Sreg0_machine: process (CLK) begin if CLK'event and CLK = '1' then case Sreg0 is when S1 => if d='0' then Sreg0 <= S1; else Sreg0 <= S3; end if; when S2 => if d='1' then Sreg0 <= S3; else Sreg0 <= S1; end if; when S3 => if d='1' then Sreg0 <= S3; else Sreg0 <= S4; end if;
when S4 => if d='1' then Sreg0 <= S1; else Sreg0 <= S2; end if; when others => null; end case; end if; end process; q_assignment: q <= "01" when (Sreg0 = S1 and d='0') else "11" when (Sreg0 = S1 and d='1') else "10" when (Sreg0 = S2 and d='1') else "00" when (Sreg0 = S2 and d='0') else "01" when (Sreg0 = S3 and d='1') else "10" when (Sreg0 = S3 and d='0') else "10" when (Sreg0 = S4 and d='1') else "00" when (Sreg0 = S4 and d='0') else "00"; end PROBLEM1_arch;
clk m( 1 ) m( 0 ) r(1 downto 0) s resetn 0 ns 2 00 ns 4 00 ns 6 00 ns 8 00 ns 10 00 ns โ 01 โ โ^10 โ^ โ^11 โ^ โ^00 โ^ โ^01 โ^ โ^10 โ clk m( 1 ) m( 0 ) r(1 downto 0) s resetn 0 ns 2 00 ns 4 00 ns 6 00 ns 8 00 ns 10 00 ns โ 01 โ โ^10 โ^ โ^11 โ^ โ^00 โ^ โ^01 โ^ โ^10 โ