Demultiplexer
2-way Dmux
Dmux is short for demultiplexer and does the inverse of what mux or multiplexer does. Given an input, the dmux select its output between several paths based on an address.
input
sel
a
b
input
0
input
0
input
1
0
input
What's that { a[n], b[n] }
output? It's our first time seeing a function that returns more than one output. In Mathematics, we usually think of a function as a machine that accepts one or multiple inputs and produces a single output. Single output also makes working with return values a lot easier. However, for our dmux
function, we clearly need to return two values. What do we do? To contain multiple outputs, we use a record. In Sim, a record is a bunch of key-value pairs:
where a
, b
, and c
are keys and 0
, 1
, and 0
are the keys' values.
The great thing about the record is that we always know the names of our many output values, just like we do for our function inputs. Plus, a record is a single value, just like 0
and input
!
If you have ideas on how to use records and how to implement dmux
, go ahead and implement it.
If you get stuck, click on "See Hints".
4-way Dmux
input
sel
a
b
c
d
input
00
input
0
0
0
input
01
0
input
0
0
input
10
0
0
input
0
input
11
0
0
0
input
If you get stuck, click on "See Hints".
8-way Dmux
input
sel
a
b
c
d
e
f
g
h
input
000
input
0
0
0
0
0
0
0
input
001
0
input
0
0
0
0
0
0
input
010
0
0
input
0
0
0
0
0
input
011
0
0
0
input
0
0
0
0
input
100
0
0
0
0
input
0
0
0
input
101
0
0
0
0
0
input
0
0
input
110
0
0
0
0
0
0
input
0
input
111
0
0
0
0
0
0
0
input
If you get stuck, click on "See Hints".
🎉 We just completed all the common logic circuits for our computer!
Last updated
Was this helpful?