-2

So I am making an ALU that has an 8to1 mux that selects between different operations. However only 6 operations are required, so the other two inputs of the mux don't even need to be used. So is there a way to essentially connect them to gnd? Basically to make nothing being outputted for those cases?

Here is the general design schematic for reference / to visualize. https://i.gyazo.com/854f8acd904f9e7db2f950c3b4eab27d.png

Here is my code for the 8to1 Mux. (Don't think I need to show this, but it might be helpful.)

module eight_one_mux(D, S, out);
input [7:0] D;
input [2:0] S;
output reg [63:0] out;

always @(D or S) 

begin

case(S)

0 : out = D[0]; //And
1 : out = D[1]; //Or
2 : out = D[2]; //Adder
3 : out = D[3]; //xor
4 : out = D[4]; //lefter
5 : out = D[5]; //righter
6 : out = D[6]; //GND
7 : out = D[7]; //GND
default : out = 1'bx;

endcase
end

endmodule

RhinoECE
  • 43
  • 7
  • Nope, but there is one thing to note... I would prefer if I keep my mux code as it is, since later on I might update my ALU and connect a different operation to the currently unused inputs. So I guess my question is, is there a way when I instantiate all my modules and connect the different blocks together (as seen in the screenshot I added) where I can just connect the D[6] and D[7] to gnd/zero. ? – RhinoECE Mar 13 '21 at 20:11
  • Not yet, when I do I'll let you know if I got any errors or not. – RhinoECE Mar 13 '21 at 20:21
  • 1
    The is no such thing as "nothing being outputted". You module always has an output - 0 or 1. If you mean don't care - that would be a 1'bx – dave_59 Mar 13 '21 at 21:27

1 Answers1

-1

you can just directly set them to 0

6 : out = 1'b0; //GND
7 : out = 1'b0; //GND

(As a side note, if this is intending to be a mux, you might want to make the output the same number of bits as the input)

noah
  • 32
  • 2