Jump to content
Sign in to follow this  
ips

LT blocking. Synch point

Recommended Posts

Hi everyone! I have model: two different initiators send data to one target.
My allocate code below

#define SC_INCLUDE_DYNAMIC_PROCESSES

#include <systemc.h>
#include <tlm.h>
#include <tlm_utils\simple_initiator_socket.h>
#include <tlm_utils\simple_target_socket.h>

SC_MODULE(Initiator) {

	tlm_utils::simple_initiator_socket<Initiator> socket;
	
	void process() {
		tlm::tlm_generic_payload *trans = new tlm::tlm_generic_payload;
		sc_time delay = sc_time(10, SC_NS);
		
		//tlm::tlm_command cmd = (tlm::tlm_command) (rand()%2);
	

		for(int i =0 ; i < 100; i++) {
			trans->set_data_ptr(reinterpret_cast<unsigned char*>(&i));
			socket->b_transport(*trans, delay);			
		}
	}

	SC_CTOR(Initiator) {
		SC_THREAD(process);
	}
};

SC_MODULE(SecondInitiator) {

	tlm_utils::simple_initiator_socket<SecondInitiator> socket;
	
	void process() {
		tlm::tlm_generic_payload *trans = new tlm::tlm_generic_payload;
		sc_time delay = sc_time(10, SC_NS);
		
		for(int i =0 ; i < 100; i++) {
			trans->set_data_ptr(reinterpret_cast<unsigned char*>(&i));
			socket->b_transport(*trans, delay);			
		}
	}

	SC_CTOR(SecondInitiator) {
		SC_THREAD(process);
	}
};

SC_MODULE(Target) {

	tlm_utils::simple_target_socket<Target> socket, socket2;

	virtual void process(tlm::tlm_generic_payload &tx, sc_time& dt) {
	  //This process should start when both initiators will send data
	}

	SC_CTOR(Target) {
		socket.register_b_transport(this, &Target::process);
		socket2.register_b_transport(this, &Target::process);
	}
};

SC_MODULE(Top) {
	Initiator		*initiator;
	SecondInitiator *secondInitiator;
	Target			*target;

	SC_CTOR(Top) {
		initiator			= new Initiator	("initiator");
		target				= new Target	("target");
		secondInitiator		= new SecondInitiator("second initiator");

		initiator->socket.bind(target->socket);
		secondInitiator->socket.bind(target->socket2);
	}
};

int sc_main(int argc, char* argv[]) {
  Top top("top");
  sc_start();

  getchar();
  return 0;
}

Question:
How to implement synch point - start target behavior process only when both initiator will send the data. Target should has only one behavioral process

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...