-
Notifications
You must be signed in to change notification settings - Fork 22
Doc publisher-subscriber package #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
IstvanZsSzekely
wants to merge
5
commits into
main
Choose a base branch
from
doc_pub_sub
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
beb3b87
scoreboard: Simplified to AXIS data packet verification
IstvanZsSzekely 23619e6
docs: Publisher-subscriber package
IstvanZsSzekely e67bce5
docs: Publisher-subscriber package - diagrams
IstvanZsSzekely a3a674b
docs: Publisher-subscriber package - removed filter and processing mo…
IstvanZsSzekely 49817a8
Update docs/library/utilities/pub_sub/publisher.rst
IstvanZsSzekely File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,5 +8,6 @@ Contents | |
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
| :glob: | ||
|
|
||
| Test Harness <test_harness/index> | ||
| */index | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| .. _pub_sub: | ||
|
|
||
| Publisher-Subscriber package | ||
| ================================================================================ | ||
|
|
||
| .. toctree:: | ||
| :hidden: | ||
|
|
||
| Publisher <publisher> | ||
| Subscriber <subscriber> | ||
|
|
||
| The publisher-subscriber package is a collection of small packages that are used | ||
| inside VIP monitors, scoreboards and checkers. | ||
|
|
||
| Contents | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| #. :ref:`publisher`: Class that publishes new data arrived in the monitor | ||
| #. :ref:`subscriber`: Class that receives new data published |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| .. _publisher: | ||
|
|
||
| Publisher | ||
| ================================================================================ | ||
|
|
||
| Overview | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| This class is designed to manage a list of subscribers, has the ability to | ||
| notify subscribers with the received data. The class is parameterized with a | ||
| ``data_type``. It is mainly used in VIP monitors, but it can also be integrated | ||
| in other environments as well. | ||
|
|
||
| .. svg:: library/utilities/pub_sub/publisher.svg | ||
| :align: center | ||
|
|
||
| Variables | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| None are available for direct external access. | ||
|
|
||
| Functions | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| function new(input string name, input adi_component parent = null); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| The class constructor function initializes the object with the provided name and | ||
| parent component. | ||
|
|
||
| function void subscribe(input adi_subscriber #(data_type) subscriber); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| The subscribe function adds a subscriber to the subscriber_list if it does not | ||
| already exist. Gives an error message, if the subscriber is already added to the | ||
| list. | ||
|
|
||
| function void unsubscribe(input adi_subscriber #(data_type) subscriber); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| The unsubscribe function removes a subscriber if it exists in the list. | ||
|
|
||
| function void notify(input adi_fifo #(data_type) data); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| The notify function is responsible for notifying all subscribers with the data. | ||
|
|
||
| Usage and recommendations | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| Basic usage of the publisher: | ||
|
|
||
| * Declare the publisher and create an instance | ||
| * Use the subscribe function to add subscribers to the list | ||
| * Create a packet that needs to be published | ||
| * Call the notify function to publish the packet | ||
| * Unsubscribe the subscribed modules if needed | ||
|
|
||
| .. important:: | ||
|
|
||
| The publisher and subscriber modules must operate on the same data type. | ||
|
|
||
| .. include:: ../../../common/support.rst | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Classes | ||
|
|
||
| # Base | ||
| adi_reporter: {shape: class} | ||
| adi_component: {shape: class} | ||
|
|
||
| # Components | ||
| adi_publisher: { | ||
| shape: class | ||
| \#subscriber_list | ||
| +subscribe() | ||
| +unsubscribe() | ||
| +notify() | ||
| } | ||
| adi_subscriber: {shape: class} | ||
|
|
||
| # Inheritances | ||
|
|
||
| # Base | ||
| adi_reporter <- adi_component: {shape: triangle; source-arrowhead.style.filled: false} | ||
|
|
||
| # Components | ||
| adi_component <- adi_publisher: {shape: triangle; source-arrowhead.style.filled: false} | ||
|
|
||
| # Aggregations | ||
|
|
||
| # Components | ||
| adi_publisher <- adi_subscriber: {source-arrowhead: * {shape: diamond; style.filled: true}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| .. _subscriber: | ||
|
|
||
| Subscriber | ||
| ================================================================================ | ||
|
|
||
| Overview | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| This class is designed to be used in conjunction with a publisher class. The | ||
| class is parameterized with a data_type. It is mainly used in scoreboard and | ||
| checker classes which need data inputs from various other modules. | ||
|
|
||
| .. important:: | ||
|
|
||
| The subscriber base class must be inherited and a new implementation must be | ||
| written in a subclass. | ||
|
|
||
| .. svg:: library/utilities/pub_sub/subscriber.svg | ||
| :align: center | ||
|
|
||
| Variables | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| It has a variable ID that is public, which is used to identify the current | ||
| instance. It is also used by the publisher when adding/removing the subscribing | ||
| class to/from the list. | ||
|
|
||
| Functions | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| function new(input string name, input adi_component parent = null); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| The class constructor function initializes the object with the provided name and | ||
| parent component. A static variable is counting the number of subscribers that | ||
| have been created up until this point, this ensures that all subscribers receive | ||
| a unique identification number. | ||
|
|
||
| virtual function void update(input adi_fifo #(data_type) data); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| This function is intended to be overridden by subclasses. When a publisher has | ||
| new data, it calls each subscriber's update function, which ensures that each | ||
| implementation will use the published data in the way it was intended to be used | ||
| in the class where the subscriber is instantiated. | ||
|
|
||
| Usage and recommendations | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| Basic usage of the subscriber: | ||
|
|
||
| * Create a subscriber subclass | ||
| * Implement the update function | ||
| * Add extra functionality if needed | ||
| * Subscribe to the publisher | ||
| * Unsubscribe from the publisher | ||
|
|
||
| .. important:: | ||
|
|
||
| The publisher and subscriber modules must operate on the same data type. | ||
|
|
||
| .. include:: ../../../common/support.rst |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.