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!
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?
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:
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.
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....
...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!
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.
I think I'm all set for now. Thanks for your help!