text: /*
   * Copyright (c) 2005-2021 Imperas Software Ltd., www.imperas.com
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *   http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
   * either express or implied.
   *
   * See the License for the specific language governing permissions and
   * limitations under the License.
   *
   */
  
  
  ////////////////////////////////////////////////////////////////////////////////
  //
  //                W R I T T E N   B Y   I M P E R A S   I G E N
  //
  //                             Version 20211118.0
  //
  ////////////////////////////////////////////////////////////////////////////////
  
  
  #include "pse.igen.h"
  /////////////////////////////// Port Declarations //////////////////////////////
  
  handlesT handles;
  
  /////////////////////////////// Diagnostic level ///////////////////////////////
  
  // Test this variable to determine what diagnostics to output.
  // eg. if (diagnosticLevel >= 1) bhmMessage("I", "MC146818", "Example");
  //     Predefined macros PSE_DIAG_LOW, PSE_DIAG_MEDIUM and PSE_DIAG_HIGH may be used
  Uns32 diagnosticLevel;
  
  /////////////////////////// Diagnostic level callback //////////////////////////
  
  static void setDiagLevel(Uns32 new) {
      diagnosticLevel = new;
  }
  
  //////////////////////////////// Bus Slave Ports ///////////////////////////////
  
  static void installSlavePorts(void) {
      handles.busPort = ppmCreateSlaveBusPort("busPort", 2);
      if (!handles.busPort) {
          bhmMessage("E", "PPM_SPNC", "Could not connect port 'busPort'");
      }
  
  }
  
  PPM_DOC_FN(installDocs){
  
      ppmDocNodeP Root1_node = ppmDocAddSection(0, "Root");
      {
          ppmDocNodeP doc2_node = ppmDocAddSection(Root1_node, "Licensing");
          ppmDocAddText(doc2_node, "Open Source Apache 2.0");
          ppmDocNodeP doc_12_node = ppmDocAddSection(Root1_node, "Description");
          ppmDocAddText(doc_12_node, "MC146818 Real:time clock.");
          ppmDocNodeP doc_22_node = ppmDocAddSection(Root1_node, "Limitations");
          ppmDocAddText(doc_22_node, "This model has sufficient functionality to allow a Linux Kernel to Boot on the MIPS:MALTA platform.");
          ppmDocNodeP doc_32_node = ppmDocAddSection(Root1_node, "Reference");
          ppmDocAddText(doc_32_node, "Motorola MC146818AS Datasheet");
      }
  }
  ////////////////////////////////// Constructor /////////////////////////////////
  
  PPM_CONSTRUCTOR_CB(periphConstructor) {
      installSlavePorts();
  }
  
  ///////////////////////////////////// Main /////////////////////////////////////
  
  int main(int argc, char *argv[]) {
  
      diagnosticLevel = 0;
      bhmInstallDiagCB(setDiagLevel);
      constructor();
  
      bhmWaitEvent(bhmGetSystemEvent(BHM_SE_END_OF_SIMULATION));
      destructor();
      return 0;
  }
  
  