Jump to content

Search the Community

Showing results for tags 'sc_thread'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Accellera Systems Initiative
    • Information
    • Announcements
    • In the News
  • SystemC
    • SystemC Language
    • SystemC AMS (Analog/Mixed-Signal)
    • SystemC TLM (Transaction-level Modeling)
    • SystemC Verification (UVM-SystemC, SCV, CRAVE, FC4SC)
    • SystemC CCI (Configuration, Control & Inspection)
    • SystemC Datatypes
  • UVM (Universal Verification Methodology)
    • UVM (IEEE 1800.2) - Methodology and BCL Forum
    • UVM SystemVerilog Discussions
    • UVM Simulator Specific Issues
    • UVM Commercial Announcements
    • UVM (Pre-IEEE) Methodology and BCL Forum
  • Portable Stimulus
    • Portable Stimulus Discussion
    • Portable Stimulus 2.0 Public Review Feedback
  • IP Security
    • SA-EDI Standard Discussion
    • IP Security Assurance Whitepaper Discussion
    • IP-XACT Discussion
  • SystemRDL
    • SystemRDL Discussion
  • IEEE 1735/IP Encryption
    • IEEE 1735/IP Encryption Discussion
  • Commercial Announcements
    • Announcements


  • SystemC
  • UVM
  • UCIS
  • IEEE 1735/IP Encryption

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL












Found 11 results

  1. Hello, I would like to create an arbitrary (random) number of processes, of the same module. So I tried with sc_vector. I can instantiate sc_module but not when there is a SC_THREAD in the module. I have the following code in my header "nodes.h" struct CNodes : sc_core::sc_module { CNodes(sc_core::sc_module_name instance); ~CNodes(void) = default; void CNodes::Init_node(int, float, float); SC_HAS_PROCESS(CNodes); private: int id = 0; // Processes and overrides void Thread_node(void); }; And the cpp files is : #include "Nodes.h" CNodes::CNodes(sc_core::sc_module_name instance) { id = 0; std::cout << "Constructing CNodes " << std::endl; SC_THREAD(Thread_node); // PROBLEMATIC LINE dont_initialize(); } void CNodes::Init_node(int pid, float bias, float rate) { } void CNodes::Thread_node(void) { while(true) { std::cout << "Hi there" << std::endl; wait(10,sc_core::SC_NS); } } When I put the "SC_THREAD" macro in my code, I got an error during elaboration Error: (E549) uncaught exception: Access violation - n In file: C:\SystemC\src\sysc\kernel\sc_except.cpp:98 The top module is this one. It instantiates 20 objects of class CNodes : #include <string> #include <time.h> #include "Network.h" #include "Nodes.h" using namespace std; CNetwork::CNetwork (sc_core::sc_module_name name, unsigned _size = 4): sc_core::sc_module(name), nodes("node") { float bias, rate; /* initialize random seed: */ srand((unsigned int)time(NULL)); nodes.init(20); for (unsigned int i = 0; i < nodes.size(); i++) { // generate random numbers for nodes bias = (float)rand() / RAND_MAX; rate = (float)rand() / RAND_MAX; nodes[i].Init_node(i, bias, rate); } } The modules "nodes" will have also ports, etc. But for the moment, I'm stuck with the instantiation. When I remove the problematic line, "SC_THREAD(Thread_node);", it works fine for the moment. But in that case I don't have the processes I need for my model. Is ther a way to instantiate a arbitrary number of processes, arbitrary meaning that the number is not known during coding phase because it will be random. Thanks ! Arnaud
  2. Hi How can I count the number of SC_THREAD/SC_METHOD in a given simulation of a SystemC platform ? Is it possible ? Thanks Khushi
  3. Hello, I'm writing a module in SystemC which basically works as follows: it receives a string of bytes through a port p_in and a control signal through the port h. The module must save the bytes within a matrix matrix just if the h signal is true. Within the SC_THREAD I'm using I implemented this: void MY_MODULE::my_method(){ if(!rst){ //put all the output ports to 0 } while(1){ //The module waits while the signal h is false while(!h) wait(); //The iterations to fill in the matrix begin //The iterations must work just if h = true for(i=0; i<100; i++){ for(j=0; j<100; j++){ matrix.nmmatrix[i*matrix.width+j] = p_in; wait(); while(!h) wait(); } } } } The problem I have is that the counters i and j start to increment one clock cycle after h passes from false to true. The behavior I'm trying to simulate is that the counters i and j start to increment in the same clock cycle when h passes from false to true and the counters must not increment while h is false. Could you please give a hint of what I am doing wrong?
  4. Good Day All, I am a complete noob in SystemC. I am however, working on a simulator which utilizes a few concepts from SystemC. Kernel is picking up on either the Sc_Method or the Sc_Thread. I am aware of the wait command. It can only be used in the sc_thread. But in my code, (excerpt) I am currently using SC_thread and sc_method simultaneously. I wanted to introduce a delay in simulation time in the sc_thread (using the wait command). Is there a way to forward the simulation time in SC_METHOD that is analogous to wait() in SC_Thread. I did change one of the functions to SC_Thread, and the other to SC_Method. But, on simulation, if the kernel picks up on the SC_Method, it continues to stay in SC_Method and not go on to SC_thread. Here is the code for SC_Method: (code for SC_THREAD is given after this code) void NoximRouter::rxProcess_local() { cout<<"rxProcess_local"; // Clear outputs and indexes of transmitting protocol ResetTable(); current_level_rx_local = 0; } else {//cout<<req_rx_local.read()<<" "<<current_level_rx_local<<endl; if((req_rx_local.read()== 1- current_level_rx_local) && !buffer_snd.IsFull()) { //current_level_rx = 1 + current_level_rx; NoximPacket received_packet = flit_rx_local.read(); //cout<<"Inside NoximRouter::rxProcess_local:"<<received_packet<<endl; buffer_snd.Push(received_packet); // cout<<"receiver"<<endl; if (NoximGlobalParams::verbose_mode > VERBOSE_OFF) { cout << sc_time_stamp().to_double() / 1000 << ": Router[" << local_id << "], Received packet from PE: " << received_packet << endl; } current_level_rx_local = 1 - current_level_rx_local; } ack_rx_local.write(current_level_rx_local); THIS IS PART OF THE CODE FOR SC_THREAD: void NoximRouter::txProcess_mode() { cout<<"txProcess_mode"; while( buffer_snd.Size()!=0) //Going with just one buffer(may be corresponding to the router,... but actually for the processing element) { NoximPacket packet = buffer_snd.Front(); NoximRouteData route_data; route_data.current_id = local_id; route_data.src_id = packet.src_id; route_data.dst_id = packet.dst_id; const vector < vector<int> > o = Route(route_data); //stats.power.Arbitration(o.size()); int src= packet.src_id; vector <int> path; int col =0; // checking in the global table the channels which are free and writhing to the respective channels path.push_back(src); packet.dir=checkdir(o); if(checkmode1(path,o,src,col,packet)==1) { buffer_snd.Pop(); cout<<"Mode1\n"; packet.seq_no=path; packet.mode_tx=1; flit_tx.write(packet); mode1_traffic++; stats.pkthist.push_back(makePacketHist(packet)); for(int i=0;i<path.size();i++) {
  5. Hello, I am having an SC_THREAD as follows // // SC_THREAD(my_proc); sensitive << event_1; dont_initialize(); // // // void my_proc() { while(1) { wait(10,SC_NS); cout << " Display ok"; wait(event_1); } } My question is i am having an situation where this event get triggered repetedly in short instance of time, lets say at time t=2 ns it get triggered then SC_THREAD starts, then again it get triggered at t=4ns, but this triggerring of event goes unnoticed. I saw some post and from them i got to know that i cant even use sc_event_queue as i am using wait in my thread. What can be alternative to implement this logic. Thanks.
  6. Hi all If I have something like follows: SC_MODULE(Test) { ... int t1; // Want this variable to be shared void tesst() { t1 = t1 +2; } SC_CTOR(Test) { SC_THREAD(tesst) } And then I create two instances of Test as Test *t1 = new ....; Test *t2 = new ... Then , how can make the varible "t1"shared by both the instances/ threads? In other words, I want this variable to be updated by both the threads. Thanks
  7. Hi Guys, It is my first day to read SystemC tutorial, forgive me if the questions are silly. I debugged following code in Visual Studio 2008 (64 bit) by setting break point at the start of do_test1 and do_test2, to my suprise, the code is running in the same thread of the sc_main function. I didn't debug in Linux environment. However, by searching the source code, I found the "pthread.h" was included by some SystemC library source code. Question 1: In Windows, will the SC_THREAD create a real thread? Or it is always in the same thread of sc_main? If this is the case, may I say SC_THREAD is creating a "fake" thread? Question 2: In Linux, since "pthread.h" is included, will SC_THREAD create a new thread? Question 3: In Windows and Linux, did I miss some settings to enable the real thread? ======================================== Following code is from this website: http://www.asic-world.com/systemc/systemc_time4.html#Example_:_sc_event #include <systemc.h> SC_MODULE (events) { sc_in<bool> clock; sc_event e1; sc_event e2; void do_test1() { while (true) { // Wait for posedge of clock wait(); cout << "@" << sc_time_stamp() <<" Starting test"<<endl; // Wait for posedge of clock wait(); cout << "@" << sc_time_stamp() <<" Triggering e1"<<endl; // Trigger event e1 e1.notify(5,SC_NS); // Wait for posedge of clock wait(); // Wait for event e2 wait(e2); cout << "@" << sc_time_stamp() <<" Got Trigger e2"<<endl; // Wait for posedge of clock wait(); cout<<"Terminating Simulation"<<endl; sc_stop(); // sc_stop triggers end of simulation } } void do_test2() { while (true) { // Wait for event e2 wait(e1); cout << "@" << sc_time_stamp() <<" Got Trigger e1"<<endl; // Wait for 3 posedge of clock wait(3); cout << "@" << sc_time_stamp() <<" Triggering e2"<<endl; // Trigger event e2 e2.notify(); } } SC_CTOR(events) { SC_CTHREAD(do_test1,clock.pos()); SC_CTHREAD(do_test2,clock.pos()); } }; int sc_main (int argc, char* argv[]) { sc_clock clock ("my_clock",1,0.5); events object("events"); object.clock (clock); sc_start(); // Run the simulation till sc_stop is encountered return 0;// Terminate simulation }
  8. Hi All, I have a case using "diamond inheritance" sc_module as below figure base / \ A B \ / top base=> struct to share A and B A => a systemc module (virtual public sc_module) B => a systemc module (virtual public sc_module) top=> a systemc module (virtual public A, virtual public B ) it work fine. But when I using SC_THREAD. the compiler shows error, "pointer to member conversion via virtual base". is it possible to fix the error? Thanks
  9. Hi, everyone, I am a starter of SystemC. I wrote a simple example with using SC_THREAD following the example in systemc source. I have two classes which boot two threads, bootMAC and respondDrv. However, when I simulate this program, I observed that only bootMAC is running, respondDrv did not print anything. Are there anything I still need to add? Thanks so much for you guys' help. The code is follows. class SYSCMAC : public sc_core::sc_module { public: SC_HAS_PROCESS(SYSCMAC); SYSCMAC(sc_module_name name) : sc_core::sc_module(name) { SC_THREAD(bootMAC); } void bootMAC() { while(true) printf("in bootMAC\n"); } }; class SYSCNETDEV : public sc_module { public: SC_HAS_PROCESS(SYSCNETDEV); SYSCNETDEV(sc_module_name name) : sc_core::sc_module(name) { SC_THREAD(respondDrv); } void respondDrv() { while(true) printf("in respondDrv\n"); } }; int sc_main(int argc, char **argv) { printf("hello world\n"); SYSCMAC *q = new SYSCMAC("mac"); SYSCNETDEV *sn = new SYSCNETDEV("qemu"); sc_start(); printf("start simulation now\n"); return 0; }
  10. Hi everyone, I'm met some problem. In box below you can see my code. struct Some_stuct { int data; float data_f; }; class payload_t { public: unsigned char *data; unsigned lenght; inline friend ostream& operator << ( ostream& os, payload_t const & v ) { os << "(" << v.data << "," << std::boolalpha << "," << v.lenght << ")"; return os; } }; SC_MODULE(tx) { sc_port<sc_fifo_out_if<payload_t> > out_port; void process() { Some_stuct data; payload_t out_data; while(true) { data.data = 5; data.data_f = 6; out_data.data = reinterpret_cast<unsigned char*>(&data); out_data.lenght = sizeof(Some_stuct); out_port->write(out_data); data.data++; data.data_f++; wait(1, SC_NS); } } SC_CTOR(tx) { SC_THREAD(process); } }; SC_MODULE(rx) { sc_port<sc_fifo_in_if<payload_t> > in_port; void process() { int realData = 0; payload_t in_data; while(true) { wait(in_port->data_written_event()); wait(171, SC_NS); in_data = in_port->read(); Some_stuct *val = reinterpret_cast<Some_stuct*>(in_data.data); cout << sc_time_stamp() << " " << val->data << " " << val->data_f << endl; } } SC_CTOR(rx) { SC_THREAD(process); } }; int sc_main(int argc, char* argv[]) { rx rx_i("rx"); tx tx_i("tx"); sc_fifo<payload_t> buf(8); tx_i.out_port(buf); rx_i.in_port(buf); sc_start(); getchar(); return 0; } I'm have two blocks: transmitter and receiver. When we call method write to fifo from transmitter, actually we will send address of our local data. And when i will read from buffer, I will receive address of transmitter local data. But if transmitter works more faster than receiver, my rx block will receive "New" data and sended data will loss. How to solve this problem? I should receive correct data
  11. Hello everyone, I have successfuly compiled SystemC-2.3.0 under VS2012. Compilation: For a system description and compilation, I had to enable static linking the following way, aside from configuring the include and library directories and the library name. Properties->configuration properties->C/C++->Code Generation Runtime Library set to Multi-threaded Debug (\MTd) After that, I was able to compile the simulation project. Execution: During execution, Windows throws an exception for the DCAST of line 359 on sc_thread_process.cpp. This is executed by the call to SC_THREAD(run) in the "CPU" constructor. The related code can be found enclosed. Console output: Error: (E549) uncaught exception: Access violation - no RTTI data! In file: c:\users\raul\documents\visual studio 2012\projects\systemc-2.3.0\src\sysc\kernel\sc_except.cpp:98 Visual Studio output: First-chance exception at 0x0135EF3F in coprocessor_func.exe: 0xC0000005: Access violation reading location 0x00000005. First-chance exception at 0x74D54B32 in coprocessor_func.exe: Microsoft C++ exception: std::__non_rtti_object at memory location 0x007EF570. First-chance exception at 0x74D54B32 in coprocessor_func.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. First-chance exception at 0x74D54B32 in coprocessor_func.exe: Microsoft C++ exception: sc_core::sc_report at memory location 0x007EE304. The program '[4260] coprocessor_func.exe' has exited with code 1 (0x1). Could this be related to the issue that dynamic cast should not be called from within a constructor because the object is not yet fully built? References: Under item 6: http://en.cppreferen...ge/dynamic_cast This is an example that I am using without issues under Linux. Any ideas of what can be going wrong? Thanks in advance, Raul Fajardo Code: #include <systemc.h> #include <iostream> using namespace std; class CoProcessor { sc_time m_process_time; public: CoProcessor() { m_process_time = sc_time(20, SC_US); } unsigned int sum(unsigned int a, unsigned int { unsigned int tmp = a + b; wait(m_process_time); return tmp; } }; class CPU : public sc_module { CoProcessor co_cpu; public: SC_HAS_PROCESS(CPU); //enables the definition of SC_THREAD or SC_METHOD (SC_METHOD has sensitivity and never ends) CPU(sc_module_name nm) : sc_module(nm) { SC_THREAD(run); //registers the function to the simulation kernel, enables wait() } void run() { unsigned int a, b, c; b = 10; c = 5; a = co_cpu.sum(b, c); cout << "Computation result of " << b << " + " << c << ": " << a << endl; cout << "Algorithm was run in " << sc_time_stamp() << endl; } }; int sc_main(int argc, char * argv[]) { CPU processor("main_processor"); sc_start(500, SC_US); //simulate for 500 microseconds return 0; }
  • Create New...