⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c1_myuart1.c

📁 这份是实验课上的教师和学生用的实例。关于用matlab simulink仿真状态机并生成vhdl代码的详细内容
💻 C
📖 第 1 页 / 共 4 页
字号:
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,12);
    if (CV_TRANSITION_EVAL(12U, (int32_T)_SFD_CCP_CALL(12,0,(((uint8_T)
            (chartInstance.c1_RateCnt & 31U) == 0)!=0))) != 0U != 0) {
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,12);
      _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,13);
      if (CV_TRANSITION_EVAL(13U, (int32_T)_SFD_CCP_CALL(13,0,(((uint8_T)
              (*c1_RxD & 1U) == 0)!=0))) != 0U != 0) {
        _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,13);
        _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,7);
        chartInstance.c1_tp_START = 0U;
        _SFD_CS_CALL(STATE_INACTIVE_TAG,7);
        _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,7);
        chartInstance.c1_is_RxdPro = (uint8_T)c1_IN_DATA;
        _SFD_CS_CALL(STATE_ACTIVE_TAG,5);
        chartInstance.c1_tp_DATA = 1U;
      } else {
        _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,14);
        _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,14);
        _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,7);
        chartInstance.c1_tp_START = 0U;
        _SFD_CS_CALL(STATE_INACTIVE_TAG,7);
        _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,7);
        chartInstance.c1_is_RxdPro = (uint8_T)c1_IN_IDLE;
        _SFD_CS_CALL(STATE_ACTIVE_TAG,6);
        chartInstance.c1_tp_IDLE = 1U;
        chartInstance.c1_BitCnt = 0U;
        _SFD_DATA_RANGE_CHECK((real_T)chartInstance.c1_BitCnt, 3U);
        *c1_Valid = 0U;
        _SFD_DATA_RANGE_CHECK((real_T)*c1_Valid, 4U);
      }
    }

    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,7);
    break;

   case c1_IN_STOP:
    CV_STATE_EVAL(4,0,4);
    _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,8);
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,15);
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,15);
    _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,8);
    chartInstance.c1_tp_STOP = 0U;
    _SFD_CS_CALL(STATE_INACTIVE_TAG,8);
    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,8);
    chartInstance.c1_is_RxdPro = (uint8_T)c1_IN_IDLE;
    _SFD_CS_CALL(STATE_ACTIVE_TAG,6);
    chartInstance.c1_tp_IDLE = 1U;
    chartInstance.c1_BitCnt = 0U;
    _SFD_DATA_RANGE_CHECK((real_T)chartInstance.c1_BitCnt, 3U);
    *c1_Valid = 0U;
    _SFD_DATA_RANGE_CHECK((real_T)*c1_Valid, 4U);
    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,8);
    break;

   case c1_IN_STORE:
    CV_STATE_EVAL(4,0,5);
    _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,9);
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,16);
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,16);
    _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,9);
    chartInstance.c1_tp_STORE = 0U;
    _SFD_CS_CALL(STATE_INACTIVE_TAG,9);
    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,9);
    chartInstance.c1_is_RxdPro = (uint8_T)c1_IN_DATA;
    _SFD_CS_CALL(STATE_ACTIVE_TAG,5);
    chartInstance.c1_tp_DATA = 1U;
    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,9);
    break;

   case c1_IN_delay:
    CV_STATE_EVAL(4,0,6);
    _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,10);
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,17);
    if (CV_TRANSITION_EVAL(17U, (_SFD_CCP_CALL(17,0,(((uint8_T)
             (chartInstance.c1_RateCnt & 31U) == 0)!=0)) != 0) || (_SFD_CCP_CALL
          (17,1,((
                  (uint8_T)(*c1_Rd & 1U) == 1)!=0)) != 0)) != 0U != 0) {
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,17);
      _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,10);
      chartInstance.c1_tp_delay = 0U;
      _SFD_CS_CALL(STATE_INACTIVE_TAG,10);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,10);
      chartInstance.c1_is_RxdPro = (uint8_T)c1_IN_STOP;
      _SFD_CS_CALL(STATE_ACTIVE_TAG,8);
      chartInstance.c1_tp_STOP = 1U;
      chartInstance.c1_BitCnt = 10U;
      _SFD_DATA_RANGE_CHECK((real_T)chartInstance.c1_BitCnt, 3U);
    }

    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,10);
    break;

   default:
    CV_STATE_EVAL(4,0,0);
    chartInstance.c1_is_RxdPro = (uint8_T)c1_IN_NO_ACTIVE_CHILD;
    _SFD_CS_CALL(STATE_INACTIVE_TAG,5);
    break;
  }

  _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,4);
}

static void init_script_number_translation(uint32_T c1_machineNumber, uint32_T
  c1_chartNumber)
{
}

const mxArray *sf_c1_MyUART1_get_eml_resolved_functions_info(void)
{
  const mxArray *c1_nameCaptureInfo = NULL;
  c1_nameCaptureInfo = NULL;
  sf_mex_assign(&c1_nameCaptureInfo, sf_mex_create(NULL, "nameCaptureInfo", 0,
    0U, 1U, 2, 0, 1));
  return c1_nameCaptureInfo;
}

static uint8_T c1__u8_s32_(int32_T c1_b)
{
  uint8_T c1_a;
  c1_a = (uint8_T)c1_b;
  if (c1_a != c1_b) {
    sf_debug_overflow_detection(0U, 0U);
  }

  return c1_a;
}

static int32_T c1__s32_add__(int32_T c1_b, int32_T c1_c)
{
  int32_T c1_a;
  c1_a = c1_b + c1_c;
  if (((c1_a ^ c1_b) & (c1_a ^ c1_c)) < 0) {
    sf_debug_overflow_detection(0U, 0U);
  }

  return c1_a;
}

static int32_T c1__s32_shl_s32_(int32_T c1_b, int32_T c1_c)
{
  int32_T c1_a;
  c1_a = c1_b << c1_c;
  if ((c1_b != c1_a >> c1_c) || ((uint32_T)c1_c > 31)) {
    sf_debug_overflow_detection(0U, 0U);
  }

  return c1_a;
}

static void init_test_point_addr_map(void)
{
  chartInstance.c1_testPointAddrMap[0] = &chartInstance.c1_RateCnt;
  chartInstance.c1_testPointAddrMap[1] = &chartInstance.c1_BitCnt;
  chartInstance.c1_testPointAddrMap[2] = &chartInstance.c1_Tmp;
  chartInstance.c1_testPointAddrMap[3] = &chartInstance.c1_tp_S;
  chartInstance.c1_testPointAddrMap[4] = &chartInstance.c1_tp_CntPro;
  chartInstance.c1_testPointAddrMap[5] = &chartInstance.c1_tp_DEC;
  chartInstance.c1_testPointAddrMap[6] = &chartInstance.c1_tp_WAIT;
  chartInstance.c1_testPointAddrMap[7] = &chartInstance.c1_tp_RxdPro;
  chartInstance.c1_testPointAddrMap[8] = &chartInstance.c1_tp_DATA;
  chartInstance.c1_testPointAddrMap[9] = &chartInstance.c1_tp_IDLE;
  chartInstance.c1_testPointAddrMap[10] = &chartInstance.c1_tp_START;
  chartInstance.c1_testPointAddrMap[11] = &chartInstance.c1_tp_STOP;
  chartInstance.c1_testPointAddrMap[12] = &chartInstance.c1_tp_STORE;
  chartInstance.c1_testPointAddrMap[13] = &chartInstance.c1_tp_delay;
}

static void **get_test_point_address_map(void)
{
  return &chartInstance.c1_testPointAddrMap[0];
}

static rtwCAPI_ModelMappingInfo *get_test_point_mapping_info(void)
{
  return &chartInstance.c1_testPointMappingInfo;
}

static void init_dsm_address_info(void)
{
}

/* SFunction Glue Code */
static void init_test_point_mapping_info(SimStruct *S);
void sf_c1_MyUART1_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(2065969203U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(2310427829U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(3216156944U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(3184896829U);
}

mxArray *sf_c1_MyUART1_get_autoinheritance_info(void)
{
  const char *autoinheritanceFields[] = { "checksum", "inputs", "parameters",
    "outputs" };

  mxArray *mxAutoinheritanceInfo = mxCreateStructMatrix(1,1,4,
    autoinheritanceFields);

  {
    mxArray *mxChecksum = mxCreateDoubleMatrix(4,1,mxREAL);
    double *pr = mxGetPr(mxChecksum);
    pr[0] = (double)(3796840957U);
    pr[1] = (double)(2848777669U);
    pr[2] = (double)(255446006U);
    pr[3] = (double)(3858297335U);
    mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
  }

  {
    const char *dataFields[] = { "size", "type", "complexity" };

    mxArray *mxData = mxCreateStructMatrix(1,2,3,dataFields);

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,0,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "aliasId", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,3,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(11));
      mxSetField(mxType,0,"aliasId",mxCreateDoubleScalar(0));

      {
        const char *fixptFields[] = { "isSigned", "wordLength", "bias", "slope",
          "exponent" };

        mxArray *mxFixpt = mxCreateStructMatrix(1,1,5,fixptFields);
        mxSetField(mxFixpt,0,"isSigned",mxCreateDoubleScalar(0));
        mxSetField(mxFixpt,0,"wordLength",mxCreateDoubleScalar(1));
        mxSetField(mxFixpt,0,"bias",mxCreateDoubleScalar(0));
        mxSetField(mxFixpt,0,"slope",mxCreateDoubleScalar(1));
        mxSetField(mxFixpt,0,"exponent",mxCreateDoubleScalar(0));
        mxSetField(mxType,0,"fixpt",mxFixpt);
      }

      mxSetField(mxData,0,"type",mxType);
    }

    mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,1,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "aliasId", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,3,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(11));
      mxSetField(mxType,0,"aliasId",mxCreateDoubleScalar(0));

      {
        const char *fixptFields[] = { "isSigned", "wordLength", "bias", "slope",
          "exponent" };

        mxArray *mxFixpt = mxCreateStructMatrix(1,1,5,fixptFields);
        mxSetField(mxFixpt,0,"isSigned",mxCreateDoubleScalar(0));
        mxSetField(mxFixpt,0,"wordLength",mxCreateDoubleScalar(1));
        mxSetField(mxFixpt,0,"bias",mxCreateDoubleScalar(0));
        mxSetField(mxFixpt,0,"slope",mxCreateDoubleScalar(1));
        mxSetField(mxFixpt,0,"exponent",mxCreateDoubleScalar(0));
        mxSetField(mxType,0,"fixpt",mxFixpt);
      }

      mxSetField(mxData,1,"type",mxType);
    }

    mxSetField(mxData,1,"complexity",mxCreateDoubleScalar(0));
    mxSetField(mxAutoinheritanceInfo,0,"inputs",mxData);
  }

  {
    mxSetField(mxAutoinheritanceInfo,0,"parameters",mxCreateDoubleMatrix(0,0,
                mxREAL));
  }

  {
    const char *dataFields[] = { "size", "type", "complexity" };

    mxArray *mxData = mxCreateStructMatrix(1,2,3,dataFields);

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,0,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "aliasId", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,3,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(11));
      mxSetField(mxType,0,"aliasId",mxCreateDoubleScalar(0));

      {
        const char *fixptFields[] = { "isSigned", "wordLength", "bias", "slope",
          "exponent" };

        mxArray *mxFixpt = mxCreateStructMatrix(1,1,5,fixptFields);
        mxSetField(mxFixpt,0,"isSigned",mxCreateDoubleScalar(0));
        mxSetField(mxFixpt,0,"wordLength",mxCreateDoubleScalar(8));
        mxSetField(mxFixpt,0,"bias",mxCreateDoubleScalar(0));
        mxSetField(mxFixpt,0,"slope",mxCreateDoubleScalar(1));
        mxSetField(mxFixpt,0,"exponent",mxCreateDoubleScalar(0));
        mxSetField(mxType,0,"fixpt",mxFixpt);
      }

      mxSetField(mxData,0,"type",mxType);
    }

    mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));

    {
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
      double *pr = mxGetPr(mxSize);
      pr[0] = (double)(1);
      pr[1] = (double)(1);
      mxSetField(mxData,1,"size",mxSize);
    }

    {
      const char *typeFields[] = { "base", "aliasId", "fixpt" };

      mxArray *mxType = mxCreateStructMatrix(1,1,3,typeFields);
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(11));
      mxSetField(mxType,0,"aliasId",mxCreateDoubleScalar(0));

      {
        const char *fixptFields[] = { "isSigned", "wordLength", "bias", "slope",
          "exponent" };

        mxArray *mxFixpt = mxCreateStructMatrix(1,1,5,fixptFields);
        mxSetField(mxFixpt,0,"isSigned",mxCreateDoubleScalar(0));
        mxSetField(mxFixpt,0,"wordLength",mxCreateDoubleScalar(1));
        mxSetField(mxFixpt,0,"bias",mxCreateDoubleScalar(0));
        mxSetField(mxFixpt,0,"slope",mxCreateDoubleScalar(1));
        mxSetField(mxFixpt,0,"exponent",mxCreateDoubleScalar(0));
        mxSetField(mxType,0,"fixpt",mxFixpt);
      }

      mxSetField(mxData,1,"type",mxType);
    }

    mxSetField(mxData,1,"complexity",mxCreateDoubleScalar(0));
    mxSetField(mxAutoinheritanceInfo,0,"outputs",mxData);
  }

  return(mxAutoinheritanceInfo);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -