# Function of demultiplexers in Register File

What is the function of demultiplexers (DMX) in this Logisim diagram of a Register File design:

Also could you explain the meaning of:

dreg,sreg,treg

dsel,ssel,tsel

dwrite,swrite,twrite

• DMUX is an "Enhanced decoder" such that given the selected line, the output of this line is the DMUX input(0 or 1) unlike the decoder which assures that its always 1 Why DMUX? 1-to select one of the registers 2-to be able to write data into this register by setting the DMUX input to a 0 or 1 [Enable] – Elbehery Jul 20 '16 at 22:45
• @AbdoMohamed So can we say that the right half of diagram related with storing and left side related with loading? – mertyildiran Jul 20 '16 at 22:48
• @AbdoMohamed or the exact opposite? – mertyildiran Jul 20 '16 at 22:50
• @AbdoMohamed regval and DMXs are input right? – mertyildiran Jul 20 '16 at 22:51
• Exactly, im posting an answer if this is not clear enough – Elbehery Jul 20 '16 at 23:12

## First let me define a simple Register

INPUTS: Write,Data_in[16],CLK

OUTPUTS: Data_out[16]

IF the Write pin is HIGH, the data in the Data_in[16] will be stored in this register the next clock cycle (Rising or falling edge)

The Write pin is connected to the DMUX outputs so you can choose one of the 8 registers to write by providing the proper select value[SEL pin] and a '1' on the Dmux input

So for example if i want to write data in R5

1- Put the data in regval[16]

Since regval[16] is connected to all the 8 registers, we need to select only one of the 8 registers to store this value

How can we make this !

By using a DMUX

2- Ill set dsel[ 3] to '101' to make sure that the DMUX is selecting the 5th register

3- Then ill set dwrite to '1' to make sure that the 5th register 'Write' pin is triggered HIGH and the data in regval will be stored only in this register the next clock cycle edge

Now we are able to Select one of the 8 registers and write the data only to it even though all the registers Data_in[16] pin are connected to the same bus (regval)

Connect all the registers Data_out[16] pin to the Mux inputs, then output only one of them by providing the proper value on the select (sel) pin

For example if i want to read the value of R5

1-Ill put '101' on dsel[ 3]

2- read the register stored value from the Mux output

## Why dsel,ssel,tsel

when making an ALU operation for example adding two numbers and storing them in a register

R[d] = R[s] + R[t]

D is the destination register where the result is stored

S and T are the two operands