Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/src/models/memory_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ class MemoryModel extends Memory {
for (final wrPort in wrPorts) {
if (!wrPort.en.previousValue!.isValid && !storage.isEmpty) {
// storage doesnt have access to `en`, so check ourselves
storage.invalidWrite();
if (wrPort.addr.previousValue!.isValid) {
// we only need to clear that address
storage.setData(
wrPort.addr.previousValue!, LogicValue.ofInt(0, dataWidth));
storage.onInvalidWrite();
} else {
storage.invalidWrite();
}

return;
}

Expand Down
10 changes: 8 additions & 2 deletions lib/src/models/sparse_memory_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:collection/collection.dart';
import 'package:rohd/rohd.dart';
import 'package:rohd_hcl/src/exceptions.dart';
import 'package:rohd_hcl/src/utils.dart';
import 'package:rohd_vf/rohd_vf.dart';

/// A storage for memory models.
abstract class MemoryStorage {
Expand All @@ -28,8 +29,13 @@ abstract class MemoryStorage {

/// Default behavior for [onInvalidWrite].
static void _defaultOnInvalidWrite() {
// ignore: avoid_print
print('WARNING: Memory was cleared by invalid write!');
if (Test.instance != null) {
Test.instance?.logger
.warning('WARNING: Memory was cleared by invalid write!');
} else {
// ignore: avoid_print
print('WARNING: Memory was cleared by invalid write!');
}
}

/// A function called if a read is made to an address that has no data.
Expand Down
Loading