Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

basic ques related to tlm and systemc

Status
Not open for further replies.

mohi@608

Member level 4
Member level 4
Joined
Apr 4, 2012
Messages
69
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,719
Well i wanted to know how TLM is related to systemc (other then TLM is systemc based) . could anyone tell basic steps to how to build a tlm based model???
and is it that in order to make TLM based model we have to first model it in systemc????
 

i have a model which is c++ based ...could anyone help me how to model it systemc based and tlm based....????

- - - Updated - - -

well i have gone through doulos which it is difficult to understand for a beginner......
 

As you wrote TLM is SystemC based. It means when you write TLM based model you use SystemC library functions.
It is based on OpenSource library and can be run with free tools like Visual Studio Express Edition. So, if you need practice in writing and simulating TLM based model I can help you to write one step-by-step.
 
As you wrote TLM is SystemC based. It means when you write TLM based model you use SystemC library functions.
It is based on OpenSource library and can be run with free tools like Visual Studio Express Edition. So, if you need practice in writing and simulating TLM based model I can help you to write one step-by-step.

thanks kornukhin
well i have a simple counter which c++ based could you help me to make it systemc and tlm based..
 

well i have a simple counter which c++ based could you help me to make it systemc and tlm based..

OK, I will write some instruction for SystemC and TLM and will post it here in a few hours.
 
Here is sample code for C++/SystemC/TLM models. Please, look at the code first, and if you have any question fill free to ask.
 

Attachments

  • SystemC.zip
    15.2 KB · Views: 131

well thanks let me go through it and i'll get back to you...

- - - Updated - - -

well while simulating systemc there is
Code:
// SystemC counter
// compiler: Borland 5.5 + SystemC_Win1.0 Beta
//
#include <stdio.h>
#include <systemc.h>
//
// C++ counter
//
unsigned int counter(unsigned int cnt)
{
   return (cnt+1);
}
//
// SystemC counter module
//
class counter_module : public sc_module
{
   SC_HAS_PROCESS(counter_module);
   public:
      sc_in_clk clk, res;
      sc_out<unsigned int> cnt;

   private:
      void increment_counter()
      {
         if(res.read() == 0)
            cnt.write(0);
         else
            cnt.write(counter(cnt.read()));
      }

   public:
      counter_module(sc_module_name nm) : sc_module(nm),
         clk("clk"),
         res("res"),
         cnt("cnt")
      {
         SC_METHOD(increment_counter);
         sensitive_pos << clk;
         sensitive_neg << res;
      }
   const char* hdl_name() const { return "counter_module"; }
};
//
// Stimulus generator
//
SC_MODULE(stimulus)
{
   sc_in<bool>  clk;
   sc_out<bool> res;
   sc_in<unsigned int> cnt;

   unsigned cycle;

   SC_CTOR(stimulus)
   {
      SC_METHOD(entry);
      sensitive_pos(clk);
      cycle = 0;
   }
   void entry()
   {
      cycle++;
      if(cycle == 0 || cycle == 22) res.write(false);
      else res.write(true);
      cout << "Counter = " << cnt.read() << " at cycle " << cycle << endl;
      if(cycle == 100)
      {
         cout << "Simulation of " << cycle << " items finished at time " << sc_simulation_time() << endl;
         sc_stop();
      };
   }
};
//
// Top-level module
//
int sc_main (int argc, char *argv[])
{
   sc_clock        clk("clk",1,SC_NS);
   sc_signal<bool> res;
   sc_signal<unsigned int> cnt;

   stimulus stimulus_inst("stimulus_block");
   stimulus_inst.clk(clk.signal());
   stimulus_inst.res(res);
   stimulus_inst.cnt(cnt);

   counter_module counter_module_inst ("counter_module_dut");
   counter_module_inst.clk(clk.signal());
   counter_module_inst.res(res);
   counter_module_inst.cnt(cnt);

   sc_start(clk, -1);
   return 0;
}

Code:
../src/practise.cpp:84: error: ‘class sc_core::sc_clock’ has no member named ‘signal’
../src/practise.cpp:89: error: ‘class sc_core::sc_clock’ has no member named ‘signal’
../src/practise.cpp:93: error: invalid conversion from ‘int’ to ‘sc_core::sc_time_unit’
../src/practise.cpp:93: error:   initializing argument 2 of ‘void sc_core::sc_start(int, sc_core::sc_time_unit, sc_core::sc_starvation_policy)’

pls check ..
and why have u used
Code:
if(i!=0 && i!=22) res=1;
	  else res=0;(/[CODE]
any specific reason...

[COLOR="silver"]- - - Updated - - -[/COLOR]

and there is another error in TLM
[CODE]../src/practise.cpp:154:   instantiated from here
/home/mohit/Desktop/systemc-2.3.0/include/tlm_utils/simple_target_socket.h:266: error: ‘opts’ has incomplete type
make: *** [src/practise.o] Error 1
 

../src/practise.cpp:84: error: ‘class sc_core::sc_clock’ has no member named ‘signal’
../src/practise.cpp:89: error: ‘class sc_core::sc_clock’ has no member named ‘signal’
../src/practise.cpp:93: error: invalid conversion from ‘int’ to ‘sc_core::sc_time_unit’
../src/practise.cpp:93: error: initializing argument 2 of ‘void sc_core::sc_start(int, sc_core::sc_time_unit, sc_core::sc_starvation_policy)’

As I wrote inside cpp files I used SystemC_Win for SystemC model compilation. Now I checked under Linux.
You should change the following code in 'cnt_sc.cpp'
stimulus_inst.clk(clk.signal()); -> stimulus_inst.clk(clk);
counter_module_inst.clk(clk.signal()); -> counter_module_inst.clk(clk);
sc_start(clk, -1); -> sc_start();

and why have u used
Code:
if(i!=0 && i!=22) res=1;
else res=0;(/[CODE]
any specific reason...
[/QUOTE]
I just clear counter at some random time.

[QUOTE]../src/practise.cpp:154:   instantiated from here
/home/mohit/Desktop/systemc-2.3.0/include/tlm_utils/simple_target_socket.h:266: error: ‘opts’ has incomplete type
make: *** [src/practise.o] Error 1
[/QUOTE]
Must be some problems with installation and configuration. I have used the following script to check all 3 models under Linux. Check if you specify same flags as I made.

[QUOTE]
g++ cnt_c.cpp
./a.out
g++ -I/home/alexei/systemc/systemc-2.3.0/src/ -lsystemc  -L/home/alexei/systemc/systemc-2.3.0/lib-linux/ cnt_sc.cpp
./a.out
g++ -DSC_INCLUDE_DYNAMIC_PROCESSES -I/home/alexei/systemc/systemc-2.3.0/src/ -lsystemc  -L/home/alexei/systemc/systemc-2.3.0/lib-linux/ cnt_tlm.cpp
./a.out
 [/QUOTE]
 

As I wrote inside cpp files I used SystemC_Win for SystemC model compilation. Now I checked under Linux.
You should change the following code in 'cnt_sc.cpp'
stimulus_inst.clk(clk.signal()); -> stimulus_inst.clk(clk);
counter_module_inst.clk(clk.signal()); -> counter_module_inst.clk(clk);
sc_start(clk, -1); -> sc_start();


I just clear counter at some random time.


Must be some problems with installation and configuration. I have used the following script to check all 3 models under Linux. Check if you specify same flags as I made.

hi,
sorry i could reply earlier i was going through the systemc code and i have a doubt that why have you used this:
Code:
const char* hdl_name() const { return "counter_module"; }
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top