4WayMux16 . syntax for bus inputs

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

4WayMux16 . syntax for bus inputs

dkennell
This post was updated on .
Howdy! First post on the forum, happy to be here.

I've successfully implemented the 4WayMux16 gate, but I kind of brute forced it with hundreds of lines of And and Or gates. I'd like to use a few Mux16 gates instead, but I can't find examples of how to use them. I keep running into 'the specified sub bus is not in the bus range' errors. I've experimented with [0..15] syntax as well, but with no luck. Is there somewhere I can see some examples of how to use this gate correctly? Thanks!

Here's my code, feel free to remove it:

[code removed]
Reply | Threaded
Open this post in threaded view
|

Re: 4WayMux16 . syntax for bus inputs

cadet1620
Administrator
dkennell wrote
I keep running into 'the specified sub bus is not in the bus range' errors. I've experimented with [0..15] syntax as well, but with no luck. Is there somewhere I can see some examples of how to use this gate correctly?

Mux(a[16]=a, ...);
Bus syntax does not change the width of a part. You need to be using Mux16 parts to build your Mux4Way16.

Then you can connect the Mux4Way16's inputs directly to the Mux16's inputs using '=' without any sub bus syntax. This will connect all 16 bits:
    Mux16(a=a, ...);


Welcome to the forum. It's OK to post code as you did to get help. Once you've solved your problem, please edit your post (More>Edit post dropdown) to minimize the code.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: 4WayMux16 . syntax for bus inputs

dkennell
This post was updated on .
Hi Mark,

Thanks for your reply! Good catch, I was indeed usnig the wrong gate there. However, switching to Mux16 didn't change the error for me and I still don't know what kind of syntax i need to use it with. What I mean by that is that I don't know how to do mass assignment for the pins. I suppose something like this might work....

[code removed]

...but I'm guessing that there's an easier way to do this than assigning all 50 pins individually. So far I haven't found anywhere that describes how to do this. Is there some documentation somewhere for this, or a similar HDL that I could read?

Thanks for your help, and I'll be sure to minimize my code when we're done!

- David
Reply | Threaded
Open this post in threaded view
|

Re: 4WayMux16 . syntax for bus inputs

cadet1620
Administrator
Connect 16-bit chip inputs/outputs directly to 16-bit part inputs/outputs.

For example, if you had a Nand16 part, you could make an And16 like this:
Nand16(a=a, b=b, out=x);
Not16(in=x, out=out);
You can also use "[0..15]" to mean the entire bus, but it's more typing:
Nand16(a[0..15]=a[0..15], b[0..15]=b[0..15], out[0..15]=x);
Note: you can't use [] on internal buses like 'x' in this example.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: 4WayMux16 . syntax for bus inputs

cadet1620
Administrator
In reply to this post by dkennell
dkennell wrote
Is there some documentation somewhere for this, or a similar HDL that I could read?
Appendix A.5.3 is about bus syntax and has some examples.
Reply | Threaded
Open this post in threaded view
|

Re: 4WayMux16 . syntax for bus inputs

dkennell
Awesome, I got it!

Okay, that makes sense. So no special syntax is needed, you can just refer to a entire bus by its variable (a, b, or whatever) and likewise, you can refer to an input bus as a single variable, no different from if it was a single wire going in.

Alright, and so by 'internal buses' you actually mean buses 'between gates.' I.e. outputs. So we can use [ ] on buses when we are defining an input for a gate, but not an output. Got it. So that's why I can use [ ] to select a specific digit of my selector, and why I could use [0..15] to select the entire input bus, if I wanted to use that syntax.

And I guess the big concept to wrap my head around is that the Mux is doesn't care what the actual values are of the bits in the different buses, it just wants to make sure that it returns the right bus. And thus, as long as our gates up with the specification, we make a choice between two gates, then make a choice between the winner and a third gate.

Neat!

I think I'm all set for now. Thanks for your help!