Nexer8 / Producer_Consumer_SystemC

A solution of the producer-consumer problem using SystemC.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Producer-Consumer problem in SystemC

Introduction

Task involves creating an app from scratch using SystemC library.

App should implement the standard producer-consumer problem where it is possible to have multiple consumers. Producer and consumers should be connected with the sc_fifo channel.

Producer should

  • generate random integer (from 1,30 range) every p cycles and send it to the consumer(s)
  • generate 1000 transactions
  • in case of multiple consumers, feed the consumers according to the writing policy - Round Robin or Load Balancing

Consumer should

  • read the input number from the producer and wait for input cycles
  • print the received input number

Results

Round RobinLoad Balancing
#cycles per wait #consumers simulation time [ps]
1 1 105882
1 10 19984
30 1 3.00588e+06
30 10 309984
#cycles per wait #consumers simulation time [ps]
1 1 105882
1 10 10601
30 1 3.00588e+06
30 10 300978

Conclusions

It is easy to spot that there is no difference in the simulation time when there is only one consumer regardless of the arbitration. That is caused by the fact that there is no way to shorten the waiting time for the consumer to become ready to receive a new message.

However, the higher the number of consumers, the more visible the difference in the simulation time happens to occur. Due to the fact that with Load Balancing the system performs the wait only when all of the consumers are busy processing messages, it was feasible to save some time that would be lost by the waits forcing the sequential order using the Round Robin arbitration.

About

A solution of the producer-consumer problem using SystemC.


Languages

Language:C++ 91.1%Language:CMake 8.9%