我的cholesky.cpp文件:
#include "chol.h"
#include <math.h>
//Main Thread
void chol::chol_main () {
// Variable declaration
sc_fixed<16,10, SC_TRN, SC_WRAP> chol_output[3][3];
sc_fixed<16,10, SC_TRN, SC_WRAP> chol_in[3][3];
int n=3;
//Main Thread
while (true) {
for (int i=0; i<n; i++){
for(int j=0; j<=i; j++){
chol_in[i][j] = chol_in_data[i][j].read();
}
}
}
for (int i=0; i<n; i++){
for (int j=0; j<=i; j++){
sc_fixed<16,10, SC_TRN, SC_WRAP> sum = 0;
for (int k=0; k<j; k++){
sum += chol_output[i][k] * chol_output[j][k];
}
if (i==j){
chol_output[i][i] = sqrt(chol_in[i][i] - sum) ;
}else{
chol_ouput[i][j] = 1.0 / chol_ouput[j][j] * (chol_in[i][j] - sum);
}
}
}
chol_out_data.write(chol_output);
}
此chol.h的头文件:
#ifndef CHOL
#define CHOL
#define SC_INCLUDE_FX
#include "define.h"
SC_MODULE (chol) {
public:
// Inputs
sc_in_clk clk;
sc_in <bool> rst;
sc_in <sc_fixed<16,10, SC_TRN, SC_WRAP> > chol_in_data[3][3] ;
// Output
sc_out <sc_fixed<16,10, SC_TRN, SC_WRAP> > chol_out_data[3][3] ;
/* F */
void chol_main ( void );
// Constructor
SC_CTOR (chol) {
SC_CTHREAD (chol_main, clk.pos());
reset_signal_is(rst, false) ;
sensitive << clk.pos();
}
// Destructor
~chol() {}
};
#endif
输出:
g++ -O1 -I"/home/mahesh/systemc/systemc-2.3.1a/include" -I"." -c cholesky.cpp -o cholesky.o
cholesky.cpp: In member function ‘void chol::chol_main()’:
cholesky.cpp:47:5: error: ‘chol_ouput’ was not declared in this scope
chol_ouput[i][j] = 1.0 / chol_ouput[j][j] * (chol_in[i][j] - sum);
^
cholesky.cpp:54:17: error: request for member ‘write’ in ‘chol_out_data’, which is of non-class type ‘sc_core::sc_out<sc_dt::sc_fixed<16, 10, (sc_dt::sc_q_mode)5u, (sc_dt::sc_o_mode)3u> > [3][3]’
chol_out_data.write (chol_output);
^
Makefile:90: recipe for target 'cholesky.o' failed
make: *** [cholesky.o] Error 1
我正在执行矩阵分解,并将cholesky模块的2D数组的输出写入连接到cholesky testbench模块的信号端口。
我已经在范围内声明了chol_output变量;仍然,我收到了超出范围的错误。同样,它说“写”是非类类型的。
有人可以帮忙吗?
最佳答案
对于第一个错误,您只是将chol_output
拼写为chol_ouput
。
第二个错误就是它的含义:chol_out_data
不是类对象,因此不能在其上使用.
。它是类对象数组的数组。