# mux4way16,help please!what's wrong with it?

4 messages
Open this post in threaded view
|

## mux4way16,help please!what's wrong with it?

 CHIP Mux4Way16 { IN a[16], b[16], c[16], d[16], sel[2]; OUT out[16]; PARTS: // Put your code here: Mux16(a[0~15]=a[0~15],b[0~15]=c[0~15], sel = sel[0],out[0~15]=x[0~15]); Mux16(a[0~15]=b[0~15],b[0~15]=d[0~15], sel = sel[0],out[0~15]=y[0~15]); Mux16(a[0~15]=x[0~15],b[0~15]=y[0~15], sel = sel[1],out[0~15]=out[0~15]);
Open this post in threaded view
|

## Re: mux4way16,help please!what's wrong with it?

 Administrator You need to use ".." for sub-bus syntax, not "~". HDL automatically connects all the wires in a bus.  Just say "a=a" rather than "a[0..15]=a[0..15]". --Mark
Open this post in threaded view
|

## Re: mux4way16,help please!what's wrong with it?

 Administrator In reply to this post by bluce One other thing that you need to watch out for when writing Mux4Way16 is which sel[n] controls the first pair of Mux16s and which sel[n] controls the output Mux16. Note from Figure 1.10 that when "b" input is to be selected, sel[0] = 1 and sel[1] = 0. --Mark
Open this post in threaded view
|

## Re: mux4way16,help please!what's wrong with it?

 In reply to this post by cadet1620 Thank you so much!it works!