#include <iostream> #include <iomanip> using namespace std; int pos(int p, int a, int b, int c, int d) { if (a == p) return 0x00; if (b == p) return 0x01; if (c == p) return 0x10; if (d == p) return 0x11; return 0; } int main(void) { int a,b,c,d; for(a=0; a<4; a++) for(b=0; b<4; b++) for(c=0; c<4; c++) for(d=0; d<4; d++) if ((a != b) && (b != c) && (c != d) && (a != c) && (a != d) && (b != d)) { cout << "when " << '"' << dec << (a>b) << (b>c) << (c>d) << (d>a) << (a>c) << (b>d) << '"' << " => "; cout << "mux(0) <= " << '"' << hex << setw(2) << setfill('0') << pos(3,a,b,c,d) << '"' << "; "; cout << "mux(1) <= " << '"' << hex << setw(2) << setfill('0') << pos(2,a,b,c,d) << '"' << "; "; cout << "mux(2) <= " << '"' << hex << setw(2) << setfill('0') << pos(1,a,b,c,d) << '"' << "; "; cout << "mux(3) <= " << '"' << hex << setw(2) << setfill('0') << pos(0,a,b,c,d) << '"' << ";" << endl; } }