Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Verilog:从两个实例中选择一个作为输出_Verilog_Shift_Mux - Fatal编程技术网

Verilog:从两个实例中选择一个作为输出

Verilog:从两个实例中选择一个作为输出,verilog,shift,mux,Verilog,Shift,Mux,我创建了两个不同的Verilog模块(shiftbymm和immShifter)。我想做的是只选择其中一个的输出作为我正在创建的这个小多路复用器模块的输出 module superShifter(input [0:31] in, input select, input [0:4] shift_value, input[0:1] shift, output reg [0:31] out); shiftByImm shift0(in, shift_value, shift, out); immSh

我创建了两个不同的Verilog模块(
shiftbymm
immShifter
)。我想做的是只选择其中一个的输出作为我正在创建的这个小多路复用器模块的输出

module superShifter(input [0:31] in, input select, input [0:4] shift_value, input[0:1] shift, output reg [0:31] out);

shiftByImm shift0(in, shift_value, shift, out);
immShifter shift1(in, shift_value, out);

assign {out} = select == 1'b0 ? shift0 : shift1;

endmodule
然而,这给了我两个完全可以理解的错误:

非法引用接口“shift0”
非法引用接口“shift1”


我知道这里少了一些东西。如何选择超级换档器模块的输出,使其与其中一个预制模块的输出相同?

您的问题在于您的命名约定。你有两个模块(我猜是),有两个不同的输出,但是你给它们取了相同的名字。在本例中,您使用的是端口顺序方法。括号中的名称按顺序隐式关联,不需要与实例化中的名称相同。另一种方法是按名称连接端口。在这个例子中,我展示了这两种方法。从那时起,您必须使用声明的连线来选择带有“小mux”的输出


您的问题在于您的命名约定。你有两个模块(我猜是),有两个不同的输出,但是你给它们取了相同的名字。在本例中,您使用的是端口顺序方法。括号中的名称按顺序隐式关联,不需要与实例化中的名称相同。另一种方法是按名称连接端口。在这个例子中,我展示了这两种方法。从那时起,您必须使用声明的连线来选择带有“小mux”的输出


从@N8TROs answer开始,您似乎正在尝试“调用”模块并让它们生成输出

模块并不等同于在需要时调用的任务,它们表示硬件的物理块。mux需要选择您不希望激活模块的输出

由于两个模块驱动相同的输出,当一个模块驱动1而另一个模块驱动0时,您可能会看到
x
s,因此导线或网络将发生冲突

我非常同意N8TROs建议使用ANSI风格的命名端口,这确实有助于KPS调试和代码维护

但为了简洁起见,并在代码中看到最小的更改以使其工作:

shiftByImm shift0(in, shift_value, shift, out0); //<-- Unique output
immShifter shift1(in, shift_value, out1);        //<-- Unique output

assign {out} = select == 1'b0 ? out0: out1;  //<-- select output

shiftbymm shift0(in,shift\u值,shift,out0)// 从@N8TROs answer开始,您似乎正在尝试“调用”模块并让它们生成输出

模块并不等同于在需要时调用的任务,它们表示硬件的物理块。mux需要选择您不希望激活模块的输出

由于两个模块驱动相同的输出,当一个模块驱动1而另一个模块驱动0时,您可能会看到
x
s,因此导线或网络将发生冲突

我非常同意N8TROs建议使用ANSI风格的命名端口,这确实有助于KPS调试和代码维护

但为了简洁起见,并在代码中看到最小的更改以使其工作:

shiftByImm shift0(in, shift_value, shift, out0); //<-- Unique output
immShifter shift1(in, shift_value, out1);        //<-- Unique output

assign {out} = select == 1'b0 ? out0: out1;  //<-- select output
shiftbymm shift0(in,shift\u值,shift,out0)//