Error: (E112) get interface failed: port is not bound - SystemC
Error: (E112) get interface failed: port is not bound - SystemC
我的目标是创建一个使用桶形移位器进行加减运算的 ALU
alu.h
#include "systemc.h"
SC_MODULE(alu){
sc_in<bool> op;
sc_in<sc_int<8> > a;
sc_inout<sc_int<8> > b;
sc_out<sc_int<8> > output;
void alu_method();
SC_CTOR(alu) {
SC_METHOD(alu_method);
dont_initialize();
sensitive << a,b,op;
}
};
alu.cpp
#include "alu.h"
void ALU::alu_method(){
if (op.read() == 0){
//substract
out.write(in.read() - in_bs.read());
}
else{
//add
out.write(in.read() + in_bs.read());
}
}
barrelshift.h
#include <systemc.h>
void make_barrel();
SC_MODULE(barrel_shift) {
sc_in<bool> clk;
sc_in<bool> enable;
sc_in<bool> left_right;
sc_in<sc_uint<3> > shift_amt;
sc_in<sc_int<8> > din;
sc_inout<sc_int<8> > dout;
void barrel_method();
SC_CTOR(barrel_shift) {
SC_METHOD(barrel_method);
dont_initialize();
sensitive << clk.pos(); //edge sensitive
}
};
barrelshift.cpp
#include "barrelshift.h"
void barrel_shift :: barrel_method(){
if(enable.read() == 1){
if(left_right.read() == 0){ //shift left
dout.write(din.read() << shift_amt.read());
}else if(left_right.read() == 1){ // right shift
dout.write(din.read() >> shift_amt.read());
}
}
else
cout << "Not enabled "<<endl;
dout <= din;
}
sc_main.cpp
#include <systemc.h>
#include "alu.h"
#include "barrelshift.h"
int sc_main(int argc, char* argv[]){
sc_trace_file *tf;
//Signals
sc_signal <bool> enable, op, l_r;
sc_signal <sc_int<8> > a, output,b, bin;
sc_signal < sc_uint<3> > shift_amt;
//Clock
sc_clock clk("clk",10,SC_PS,0.5);
alu myALU("myALU");
barrel_shift myShifter("myShifter");
myALU.a(a);
myALU.b(b);
myALU.output(output);
myALU.op(op);
myShifter.clk(clk);
myShifter.din(bin);
myShifter.enable(enable);
myShifter.left_right(l_r);
myShifter.shift_amt(shift_amt);
myShifter.dout(b);
tf = sc_create_vcd_trace_file("trace_file");
sc_trace(tf, clk, "clk");
sc_trace(tf, a, "a");
sc_trace(tf, bin, "BarrelShifter In");
sc_trace(tf, op, "op");
sc_trace(tf, shift_amt, "shift_amt");
sc_trace(tf, l_r, "left_right");
sc_trace(tf, enable, "enable");
sc_trace(tf, b, "b");
sc_trace(tf, output, "output");
sc_close_vcd_trace_file(tf);
cout << "The result from the ALU is: " << output.read();
}
构建时没有错误。但是每当我尝试执行它时,我都会收到以下错误:
Error: (E112) get interface failed: port is not bound: port 'myALU.port_0' (sc_in)
In file: sc_port.cpp:231
是什么原因造成的,我该如何解决?
问题出在 alu
的敏感度列表上。应该是:
sensitive << a << b << op;
错误信息
Error: (E112) get interface failed: port is not bound: port 'myALU.port_0' (sc_in)
表示端口myALU.port_0
没有绑定信号。但是alu
模块中哪个端口对应port_0
?
最好为所有端口和信号命名——无论您使用的是哪种硬件描述语言——这样更容易诊断此类错误。
在 alu
构造函数中命名端口:
SC_CTOR(alu) :
op("op"),
a("a"),
b("b"),
output("output")
{
// ...
我无法重现您看到的错误。我看到这个错误(在提供所有端口和信号的名称之后):
Error: (E115) sc_signal<T> cannot have more than one driver:
signal `signal_5' (sc_signal)
first driver `myShifter.dout' (sc_inout)
second driver `myALU.b' (sc_inout)
我注意到您的代码中存在一些其他问题:
- 您的代码无法编译,因为
alu_method()
. 中使用了错误的变量名
sc_start()
未在 sc_main()
中调用。
alu()
中有一个无效的 sensitive
调用 -- 应该是 sensitive << a << b << op;
正如@DarrylLawson 正确指出的那样,此错误消息表明端口 myALU.port_0
未绑定到信号(如果您在构造函数中为端口命名,您将获得更清晰的名称).
一个重要的细微差别恕我直言,这意味着端口未绑定到信号在给出错误时。您可能有绑定它的代码,但这仅在详细说明期间的某个时刻执行。如果您在此之前尝试使用该端口(例如,在模块的构造函数中),您仍然会收到此错误消息。在这种情况下,错误将在时间 0 发生。
我的目标是创建一个使用桶形移位器进行加减运算的 ALU
alu.h
#include "systemc.h"
SC_MODULE(alu){
sc_in<bool> op;
sc_in<sc_int<8> > a;
sc_inout<sc_int<8> > b;
sc_out<sc_int<8> > output;
void alu_method();
SC_CTOR(alu) {
SC_METHOD(alu_method);
dont_initialize();
sensitive << a,b,op;
}
};
alu.cpp
#include "alu.h"
void ALU::alu_method(){
if (op.read() == 0){
//substract
out.write(in.read() - in_bs.read());
}
else{
//add
out.write(in.read() + in_bs.read());
}
}
barrelshift.h
#include <systemc.h>
void make_barrel();
SC_MODULE(barrel_shift) {
sc_in<bool> clk;
sc_in<bool> enable;
sc_in<bool> left_right;
sc_in<sc_uint<3> > shift_amt;
sc_in<sc_int<8> > din;
sc_inout<sc_int<8> > dout;
void barrel_method();
SC_CTOR(barrel_shift) {
SC_METHOD(barrel_method);
dont_initialize();
sensitive << clk.pos(); //edge sensitive
}
};
barrelshift.cpp
#include "barrelshift.h"
void barrel_shift :: barrel_method(){
if(enable.read() == 1){
if(left_right.read() == 0){ //shift left
dout.write(din.read() << shift_amt.read());
}else if(left_right.read() == 1){ // right shift
dout.write(din.read() >> shift_amt.read());
}
}
else
cout << "Not enabled "<<endl;
dout <= din;
}
sc_main.cpp
#include <systemc.h>
#include "alu.h"
#include "barrelshift.h"
int sc_main(int argc, char* argv[]){
sc_trace_file *tf;
//Signals
sc_signal <bool> enable, op, l_r;
sc_signal <sc_int<8> > a, output,b, bin;
sc_signal < sc_uint<3> > shift_amt;
//Clock
sc_clock clk("clk",10,SC_PS,0.5);
alu myALU("myALU");
barrel_shift myShifter("myShifter");
myALU.a(a);
myALU.b(b);
myALU.output(output);
myALU.op(op);
myShifter.clk(clk);
myShifter.din(bin);
myShifter.enable(enable);
myShifter.left_right(l_r);
myShifter.shift_amt(shift_amt);
myShifter.dout(b);
tf = sc_create_vcd_trace_file("trace_file");
sc_trace(tf, clk, "clk");
sc_trace(tf, a, "a");
sc_trace(tf, bin, "BarrelShifter In");
sc_trace(tf, op, "op");
sc_trace(tf, shift_amt, "shift_amt");
sc_trace(tf, l_r, "left_right");
sc_trace(tf, enable, "enable");
sc_trace(tf, b, "b");
sc_trace(tf, output, "output");
sc_close_vcd_trace_file(tf);
cout << "The result from the ALU is: " << output.read();
}
构建时没有错误。但是每当我尝试执行它时,我都会收到以下错误:
Error: (E112) get interface failed: port is not bound: port 'myALU.port_0' (sc_in) In file: sc_port.cpp:231
是什么原因造成的,我该如何解决?
问题出在 alu
的敏感度列表上。应该是:
sensitive << a << b << op;
错误信息
Error: (E112) get interface failed: port is not bound: port 'myALU.port_0' (sc_in)
表示端口myALU.port_0
没有绑定信号。但是alu
模块中哪个端口对应port_0
?
最好为所有端口和信号命名——无论您使用的是哪种硬件描述语言——这样更容易诊断此类错误。
在 alu
构造函数中命名端口:
SC_CTOR(alu) :
op("op"),
a("a"),
b("b"),
output("output")
{
// ...
我无法重现您看到的错误。我看到这个错误(在提供所有端口和信号的名称之后):
Error: (E115) sc_signal<T> cannot have more than one driver:
signal `signal_5' (sc_signal)
first driver `myShifter.dout' (sc_inout)
second driver `myALU.b' (sc_inout)
我注意到您的代码中存在一些其他问题:
- 您的代码无法编译,因为
alu_method()
. 中使用了错误的变量名
sc_start()
未在sc_main()
中调用。alu()
中有一个无效的sensitive
调用 -- 应该是sensitive << a << b << op;
正如@DarrylLawson 正确指出的那样,此错误消息表明端口 myALU.port_0
未绑定到信号(如果您在构造函数中为端口命名,您将获得更清晰的名称).
一个重要的细微差别恕我直言,这意味着端口未绑定到信号在给出错误时。您可能有绑定它的代码,但这仅在详细说明期间的某个时刻执行。如果您在此之前尝试使用该端口(例如,在模块的构造函数中),您仍然会收到此错误消息。在这种情况下,错误将在时间 0 发生。