|
Mux ( Coord, Controls, Inputs, Outputs )
Coord = coordinate of the component
Controls = control signals of the Mux
Inputs = input signals of the Mux
Outputs = output signals of the Mux
|
Requirement:
|
void simnet()
{
Sig(i0,1); Sig(i1,1); Sig(i2,1); Sig(i3,1); // Input signals
Sig(c0,1); Sig(c1,1); // Control signals
Sig(out,1); // Output signal
Switch( "aa", i3, '3', Zero );
Switch( "ba", i2, '2', Zero );
Switch( "ca", i1, '1', Zero);
Switch( "da", i0, '0', One );
Switch( "fa", c1, 'b', Zero );
Switch( "ga", c0, 'a', Zero );
/* ==========================================
c1 c0 Output
--------------------------
0 0 i0
0 1 i1
1 0 i2
1 1 i3
========================================== */
Mux ( "ab-db", (c1,c0), (i3,i2,i1,i0), out ); // Mux !!!
Probe ( "bc", out ); // Probe out
}
|
Notice that:
|
Sample output:
|
How to run the program:
|
|
|
void simnet()
{
Sig(i0,1); Sig(i1,1); Sig(i2,1); Sig(i3,1); // Input signals
Sig(i4,1); Sig(i5,1); Sig(i6,1); Sig(i7,1);
Sig(c0,1); Sig(c1,1); // Control signals
Sig(out0,1); Sig(out1,1); // Output signals
Switch( "aa", i7, '7', Zero );
Switch( "aa", i6, '6', Zero );
Switch( "ba", i5, '5', Zero );
Switch( "ba", i4, '4', One );
Switch( "ca", i3, '3', One);
Switch( "ca", i2, '2', Zero);
Switch( "da", i1, '1', One );
Switch( "da", i0, '0', One );
Switch( "fa", c1, 'b', Zero );
Switch( "ga", c0, 'a', Zero );
/* ==========================================
c1 c0 Output
--------------------------
0 0 (i1,i0)
0 1 (i3,i2)
1 0 (i5,i4)
1 1 (i7,i6)
========================================== */
Mux ( "ab-db", (c1,c0),
( (i7,i6), (i5,i4), (i3,i2), (i1,i0) ),
(out1,out0)
); // Mux !!!
Probe ( "bc", out1 ); // Probe out
Probe ( "bc", out0 ); // Probe out
}
|
How to run the program:
|