|
Simo 0.0.1
|
This document explains basic principle of ports of Simo and how to use them in SimoSim.
Ports allow to create connections between modules. The class Simo::Port is a templated class and it is the base class. Any protocol can be built on top of it. To create a new port class, it is required to implement is the bool connect(Port* other) method in the subclass. This method is called when two ports are connected together and this is what SimoSim uses to connect the ports.
Some templated implementations are already provided in the library to ease integration:
Look at Simo/port/Port.h for the implementation of these classes. Here below a recap of the methods that Simo::BidirectionalPort<T> provides:
No specific protocol is enforced and both sides of the port can remove the payload anytime. This is a design choice to allow more flexibility.
The configuration file of SimoSim allows to connect using the connections section. Look at system_config.yaml for an example:
Here ping_module and pong_module both expose a port named port, and these two are connected together. Look at tests/collection/PingPongCollection.cc for the implementation of these modules and how the ports are defined. Inside a module, a port can be created with the Simo::Module::create_port<{Port-Class}>({port_name}) method.
To run this example, you need the PingPongCollection. This is built by default when Simo is built. To run the example, use the following command: