1 / 6

CSE 670 Winter 2004 Mid-Term examination

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=>

jarvis
Download Presentation

CSE 670 Winter 2004 Mid-Term examination

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 670 Winter 2004Mid-Term examination Implementation of Bubble sort aglorithm By, Sumitha Nath .K.N

  2. 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 - - }

  3. 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;

  4. 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;

  5. 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;

  6. 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;

More Related