CsrBlockBinding constructor

CsrBlockBinding({
  1. required CsrBlockConfig config,
  2. required Logic clk,
  3. required Logic reset,
  4. required DataPortInterface<Logic>? frontWrite,
  5. required DataPortInterface<Logic>? frontRead,
  6. bool allowLargerRegisters = false,
  7. int logicalRegisterIncrement = 1,
  8. BigInt? wideLogicalRegisterIncrement,
  9. BigInt? addressExtent,
  10. bool asyncReset = false,
  11. CsrImplementationConfiguration? implementationConfiguration,
  12. bool reserveName = false,
  13. bool reserveDefinitionName = false,
  14. String? definitionName,
})

Constructs one block using an explicit or scoped implementation policy.

Frontdoor and raw model addresses are relative to the block, irrespective of config's base address. Software hardware selections use block/register names, as in CsrTop.

Implementation

factory CsrBlockBinding({
  required CsrBlockConfig config,
  required Logic clk,
  required Logic reset,
  required DataPortInterface? frontWrite,
  required DataPortInterface? frontRead,
  bool allowLargerRegisters = false,
  int logicalRegisterIncrement = 1,
  BigInt? wideLogicalRegisterIncrement,
  BigInt? addressExtent,
  bool asyncReset = false,
  CsrImplementationConfiguration? implementationConfiguration,
  bool reserveName = false,
  bool reserveDefinitionName = false,
  String? definitionName,
}) {
  final implementation =
      implementationConfiguration ?? CsrImplementationScope.current;
  if (implementation.implementation == CsrImplementation.rtl) {
    if (implementation.hardwareRegisters != null) {
      throw ArgumentError('Selective CSR hardware exposure requires '
          'software implementation.');
    }
    final block = CsrBlock(
      config: config,
      clk: clk,
      reset: reset,
      frontWrite: frontWrite,
      frontRead: frontRead,
      allowLargerRegisters: allowLargerRegisters,
      logicalRegisterIncrement: logicalRegisterIncrement,
      wideLogicalRegisterIncrement: wideLogicalRegisterIncrement,
      addressExtent: addressExtent,
      asyncReset: asyncReset,
      reserveName: reserveName,
      reserveDefinitionName: reserveDefinitionName,
      definitionName: definitionName,
    );
    return CsrBlockBinding._(block, null, block.getBackdoorPortsByName,
        block.getBackdoorPortsByBigIntAddr);
  }
  final block = CsrBlockModel(
    config: config,
    clk: clk,
    reset: reset,
    frontWrite: frontWrite,
    frontRead: frontRead,
    allowLargerRegisters: allowLargerRegisters,
    logicalRegisterIncrement: logicalRegisterIncrement,
    wideLogicalRegisterIncrement: wideLogicalRegisterIncrement,
    addressExtent: addressExtent,
    asyncReset: asyncReset,
    hardwareRegisters: implementation.hardwareRegisters,
    reserveName: reserveName,
    reserveDefinitionName: reserveDefinitionName,
    definitionName: definitionName,
  );
  return CsrBlockBinding._(block, block.model, block.getBackdoorPortsByName,
      block.getBackdoorPortsByBigIntAddr);
}