hw5+6sol - severity error; wait until R=1 and S=0; n_s...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
C-302-701 Solutions to HW 5 + 6 Q1. Solution not provided. . Worked out in class without PRESET Q2. The FSM has 3 states – RESET,SET and UNDEFINED. It gets into the UNDEFINED state if R=’1’ and S=’1’. In this state it produces invalid outputs Q=’0’ and QBAR=’0’ and waits for the user to reset it. Due to the wait statement the process cannot have a sensitivity list; instead it waits for the rising edge of the clock at the end. entity RSFF is port(R,S,CLK:in bit; Q,QBAR:out bit); end RSFF; architecture behav of RSFF is type state is (RESET,SET,UNDEFINED) signal n_s:state; begin process begin case n_s is when RESET => Q <=’0’; QBAR <’’1’; if R=’0’ and S=’1’ then n_s <=SET; elsif (R=’1’) and(S=’1’) then n_s<= UNDEFINED; end if; when SET => Q <=’1’; QBAR <=’0’; if (R=’1’) and (S=’0’) then n_s <=RESET; elsif (R=’1’) and (S=’1’) then n_s<=UNDEFINED; end if; when UNDEFINED => Q <= ‘0’; QBAR <=’0’; assert false report”Invalid inputs and outputs – Reset the flipflop!”
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: severity error; wait until R=1 and S=0; n_s <=RESET; end case; wait until CLK=1 and CLKEVENT; end process; end behav; Q6. Solution not provided. Similar problem worked out in class Q4. The odd integers are 1,3,5,7. The ith odd integer is 2i-1 (i) process variable i,sum:integer; begin sum:=0; for i in 1 to n loop sum:=sum+2*i-1; end loop; wait for 100 ns; end process; (ii) process variable i,sum:integer; begin sum:=0; i:=1; while(i<n+1) loop sum:=sum+2*i-1; i:=i+1; end loop; wait for 100 ns; end process; (iii) process variable i,sum:integer; begin sum:=0; i:=1; loop sum:=sum+2*i-1; i:=i+1; exit when i:=n+1; end loop; wait for 100 ns; end process; (iv) process variable i,sum:integer; begin sum:=0; i:=1; for i in 1 to 2*n-1 loop if i mod 2 =0 then next; else sum:=sum+i; end loop; wait for 100 ns; end process; Q5. Correct answers: (i) 3 times (ii) Once (iii) s =22 (iv) s = 22...
View Full Document

This note was uploaded on 01/17/2012 for the course ECEC 302 taught by Professor Karkalprabhu during the Spring '06 term at Drexel.

Page1 / 3

hw5+6sol - severity error; wait until R=1 and S=0; n_s...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online