Thread: : error: no match for 'operator<<' in 'os << *(((cmd*)((const sc_core::sc_fifo<cmd>*)

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    10

    : error: no match for 'operator<<' in 'os << *(((cmd*)((const sc_core::sc_fifo<cmd>*)

    Hi

    while running the code as attached

    I am getting the following error

    C:/Xilinx/Vivado_HLS/2015.4/win64/tools/systemc/include/sysc/communication/sc_fifo.h:314:13: error: no match for 'operator<<' in 'os << *(((cmd*)((const sc_core::sc_fifo<cmd>*)this)->sc_core::sc_fifo<cmd>::m_buf) + ((unsigned int)(((unsigned int)i) * 16u)))

    Can anyone please help

    here is my code

    Code:
    
    
    Code:
    #include "systemc.h"
    enum state {ADD, SUB, MULT, DIV};
    
    
    class cmd{
    public:
        state command;
    
    
         int op_1;
         int op_2;
         int cmd_id;
    
    
        cmd() : command(ADD), op_1(0), op_2(0), cmd_id(0) {};
    
    
        cmd (state c,int d0,int d1,int id):
    
    
        command(c), op_1(d0),op_2(d1),cmd_id(id) {};
    };
    
    ///////////////////////////////////////////////////
    
    #include "systemc.h"
    #include "cmd.h"
    
    
    SC_MODULE(arith){
    
    
    
    
    
    
        sc_port<sc_fifo_in_if<cmd> > data_in;
        sc_port<sc_fifo_out_if<cmd> > data_out;
    
    
        sc_fifo<cmd> result_buffer;
    
    
        void write_result (cmd&, sc_int<64>&);
    
    
        void return_proc();
        void arith_proc();
    
    
        SC_CTOR(arith) {
    
    
         SC_THREAD(return_proc);
    
    
        // SC_THREAD(arith_proc);
         }
    
    
    };
    
    
    //////////////////////////////////////////
    
    void arith::arith_proc()
    
    
    {
        cmd tmp_reg;
         sc_int<64> result;
    
    
    
    
         // wait to get off time zero
    
    
         wait(1, SC_NS);
    
    
         while (true) {
         // Get the next command
         tmp_reg = data_in->read();
    
    
         switch (tmp_reg.command) {
                        result = tmp_reg.op_1 + tmp_reg.op_2;
                       wait(20, SC_NS); //time to do op
                       write_result(tmp_reg, result);
                       break;
              case SUB:
                       result = tmp_reg.op_1 - tmp_reg.op_2;
                     wait(20, SC_NS); //time to do op
                     write_result(tmp_reg, result);
                     break;
              case MULT:
                       result=tmp_reg.op_1*tmp_reg.op_2;
                       wait(40,SC_NS);
                       write_result(tmp_reg, result);
                       break;
             case DIV:
                        result=tmp_reg.op_1/tmp_reg.op_2;
                        wait(40,SC_NS);
                        write_result(tmp_reg, result);
                        break;
    
    
    
    
             default:
                 cout << endl << sc_time_stamp() << " "
                << name() << ": Received an illegal command, value = "
                <<tmp_reg.command << endl << endl;
                 break;
         }
    
    
     }
    
    
    
    
    }
    
    
    //////////////////////////////////////////
    
    void arith::return_proc() {
    while (true){
     // get a result and send it back
    
    
        data_out->write(result_buffer.read());
     }
    }
    
    
    ////////////////////////////////////////////
    
    void arith::write_result(cmd& tmp, sc_int<64>& result) {
     tmp.op_1 = result.range(63,32); //upper 32 bits
     tmp.op_2 = result.range(31,0);
    // lower 32 bits
     result_buffer.write(tmp);
    // write into buffer
    }

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,626
    Presumably you're missing something like this (example) :
    Code:
    std::ostream& operator<<(std::ostream& os, cmd& c) {
        os << c.op_1 << ", " << c.op_2 << ", " << cmd_id << '\n';
        return os;
    }
    A little inaccuracy saves tons of explanation. - H.H. Munro

  3. #3
    Registered User
    Join Date
    Dec 2017
    Posts
    10
    I added this code in cmd.h file now it is giving error like

    ../../../cmd.h:24:51: error: 'std:stream& cmd:perator<<(std:stream&, cmd&)' must take exactly one argument


    I apologize for stupid comments and question but being newbie i m unable to understand the error

  4. #4
    Registered User
    Join Date
    Dec 2017
    Posts
    1,626
    It shouldn't be inside the cmd class. It's not a member function. (Normally it would be a "friend" function, but since your data is all public, it doesn't need that either.)

    You could put this prototype in cmd.h, after the class:
    Code:
    std::ostream& operator<<(std::ostream&, cmd&);
    Then put the definition of that function (that I gave previously) in the appropriate source file.

    However, I find your code very confusing, so I'm not sure if this will fix your problem.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  5. #5
    Registered User
    Join Date
    Dec 2017
    Posts
    10
    thanks John it worked well

    now I am having the following error by adding the code

    Error: Compiling ../../../receive_cmd.cpp in debug mode../../../receive_cmd.cpp: In member function 'void tb::receive_cmds()':
    ../../../receive_cmd.cpp:11:40: error: no match for 'operator==' in 'tmp_cmd == ((tb*)this)->tb::gold_rom[tmp_cmd.cmd::cmd_id]'
    ../../../receive_cmd.cpp:11:40: note: candidate is:
    C:/Xilinx/Vivado_HLS/2015.4/win64/tools/systemc/include/sysc/kernel/sc_process_handle.h:145:13: note: bool sc_core:perator==(const sc_core::sc_process_handle&, const sc_core::sc_process_handle&)
    C:/Xilinx/Vivado_HLS/2015.4/win64/tools/systemc/include/sysc/kernel/sc_process_handle.h:145:13: note: no known conversion for argument 1 from 'cmd' to 'const sc_core::sc_process_handle&'
    make: *** [obj/receive_cmd.o] Error 1

    Code:
    #include "tb.h"
    #include "cmd.h"
    
    
    
    
    void tb::receive_cmds(){
     cmd tmp_cmd;
     wait(1, SC_NS);
     cmd_error = false;
     while(true){
     tmp_cmd = tb_cmd_in->read();
     if (tmp_cmd == gold_rom[tmp_cmd.cmd_id]) {
     cout << sc_time_stamp() << " " << name();
     cout << ": received correct result for: " << tmp_cmd << endl;
     }
     else {
     cmd_error++;
     cout << sc_time_stamp() << " " << name();
     cout << ": ERROR command = "<< tmp_cmd
     << ", should be: "
     << gold_rom[tmp_cmd.cmd_id];
     }
     num_cmds --;
     cmd_received.notify();
     }
    }
    your advice is highly regarded .you solved my problem had been trying for days

    Best regards
    Uzmeed

  6. #6
    Registered User
    Join Date
    Dec 2017
    Posts
    1,626
    I don't know how to fix that one.
    You seem to be trying to compare two very different things.
    One is a cmd, the other seems to be a sc_core::sc_process_handle
    I have no idea what the relationship between them is.
    A little inaccuracy saves tons of explanation. - H.H. Munro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-29-2017, 12:43 PM
  2. [Error] no match for 'operator<' in '(& st
    By Дмитро in forum C++ Programming
    Replies: 1
    Last Post: 12-16-2015, 11:50 AM
  3. error : no match for 'operator<<' in 'std::cin 1935374429'
    By funnydarkvador in forum C++ Programming
    Replies: 3
    Last Post: 03-12-2013, 05:06 PM
  4. Fix basic error: no match for 'operator!=' in 'i != ...
    By aeolusaether in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2010, 12:27 AM
  5. new to C++ : Error: no match for `operator` ....
    By MasterACE14 in forum C++ Programming
    Replies: 13
    Last Post: 05-23-2008, 01:56 AM

Tags for this Thread