[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6. Port

Port manages connection and packet transfer between units. It includes port class which represents shared wires for multiple inputs/outputs, and virtual_channel_input and virtual_channel_output class representing a virtual channel.

6.1 port class  
6.2 bus_port_base class  
6.3 bus_port class  
6.4 virtual_channel_input class  
6.5 virtual_channel_output class  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1 port class

port class is used for connection between classes representing hardware. By connecting multiple ports, a path which can share all connecting ports is generated. When a packet is transferred to a port, the packet can be got or referred by all connected ports.

For simulating the situation that a wire is occupied with a port, a unique identifier is assigned automatically. If requests conflict, arbitration is performed according to the specified algorithm based on port ID, and the owner is selected. After using the path, the owner release the ownership.

A unique transaction ID is automatically assigned to a sequence of packet transfer. The ID is updated when the owner is changed. The arbitrary ID can be specified. This ID is also used for split transaction.

The path can hold multiple arbiters. If not specified, a single arbiter can be used. By using multiple arbiters multiple owners can be treated.

6.1.1 port class definition  
6.1.2 Sending packet  
6.1.3 Port ownership  
6.1.4 Using port class  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1.1 port class definition

bool is_connected(void) const
Returns true if the port is connected.

bool is_connected(const port&) const
Returns true if the port is connected to the specified port.

bool have_packet(void) const
Returns true if a packet exists on the path.

void connect(port&)
Connects to the specified port.

void disconnect(port&)
Disconnects from the specified port. If it is not connected, do nothing.

void disconnect(void)
Disconnects from the path. If it is not connected, do nothing.

void put(packet*)
Sends packet. If a packet exists already on the path, a new packet is overwritten.

packet* get(void)
Receives the packet on the path, and remove it. If there is no packet, NULL is returned.

void clear(void)
Removes a packet on the path.

const packet* look(void) const
Refers the packet on the path. If there is no packet, NULL is returned.

bool is_connected_to_asynchronous_unit(void) const
Returns true if the port is connected to an asynchronous unit.

bool is_connected_to_asynchronous_unit(const asynchronous_unit&) const
Returns true if the port is connected to the specified asynchronous unit.

void connect_to_asynchronous_unit(asynchronous_unit&)
Connects to the specified asynchronous unit.

void disconnect_asynchronous_unit(void)
Disconnects from an asynchronous unit. If it is not connected, do nothing.

int id(void) const
Returns the ID of the port.

void set_id(int)
Sets the ID of the port.

bool is_owned(int = 0) const
Returns true if the port of the specified arbiter is owned by the other port.

bool is_owner(int = 0) const
Returns true if the port of the specified arbiter is owned by itself.

void request_ownership(int = 0)
Requests the ownership of the specified arbiter.

void release_ownership(int = 0)
Releases the ownership of the specified arbiter.

int transaction_id(void) const
Returns the current transaction ID.

void set_transaction_id(int)
Set the transaction ID.

void set_number_of_arbiter(int)
Set the number of arbiter.

virtual bool compete(int, int) const
This function supports arbitration algorithm. The first parameter shows the previous owner ID, and the second parameter shows the competitor ID. Arbitration is performed between own ID and parameters. True is returned for winner, and false for looser.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1.2 Sending packet

Packet is sent according to the following procedures. Here, an exclusive operation for the path is not performed. For an exclusive operation, an ownership must be obtained for sending/receiving packets. See section 6.1.3 Port ownership.

  1. Packet is generated with operator new.

  2. Insert a packet to the input port. Return the pointer to the input port. use put member function. After that, handling of packet is done by the port, the user cannot touch it.

  3. Check whether the packet can be received or not using have_packet function.

  4. Refer the packet from output port using look member function. If the packet has been sent, it can be referred. The packet which is not required at that point, it is not needed to be received. Note that the unreceived packet is left in the port until overwritten by the succeeding packets.

  5. Receiving packets from output port using get member function. If the packet has been sent, it can be received. Actually, the pointer is received. The receiving user must release the packet after using the information.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1.3 Port ownership

Port ownership.

Multiple processors try to write the shared bus simultaneously in the system which connects multiple processors to a single bus. This access conflict must be solved with exclusive operation. Each port provides the ownership for the exclusion.

A unique ID is automatically assigned into connected ports each other. For obtaining the ownership, a port requests to the path. If multiple requests conflict, arbitration is done with the specified arbitration algorithm, and the owner is selected. After using the path, the owner release its ownership. Arbitration algorithm is implemented with compete virtual function, and users can modify it freely. Default algorithm is round-robin.

To get the ownership, the following steps are required. Note that requesting and releasing of the ownership must be done in the output phase, while checking state must be done in the input phase.

  1. In an output phase, request the ownership with request_ownership function.

  2. In the next input phase, check whether it has ownership with is_owner function. If it does not get an ownership, request it again in an output phase.

  3. If it got the ownership, execute the critical section.

  4. After executing the critical section, release the ownership with release_ownership function.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1.4 Using port class

As an example of using port class, a program of bus_packet communicates between two ports is shown.

 
#include <isis/isis.h>

int main(void)
{
    port a, b;
    a.connect(b);
    packet* pkt = new bus_packet<int>;
    ((bus_packet<int>*)(pkt))->address() = 100;
    a.put(pkt);
    pkt = b.get();
    ((bus_packet<int>*)(pkt))->address()++;
    b.put(pkt);
    pkt = a.get();
    cout << *pkt << endl;
    delete pkt;
    return 0;
}

  1. Create port a and port b, and connect them.

  2. Generate a packet which represents an address 100, and send it.

  3. Send the packet to port a, and receive it from b.

  4. Increment the address of the received packet, and send it to port b.

  5. Receive the packet and show its value.

  6. Delete the packet.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.2 bus_port_base class

bus_port_base class is a class for bus interfaces. An actual bus is implemented as a derived class of port class and bus_packet_base class, but it is cumbersome job to access them directly. bus_port_base class is prepared in order to hide this complexity. See section 5.2 bus_packet_base class.

This class only prepares the interface of the abstract class bus_packet_base. So packet generation function is not prepared. See section 6.3 bus_port class.

const packet_type* look(void) const
Refers the packet on the bus directly.

address_type address(void) const
Refers the address.

data_type data(void) const
Refers the data.

int total_packet_count(void) const
Refers the number of data packets in the burst transfer. For example, return value of four words continuous transfer is four.

int packet_number(void) const
Refers the packet ID in the burst transfer. The second word transfer in the four words burst transfer returns value 1 (Packet ID is 0 origin).

bool is_single(void) const
Returns true if the mode is single word transaction.

bool is_multi(void) const
Returns true if the mode is multiple word transaction.

bool is_ready(void) const
Returns true if a packet does not exist on the bus.

bool is_read(void) const
Returns true if a read packet exists on the bus.

bool is_write(void) const
Returns true if a write packet exists on the bus.

bool is_request(void) const
Returns true if a request packet exists on the bus.

bool is_grant(void) const
Returns true if a grant packet exists on the bus.

bool is_ack(void) const
Returns true if a ack packet exists on the bus.

bool is_nack(void) const
Returns true if a nack packet exists on the bus.

bool is_data(void) const
Returns true if a data packet exists on the bus.

bool is_read_request(void)
Returns true if a read_request packet exists on the bus.

bool is_read_grant(void) const
Returns true if a read_grant packet exists on the bus.

bool is_read_ack(void) const
Returns true if a read_ack packet exists on the bus.

bool is_read_nack(void) const
Returns true if a read_nack packet exists on the bus.

bool is_read_data(void) const
Returns true if a read_data packet exists on the bus.

bool is_write_request(void)
Returns true if a write_request packet exists on the bus.

bool is_write_grant(void) const
Returns true if a write_grant packet exists on the bus.

bool is_write_ack(void) const
Returns true if a write_ack packet exists on the bus.

bool is_write_nack(void) const
Returns true if a write_nack packet exists on the bus.

bool is_write_data(void) const
Returns true if a write_data packet exists on the bus.

bool is_single_read_request(void) const
Returns true if a single word read_request packet exists on the bus.

bool is_single_read_grant(void) const
Returns true if a single word read_grant packet exists on the bus.

bool is_single_read_ack(void) const
Returns true if a single word read_ack packet exists on the bus.

bool is_single_read_nack(void) const
Returns true if a single word read_nack packet exists on the bus.

bool is_single_read_data(void) const
Returns true if a single word read_data packet exists on the bus.

bool is_single_write_request(void) const
Returns true if a single word write_request packet exists on the bus.

bool is_single_write_grant(void) const
Returns true if a single word write_grant packet exists on the bus.

bool is_single_write_ack(void) const
Returns true if a single word write_ack packet exists on the bus.

bool is_single_write_nack(void) const
Returns true if a single word write_nack packet exists on the bus.

bool is_single_write_data(void) const
Returns true if a single word write_data packet exists on the bus.

bool is_multi_read_request(void) const
Returns true if a multiple word read_request packet exists on the bus.

bool is_multi_read_grant(void) const
Returns true if a multiple word read_grant packet exists on the bus.

bool is_multi_read_ack(void) const
Returns true if a multiple word read_ack packet exists on the bus.

bool is_multi_read_nack(void) const
Returns true if a multiple word read_nack packet exists on the bus.

bool is_multi_read_data(void) const
Returns true if a multiple word read_data packet exists on the bus.

bool is_multi_write_request(void) const
Returns true if a multiple word write_request packet exists on the bus.

bool is_multi_write_grant(void) const
Returns true if a multiple word write_grant packet exists on the bus.

bool is_multi_write_ack(void) const
Returns true if a multiple word write_ack packet exists on the bus.

bool is_multi_write_nack(void) const
Returns true if a multiple word write_nack packet exists on the bus.

bool is_multi_write_data(void) const
Returns true if a multiple word write_data packet exists on the bus.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3 bus_port class

bus_port class is a class for an interface of bus consisting of bus_packet class. It is a derived class of bus_port_base class, and the packet sending functions are added. See section 6.2 bus_port_base class.

void send_single_read_request(address_type)
Issues a single word read_request. The first argument is the address.

void send_single_read_grant(void)
Issues a single word read_grant.

void send_single_read_ack(void)
Issues a single word read_ack.

void send_single_read_nack(void)
Issues a single word read_nack.

void send_single_read_data(data_type)
Issues a single word read_data. The first argument is the data.

void send_single_write_request(address_type)
Issues a single word write_request. The first argument is the address.

void send_single_write_grant(void)
Issues a single word write_grant.

void send_single_write_ack(void)
Issues a single word write_ack.

void send_single_write_nack(void)
Issues a single word write_nack.

void send_single_write_data(data_type)
Issues a single word write_data. The first argument is the data.

void send_multi_read_request(address_type, unsigned int)
Issues a multiple word read_request. The first argument is the address, and the second argument is the number of transferred words.

void send_multi_read_grant(void)
Issues a multiple word read_grant.

void send_multi_read_ack(void)
Issues a multiple word read_ack.

void send_multi_read_nack(void)
Issues a multiple word read_nack.

void send_multi_read_data(data_type, unsigned int, unsigned int)
Issues a multiple word read_data. The first argument is the data, and the second argument is the index number of the data.

void send_multi_write_request(address_type, unsigned int)
Issues a multiple word write_request. The first argument is the address, and the second argument is the number of transferred words.

void send_multi_write_grant(void)
Issues a multiple word write_grant.

void send_multi_write_ack(void)
Issues a multiple word write_ack.

void send_multi_write_nack(void)
Issues a multiple word write_nack.

void send_multi_write_data(data_type, unsigned int, unsigned int)
Issues a multiple word write_data. The first argument is the data and the second argument is the number of transferred words, and the third argument is the index number of the data.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.4 virtual_channel_input class

virtual_channel_input class represents an input port of a virtual channel. Combined with an object of virtual channel output class, a virtual channel is realized. Specified number of the path for virtual packets are generated. Each channel has a specified size of queue, and stores a certain number of packets. It also support handshake function. See section 6.5 virtual_channel_output class.

6.4.1 virtual_channel_input class definition  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.4.1 virtual_channel_input class definition

virtual_channel_input(void)
Creates an input virtual channel with channel number 0 and inner buffer size 0.

virtual_channel_input(size_t a, size_t b)
Creates an input virtual channel with channel number a and inner buffer size b.

bool is_connected(void)
Returns true if the channel is connected to an output virtual channel.

bool is_connected(const virtual_channel_output&)
Returns true if the channel is connected to specified output virtual channel.

void connect(virtual_channel_output&)
Connects to specified output virtual channel.

void disconnect(void)
Disconnects from an output virtual channel.

size_t channel_size(void) const
Returns the number of virtual channels.

size_t buffer_size(void) const
Returns the size of inner buffers.

void channel_resize(size_t)
Changes the number of virtual channels.

void buffer_resize(size_t)
Changes the size of inner buffers.

bool empty(size_t)
Returns true if specified inner buffer is empty.

bool full(size_t)
Returns true if specified inner buffer is full.

size_t length(size_t)
Returns the number of packets in specified inner buffer.

packet* get(size_t)
Gets the packet from specified inner buffer.

const packet* look(size_t)
Refers the header packet of specified inner buffer.

void del(size_t)
Removes the header packet of specified inner buffer.

void clear(size_t)
Clears specified inner buffer.

void clear(void)
Clears all inner buffers.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.5 virtual_channel_output class

virtual_channel_output class represents an output port of a virtual channel. Combined with an object of virtual_channel_input class, virtual channel is realized. See section 6.4 virtual_channel_input class.

6.5.1 virtual_channel_output class definition  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.5.1 virtual_channel_output class definition

virtual_channel_output(void)
Creates an output virtual channel.

bool is_connected(void)
Returns true if the channel is connected to an input virtual channel.

bool is_connected(const virtual_channel_input&)
Returns true if the channel is connected to specified input virtual channel.

void connect(virtual_channel_input&)
Connects to specified input virtual channel.

void disconnect(void)
Disconnects from an input virtual channel.

size_t channel_size(void) const
Returns the number of virtual channels.

size_t buffer_size(void) const
Returns the size of inner buffers.

void channel_resize(size_t)
Changes the number of virtual channels.

void buffer_resize(size_t)
Changes the size of inner buffers.

bool empty(size_t)
Returns true if specified inner buffer is empty.

bool full(size_t)
Returns true if specified inner buffer is full.

size_t length(size_t)
Returns the number of packets in specified inner buffer.

void put(size_t, packet*)
Puts specified packet to specified inner buffer. The first argument is the packet and the second argument is the buffer.

const packet* look(size_t) const
Refers the header packet of specified inner buffer.

void clear(size_t)
Clears specified inner buffer.

void clear(void)
Clears all inner buffers.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Masaki WAKABAYASHI on September, 3 2003 using texi2html