8 位宽、2 对 1 多路复用器 verilog 模块
8 bit wide, 2-to-1 multiplexer verilog module
我很难理解这个问题。我应该使用 Verilog 为 8 位宽的 2 对 1 多路复用器创建一个模块。
问题:
Write a verilog module that uses 8 assignment statements to describe the circuit. Use SW[17] on the DE2 board as the s input, switches [7:0] as the X input, switches [15:8] as the Y input. Connect SW switches to the red lights LEDR and output M to the green light LEDG [7:0].
我的代码:
module example(M, X, Y, S)
input[15:0] SW;
input SW[17];
output [7:0] LEDR;
output [7:0] LEDG;
output [7:0] M;
wire [7:0] X = SW[7:0];
wire [7:0] Y = SW[15:8];
wire S = SW[17]
assign M[0] = X[0] & ~S | Y[8] & S;
assign M[1] = X[1] & ~S | Y[9] & S;
assign M[2] = X[2] & ~S | Y[10] & S;
assign M[3] = X[3] & ~S | Y[11] & S;
assign M[4] = X[4] & ~S | Y[12] & S;
assign M[5] = X[5] & ~S | Y[13] & S;
assign M[6] = X[6] & ~S | Y[14] & S;
assign M[7] = X[7] & ~S | Y[15] & S;
endmodule
我不明白我应该如何将 m 分配给绿色 LEDG[7:0],因为我已经将每个 M 分配给那些条件语句。有人知道如何解决这个问题吗?
虽然有多种方法可以做到这一点,但我建议制作一个包含电路板 i/o 作为输入和输出的包装器模块,并在其中实例化您的 MUX:
module top(input [17:0] SW,
output [15:0] LEDR,
output [7:0] LEDG);
example ex(.M(LEDG), .s(SW[17]), .X(SW[7:0]), .Y(SW[15:8]));
assign LEDR[7:0] = X;
assign LEDR[15:8] = Y;
endmodule
[insert your mux module minus the board i/o here]
如果您不能使用上述解决方案,您可以查看如何在 QuartusII 中使用 Pin Planner(我假设您正在使用提示中的 DE2 参考)。
我很难理解这个问题。我应该使用 Verilog 为 8 位宽的 2 对 1 多路复用器创建一个模块。
问题:
Write a verilog module that uses 8 assignment statements to describe the circuit. Use SW[17] on the DE2 board as the s input, switches [7:0] as the X input, switches [15:8] as the Y input. Connect SW switches to the red lights LEDR and output M to the green light LEDG [7:0].
我的代码:
module example(M, X, Y, S)
input[15:0] SW;
input SW[17];
output [7:0] LEDR;
output [7:0] LEDG;
output [7:0] M;
wire [7:0] X = SW[7:0];
wire [7:0] Y = SW[15:8];
wire S = SW[17]
assign M[0] = X[0] & ~S | Y[8] & S;
assign M[1] = X[1] & ~S | Y[9] & S;
assign M[2] = X[2] & ~S | Y[10] & S;
assign M[3] = X[3] & ~S | Y[11] & S;
assign M[4] = X[4] & ~S | Y[12] & S;
assign M[5] = X[5] & ~S | Y[13] & S;
assign M[6] = X[6] & ~S | Y[14] & S;
assign M[7] = X[7] & ~S | Y[15] & S;
endmodule
我不明白我应该如何将 m 分配给绿色 LEDG[7:0],因为我已经将每个 M 分配给那些条件语句。有人知道如何解决这个问题吗?
虽然有多种方法可以做到这一点,但我建议制作一个包含电路板 i/o 作为输入和输出的包装器模块,并在其中实例化您的 MUX:
module top(input [17:0] SW,
output [15:0] LEDR,
output [7:0] LEDG);
example ex(.M(LEDG), .s(SW[17]), .X(SW[7:0]), .Y(SW[15:8]));
assign LEDR[7:0] = X;
assign LEDR[15:8] = Y;
endmodule
[insert your mux module minus the board i/o here]
如果您不能使用上述解决方案,您可以查看如何在 QuartusII 中使用 Pin Planner(我假设您正在使用提示中的 DE2 参考)。