60 likes | 159 Views
CSE 670 Winter 2004 Mid-Term examination. Implementation of Bubble sort aglorithm By, Sumitha Nath .K.N. Bubble sort algorithm. for i n to 1 { for j 2 to i { if a[j-1] > a[j] then temp = a[j-1] a[j-1] = a[j] a[j] = temp J++ } i - - }. case current_state is when s0=>
E N D
CSE 670 Winter 2004Mid-Term examination Implementation of Bubble sort aglorithm By, Sumitha Nath .K.N
Bubble sort algorithm for i n to 1 { for j 2 to i { if a[j-1] > a[j] then temp = a[j-1] a[j-1] = a[j] a[j] = temp J++ } i - - }
case current_state is when s0=> next_state <= s1; when s1 => if iflag = '1' then next_state <= sdisp; else next_state <= s2; end if; when s2 => if jflag = '1' then next_state <= s9 ; else next_state <= s3j; end if; when s3j => next_state <= s3j1; when s3j1 => if chkflag = '1' then next_state <= s4 ; else next_state <= s8; end if; when s4 => next_state <= s5; when s5 => next_state <= s6; when s6 => next_state <= s7; when s7 => next_state <= s8; when s8 => next_state <= S2; when s9 => next_state <= s1; when sdisp => next_state <= s0; end case;
case current_state is when s0 => loopclr <= '1'; when s1 => loopclr <= '0'; when s2 => null; when s3j => jload <='1'; when s3j1 => addrsel <= '0'; j1load <= '1'; when s4 => tload <= '1'; when s5 => wj1load <= '1'; addrsel <= '0'; fload <= '1'; when s6 => addrsel <= '1'; datasel <= '1'; when s7 => wjload <= '1'; fload <= '1'; when s8=> jinc <= '1'; when s9 => loopclr <= '1'; iinc <= '1'; when sdisp => sortdone <= '1'; when others => null; end case;
C1: process(current_state,dflag,sortdone,BTN4) begin case current_state is when swait => if BTN4 = '1' then next_state <= swait; else next_state <= s0; end if; when s0=> if BTN4 = '1' then next_state <= s1; else next_state <= s0; end if; when s1 => if dflag = '1' then next_state <= swait; else next_state <= s2; end if; when s2 => next_state <= s1 ; end case; end process C1;
C2: process(current_state) begin dinc <= '0'; floaddisp <= '0'; case current_state is when swait => null; when s0 => null; when s1 => null; when s2 => dinc <= '1'; when others => null; end case; end process C2;