-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
556 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,13 @@ | ||
# Ready/Valid BFM | ||
|
||
The Ready/Valid BFM is a collection of [ROHD-VF](https://github.com/intel/rohd-vf) components and objects that are helpful for validating hardware that contains interfaces that use a ready/valid protocol. To summarize: | ||
|
||
- When a transmitter has something to send, it raises `valid`. | ||
- When a receiver is able to accept something, it raises `ready`. | ||
- When both `valid` and `ready` are high, the transaction is accepted by both sides. | ||
|
||
The main two components are the `ReadyValidTransmitterAgent` and `ReadyValidReceiverAgent`, which transmit and receive `data`, respectively. Any bundle of information can be mapped onto the `data` bus. Both agents provide a `blockRate` argument which controls a random weighted chance of preventing a transaction from occuring (either delaying a `valid` or dropping a `ready`). | ||
|
||
Additionally, the `ReadyValidMonitor` can be placed on any ready/valid protocol to observe transactions that are accepted. The resulting `ReadyValidPacket`s can also be logged via the `ReadyValidTracker`. | ||
|
||
The unit tests in `ready_valid_bfm_test.dart`, which have a transmitter and receiver agent talking to each other, can serve as a good example of how to use these components. |
This file contains 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// Copyright (C) 2023-2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
export 'apb_bfm/apb_bfm.dart'; | ||
export 'memory_model.dart'; | ||
export 'ready_valid_bfm/ready_valid_bfm.dart'; | ||
export 'sparse_memory_storage.dart'; |
This file contains 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,40 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// ready_valid_agent.dart | ||
// A generic agent for ready/valid protocol. | ||
// | ||
// 2024 January 5 | ||
// Author: Max Korbel <[email protected]> | ||
|
||
import 'package:rohd/rohd.dart'; | ||
import 'package:rohd_vf/rohd_vf.dart'; | ||
|
||
/// A generic agent for ready/valid protocol. | ||
abstract class ReadyValidAgent extends Agent { | ||
/// The clock. | ||
final Logic clk; | ||
|
||
/// Active-high reset. | ||
final Logic reset; | ||
|
||
/// Ready signal. | ||
final Logic ready; | ||
|
||
/// Valid signal. | ||
final Logic valid; | ||
|
||
/// Data being transmitted. | ||
final Logic data; | ||
|
||
/// Creates a new agent. | ||
ReadyValidAgent({ | ||
required this.clk, | ||
required this.reset, | ||
required this.ready, | ||
required this.valid, | ||
required this.data, | ||
required Component? parent, | ||
String name = 'readyValidComponent', | ||
}) : super(name, parent); | ||
} |
This file contains 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,10 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
export 'ready_valid_agent.dart'; | ||
export 'ready_valid_monitor.dart'; | ||
export 'ready_valid_packet.dart'; | ||
export 'ready_valid_receiver_agent.dart'; | ||
export 'ready_valid_tracker.dart'; | ||
export 'ready_valid_transmitter_agent.dart'; | ||
export 'ready_valid_transmitter_driver.dart'; |
This file contains 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,60 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// ready_valid_monitor.dart | ||
// A monitor for ready/valid protocol. | ||
// | ||
// 2024 January 5 | ||
// Author: Max Korbel <[email protected]> | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:rohd/rohd.dart'; | ||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
import 'package:rohd_vf/rohd_vf.dart'; | ||
|
||
/// A [Monitor] for ready/valid protocol. | ||
class ReadyValidMonitor extends Monitor<ReadyValidPacket> { | ||
/// The clock. | ||
final Logic clk; | ||
|
||
/// Active-high reset. | ||
final Logic reset; | ||
|
||
/// Ready signal. | ||
final Logic ready; | ||
|
||
/// Valid signal. | ||
final Logic valid; | ||
|
||
/// Data being transmitted. | ||
final Logic data; | ||
|
||
/// Creates a new [ReadyValidMonitor]. | ||
ReadyValidMonitor({ | ||
required this.clk, | ||
required this.reset, | ||
required this.ready, | ||
required this.valid, | ||
required this.data, | ||
required Component? parent, | ||
String name = 'readyValidMonitor', | ||
}) : super(name, parent); | ||
|
||
@override | ||
Future<void> run(Phase phase) async { | ||
unawaited(super.run(phase)); | ||
|
||
await reset.nextNegedge; | ||
|
||
clk.posedge.listen((event) { | ||
if (!ready.previousValue!.isValid || !valid.previousValue!.isValid) { | ||
logger.severe('Both ready and valid must be valid for protocol,' | ||
' but found ready=${ready.value} and valid=${valid.value}'); | ||
} else if (ready.previousValue!.toBool() && | ||
valid.previousValue!.toBool()) { | ||
add(ReadyValidPacket(data.previousValue!)); | ||
} | ||
}); | ||
} | ||
} |
This file contains 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,33 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// ready_valid_packet.dart | ||
// A monitor for ready/valid protocol. | ||
// | ||
// 2024 January 5 | ||
// Author: Max Korbel <[email protected]> | ||
|
||
import 'package:rohd/rohd.dart'; | ||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
import 'package:rohd_vf/rohd_vf.dart'; | ||
|
||
/// A packet to be transmitted over a ready/valid interface. | ||
class ReadyValidPacket extends SequenceItem implements Trackable { | ||
/// The data associated with this packet. | ||
final LogicValue data; | ||
|
||
/// Constructs a new packet with associated [data]. | ||
ReadyValidPacket(this.data); | ||
|
||
@override | ||
String? trackerString(TrackerField field) { | ||
switch (field.title) { | ||
case ReadyValidTracker.timeField: | ||
return Simulator.time.toString(); | ||
case ReadyValidTracker.dataField: | ||
return data.toString(); | ||
} | ||
|
||
return null; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
lib/src/models/ready_valid_bfm/ready_valid_receiver_agent.dart
This file contains 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,57 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// ready_valid_receiver_agent.dart | ||
// An agent for receiving over a ready/valid protocol. | ||
// | ||
// 2024 January 5 | ||
// Author: Max Korbel <[email protected]> | ||
|
||
import 'dart:async'; | ||
import 'dart:math'; | ||
|
||
import 'package:rohd/rohd.dart'; | ||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
import 'package:rohd_vf/rohd_vf.dart'; | ||
|
||
/// An [Agent] for receiving over a ready/valid protocol. | ||
class ReadyValidReceiverAgent extends ReadyValidAgent { | ||
/// Probability (from 0 to 1) of blocking a ready from being driven. | ||
/// | ||
/// 0 -> never block, accept transactions as soon as possible. | ||
final double blockRate; | ||
|
||
/// Creates an [Agent] for receiving over a ready/valid protocol. | ||
ReadyValidReceiverAgent({ | ||
required super.clk, | ||
required super.reset, | ||
required super.ready, | ||
required super.valid, | ||
required super.data, | ||
required super.parent, | ||
this.blockRate = 0, | ||
super.name = 'readyValidReceiverAgent', | ||
}); | ||
|
||
@override | ||
Future<void> run(Phase phase) async { | ||
unawaited(super.run(phase)); | ||
|
||
final random = Test.random ?? Random(); | ||
|
||
await _drive(LogicValue.zero); | ||
|
||
await reset.nextNegedge; | ||
|
||
while (!Simulator.simulationHasEnded) { | ||
final doBlock = random.nextDouble() < blockRate; | ||
|
||
await _drive(doBlock ? LogicValue.zero : LogicValue.one); | ||
} | ||
} | ||
|
||
Future<void> _drive(LogicValue newReady) async { | ||
ready.inject(newReady); | ||
await clk.nextPosedge; | ||
} | ||
} |
This file contains 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,24 @@ | ||
import 'package:rohd_hcl/src/models/models.dart'; | ||
import 'package:rohd_vf/rohd_vf.dart'; | ||
|
||
/// A tracker for a ready/valid protocol. | ||
class ReadyValidTracker extends Tracker<ReadyValidPacket> { | ||
/// Tracker field for simulation time. | ||
static const timeField = 'time'; | ||
|
||
/// Tracker field for data. | ||
static const dataField = 'data'; | ||
|
||
/// Creates a new tracker for a ready/valid protocol. | ||
ReadyValidTracker({ | ||
String name = 'readyValidTracker', | ||
super.dumpJson, | ||
super.dumpTable, | ||
super.outputFolder, | ||
int timeColumnWidth = 12, | ||
int dataColumnWidth = 14, | ||
}) : super(name, [ | ||
TrackerField(timeField, columnWidth: timeColumnWidth), | ||
TrackerField(dataField, columnWidth: dataColumnWidth), | ||
]); | ||
} |
45 changes: 45 additions & 0 deletions
45
lib/src/models/ready_valid_bfm/ready_valid_transmitter_agent.dart
This file contains 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,45 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// ready_valid_transmitter_agent.dart | ||
// An agent for transmitting over a ready/valid protocol. | ||
// | ||
// 2024 January 5 | ||
// Author: Max Korbel <[email protected]> | ||
|
||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
import 'package:rohd_vf/rohd_vf.dart'; | ||
|
||
/// An [Agent] for transmitting over a ready/valid protocol. | ||
class ReadyValidTransmitterAgent extends ReadyValidAgent { | ||
/// The [Sequencer] to send [ReadyValidPacket]s into. | ||
late final Sequencer<ReadyValidPacket> sequencer; | ||
|
||
/// Creates an [Agent] for transmitting over a ready/valid protocol. | ||
/// | ||
/// The [blockRate] is the probability (from 0 to 1) of blocking a valid from | ||
/// being driven. | ||
ReadyValidTransmitterAgent({ | ||
required super.clk, | ||
required super.reset, | ||
required super.ready, | ||
required super.valid, | ||
required super.data, | ||
required super.parent, | ||
double blockRate = 0, | ||
super.name = 'readyValidTransmitterAgent', | ||
}) { | ||
sequencer = Sequencer<ReadyValidPacket>('sequencer', this); | ||
|
||
ReadyValidTransmitterDriver( | ||
clk: clk, | ||
reset: reset, | ||
ready: ready, | ||
valid: valid, | ||
data: data, | ||
sequencer: sequencer, | ||
blockRate: blockRate, | ||
parent: this, | ||
); | ||
} | ||
} |
Oops, something went wrong.