module compareSwap #(parameter Width=32) (req,fin,a,b,smaller,bigger);

input [Width-1:0] a,b;
output wire [Width-1:0] smaller,bigger;
input req;
output wire fin;
wire compareFin,biggerSign,equalSign,smallerSign;
wire biggerFin,smallerFin;

comparator  #(Width) comparator (req,compareFin,a,b,biggerSign,equalSign,smallerSign);
chooseFrom2 #(Width) chooseSmaller (compareFin,smallerFin,a,b,smaller,smallerSign);
chooseFrom2 #(Width) chooseBigger  (compareFin,biggerFin,b,a,bigger,smallerSign);
reqAnd      #(2) finAnd ({smallerFin,biggerFin},fin);

endmodule