Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

sorting 4 numbers with controller and datapath

hi

i'm working on a machine that sorts 4 numbers with 4 bits.

i can't understand why it doesnt work.

i made it by ussing "bubble sort" technique

all files here include an image of the machine.

the machine works well with the second and the third numbers but it doesnt works with the first and the fourth.

compare2 - the comperator

contcomp- controller

top - the main.

thanks in advance

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    an easy way is to address four locations (out of 16) with the numbers serially and write value 1 there then read them back.

    e.g. if address sequence (A,B,C,D] is 11, 15,0,1 then

    addresses 0,1,11,15 will be set to 1, others 0

    read back from 0 to 15

    min will be first address with 1 and so on