createModule method

  1. @override
Module createModule()
override

Creates a Module instance as configured.

Implementation

@override
Module createModule() {
  if (entryCountKnob.value < 2) {
    throw RohdHclException(
        'A configurable CAM requires at least two entries.');
  }
  if (lookupPortCountKnob.value < 1) {
    throw RohdHclException('A CAM requires at least one lookup port.');
  }
  if (writePortCountKnob.value < 0) {
    throw RohdHclException(
        'A CAM cannot have a negative number of write ports.');
  }

  final indexWidth = log2Ceil(entryCountKnob.value);
  final writePorts = List<TagInterface>.generate(writePortCountKnob.value,
      (_) => TagInterface(indexWidth, tagWidthKnob.value));
  final lookupPorts = List<TagInterface>.generate(lookupPortCountKnob.value,
      (_) => TagInterface(indexWidth, tagWidthKnob.value));

  return Cam(
    Logic(),
    Logic(),
    writePorts,
    lookupPorts,
    numEntries: entryCountKnob.value,
    enableValidTracking: validTrackingKnob.value,
  );
}