readPort method
- List<
LogicValue> storage, { - required bool? enable,
- required int? address,
Reads a combinationally addressed register file the way hardware does.
Implementation
@protected
LogicValue readPort(
List<LogicValue> storage, {
required bool? enable,
required int? address,
}) {
final width = storage.first.width;
if (enable == false) {
return LogicValue.filled(width, LogicValue.zero);
}
if (enable == null || address == null) {
return LogicValue.filled(width, LogicValue.x);
}
return address < storage.length
? storage[address]
: LogicValue.filled(width, LogicValue.zero);
}