DMUX4WAY

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

DMUX4WAY

jayjay
Wondering if someone can explain to me what the number IN square brackets represents?
For example below is the parts list I came up with for DMUX4WAY.
I could not get it to work when I had originally used sel=sel[0]  , sel=sel[1] sel=sel[1] in place of what is below for the selectors.
When I get DMUX8WAY to work the architecture seems different again for the DMUX4WAY used to build it. sel[0]=sel[0] etc....
Thanks

DMUX4WAY
PARTS:
    // Put your code here:
    DMux(in=in, sel=sel[1], a=c1, b=c2);
    DMux(in=c1, sel=sel[0], a=a, b=b);
    DMux(in=c2, sel=sel[0], a=c, b=d);

DMUX8WAY
PARTS:
    // Put your code here:
DMux(in=in, sel=sel[2], a=c1, b=c2);
DMux4Way(in=c1, sel[0]=sel[0], sel[1]=sel[1], a=a, b=b, c=c, d=d);
DMux4Way(in=c2, sel[0]=sel[0], sel[1]=sel[1], a=e, b=f, c=g, d=h);
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

WBahn
Administrator
The number in square brackets on the DMUX4WAY means the same thing that it did on the other multi-bit and multi-way gates that came before it. Go back and revisit those and make sure you understand them.

Reread sections 1.2.3 and 1.2.4 very carefully.
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

jayjay
I have read and re-read but it doesn't make sense to me why the selector has to begin
with 1 in the first Dmux.
Let me explain what I think I understand and maybe you can tell me where I am going wrong.
I understand that there are 3 selectors as per the 3 Dmux chips we are using here
to build the Dmux4Way(each of my Dmux chips have 2 inputs being in,and sel as well as 1 output).
I would figure we could call/label the Dmux`s selectors  "sel" and then assign them numbers 0,1,and 2
being that there are 3 selectors.If I did name them as such I would do so in order and end up with
something like;
Dmux(in=in, sel[0]=sel[0], a=c1, b=c2);
Dmux(in=c1, sel[1]=sel[1], a=a, b=b);
Dmux(in=c2, sel[2]=sel[1], a=c, b=d);
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

WBahn
Administrator
jayjay wrote
I have read and re-read but it doesn't make sense to me why the selector has to begin
with 1 in the first Dmux.
Let me explain what I think I understand and maybe you can tell me where I am going wrong.
I understand that there are 3 selectors as per the 3 Dmux chips we are using here
to build the Dmux4Way(each of my Dmux chips have 2 inputs being in,and sel as well as 1 output).
I would figure we could call/label the Dmux`s selectors  "sel" and then assign them numbers 0,1,and 2
being that there are 3 selectors.If I did name them as such I would do so in order and end up with
something like;
Dmux(in=in, sel[0]=sel[0], a=c1, b=c2);
Dmux(in=c1, sel[1]=sel[1], a=a, b=b);
Dmux(in=c2, sel[2]=sel[1], a=c, b=d);

Look at the interface for the Dmux chip. It only has a 1-bit sel signal.

The four signals for the Dmux chip are {in, sel, a, b}, so those are the exact signal names you have to use when you hook it up.

So your part instantiation needs to be

Dmux(in=<someSignal1>, sel=<someSignal2>, a=<someSignal3>, b=<someSignal4>);

The <someSignaln> is the name of the wire connecting the parts together.

Look back at the diagram in Figure 1.6. In each of the part instantiations, the name on the left side of the equals sign is the name of one of the ports for that part, while the name on the right is the name of a wire in the schematic at the top of the diagram.

Draw out your schematic for how you want to hook up the parts and put them in a box that has the inputs and outputs of the chip you are building crossing it. After you have it wired like you want it, give each wire a unique name (the wires connected to the pins on the box already have a name -- the name of the box pin). Then just use those names to connect the parts in your HDL netlist.
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

kingofbuffs
In reply to this post by jayjay
I am stuck at this too. It was already hard for me to wrap my head around DMux in the first place,  because of the two outputs.  This one has two sel inputs and four outputs. The only tip given in the book about multiway gates is "Think forks". It worked wonderfully for Mux but I have no idea how to do it for DMux.

Can someone please give me another tip, so hopefully I can at least get a foothold in and solve this? I can't wait to get to the next chapter.

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

WBahn
Administrator
I wouldn't put much credence in those "hints". While some of them might be helpful, I think for the most part it was the authors trying to be cute and get  chuckle. Having said that, this is one of the helpful ones.

Don't make parts with multiple outputs harder than they are. You can always treat each output as it's own, separate problem and simply put the code for each in the same file. You may not end up with an elegant solution, but all that is important is that you end up with a working solution.

Imagine going down a road and you come to a (wait for it...) fork in the road. Your options are to go left or go right. You have a light on your dashboard, call it Light#1, that is OFF if you should go to the left and ON if you should go to the right. After taking the indicated branch you soon come to another (wait for it...) fork in the road. You look at a different light, Light#2 and it is OFF if you should go to the left and ON if you should go to the right (and had you gone the other way at the first fork, you would have done the same thing).

How many different roads, starting from the original starting road, could you end up on based on the possible ON/OFF conditions of these two lights?




Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

kingofbuffs
This post was updated on .
I spent an embarassing amount of time on this one, but I came up short. I found DMux4Way (eureka moment came at 4am while I was trying to sleep, it is a bit of an abomination but it works.) but couldn't really do it with DMux8Way. I don't think my iq points were quite up to the task for this one.

I read some old posts here, apparently it's possible to do it with 3 DMux4ways, even though most solutions I saw on github used a lot of Dmuxs.

Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

WBahn
Administrator
There are several ways to do it. Think of the road example again.

If we put a fence around the forks in the road described above, I have one road going in to the fenced area and four roads coming out of it with two lights on my dash telling me what to do at both decision points that I have to make. Sounds a lot like a DMux4Way, right?

Now what if the first thing that happens is I come across there is a fork in the road and I have a third light on my dash telling me to go left or right. Whichever way I go I encounter a fenced in area like the one above.

How many total lights do I have on my dash? How many total eventual road options are available to me?

You don't need 3 DMux4Ways, just two plus a normal DMux (and three Not gates).
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

kingofbuffs
This post was updated on .
Recently I have been doing a lot of programming/learning to program, so I tend to think a lot about conditionals, which I think prevents me from finding an answer.

My thought process tends to go like this:
There are 8 total outputs: a, b, c, d, e, f, g, h.
If sel[0]=0, we are left with 4 outputs: a, b, c, d.

And then if sel[1]= 0, we eleminate the last two, and left with a, b.

And finally if sel[2]=0, then in=a.



I just keep thinking this way but I don't know exactly how to translate it into the script. (I don't even know if it's the correct way to think about it.) Thank you  for the tip, I will give this one a shot and try to do it with 2 DMux4ways, 1 DMux and 3 Not gates and see if I can come up with a solution of my own.
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

WBahn
Administrator
Your diagram is EXACTLY what you are looking for.

And I was overlooking something in my mind -- you don't need the Not gates at all -- they are already built into the DMux parts.



Do see the fences. What's inside each fence?

Wires connect parts the same way that roads connect fenced areas.
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

kingofbuffs
(I used lightshot to avoid giving away the solution to people who may not want it.)

In a futile attempt to translate the diagram into a script, I came up with
this.

This did not work so I gave a shot to this.

And it worked. What the hell? All this time (over a week) spent scratching my head and it was because of the order of sels?

Anyway, I also came up with a more elegant solution.

I think this is the best it's going to get. Time to get to the next chapter. (so much for one week per chapter thing.)

Thank you so much for taking the time to help. In retrospect I should have asked for help earlier, that way I wouldn't have second guessed myself all the time and come up with a solution much faster. (I tried the solution I posted first here like 100 times because it made sense in my head but it just wouldn't work.)

Really appreciate it.
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

WBahn
Administrator
The key to getting the mapping right is to draw a clearly labelled chart and then follow it through by hand and ask if it makes sense.

In this case, you know that a particular select bit determines if the signal is routed to one of {a,b,c,d} versus {e,f,g,h}. So which DMux makes that happen? That DMux has to get that particular select bit.

Your elegant solution is the one I was telling you about with the 1 DMux and 2 DMux4Way parts. Do you see how it matches your tree diagram that I marked up?
Reply | Threaded
Open this post in threaded view
|

Re: DMUX4WAY

kingofbuffs
Yeap! It was rather easy after I drew the diagram.

It's kind of frusturating to know that I would have solved DMux4 and DMux8 much faster if only I did sel[2]->sel[1]->sel[0].

Regardless, it's still very satisfying to actually solve it and completely understand how it works.