templates with systemc

Hi,

Can you guys help me with this template issue?

Please look at my example and error below.

Here is the error:

g++ -o amba -Wall -g ./bin/sc_main.o ./bin/master.o ./bin/arbiter.o ./bin/slave.o ./bin/amba.o ./bin/mux_hrdata.o ./bin/slave_decoder.o ./bin/mux.o /iceng/lib/stdcell/work/tforby/systemc/systemc-2.2.0/lib-gccsparcOS5/libsystemc.a
Undefined first referenced
symbol in file
Mux<unsigned>::main_action() ./bin/amba.o
ld: fatal: Symbol referencing errors. No output written to amba
collect2: ld returned 1 exit status
gnumake: *** [amba] Error 1

C++ code


Mux.h
--------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
template <class T>
class Mux : public sc_module
{
  public:
    //ports, process, ...
   
    // sel from arbiter
    sc_fifo_in<unsigned int> sel;
   
    // in
    sc_fifo_in<T> in[SIZE];
   
    // hrdata
    sc_fifo_out<T> out;
   
    SC_HAS_PROCESS(Mux);
   
    //SC_CTOR(Mux)
    Mux(sc_module_name name_)
    {
      SC_THREAD(main_action);
      sensitive << sel << in[SIZE];
    }
   
    void main_action();
   
};


Mux.cpp
---------------

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
template <class T>
void Mux<T>::main_action()
{
 
  //verify that its a valid sel - 0 -- 15
  if ( sel.read() < SIZE )
  {
    //out = in[sel]
    out.write(in[sel.read()].read());
  }
  else
  {
    //error -- invalid sel bit
  }
}


Amba.cpp
-------

1
2
3
  Mux<unsigned int> MuxHaddr("muxhaddr");
  Mux<unsigned int> MuxHwdata("muxhwdata");
  Mux<unsigned int> MuxHwrite("muxhwrite");

Last edited on
Okay, this seems like a systemc thing. I copied mux.h and mux.ccp and removed all the systemC stuff out, and it compiled. Hmm, if you cans can offer help, i would still appreciate it.

Thanks!!!
WOOHOO, sorry for this post guys, I have figured it out. I had to put the template class member function in the mux.h file itself. Once again, sorry for this wasted thread. But I am sure I'll be back again.
Topic archived. No new replies allowed.