gpt4 book ai didi

c++ - 请求 ‘write’中的成员 ‘chol_out_data’,非类类型

转载 作者:行者123 更新时间:2023-11-28 05:13:56 25 4
gpt4 key购买 nike

我的 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 模块的二维数组的输出写入连接到 cholesky 测试台模块的信号端口。

我已经在范围内声明了 chol_output 变量;仍然,我得到了同样的错误,它超出了范围。此外,它表示“write”属于非类类型。

有人能帮忙吗?

最佳答案

对于第一个错误,您只是将 chol_output 拼错为 chol_ouput

第二个错误就是它所说的:chol_out_data 不是类对象,因此您不能在其上使用 .。它是类对象数组的数组。

关于c++ - 请求 ‘write’中的成员 ‘chol_out_data’,非类类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43033530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com