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

📄 c2_myuart1.c

📁 这份是实验课上的教师和学生用的实例。关于用matlab simulink仿真状态机并生成vhdl代码的详细内容
💻 C
📖 第 1 页 / 共 4 页
字号:

   case c2_IN_Delay:
    CV_STATE_EVAL(5,0,3);
    _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,8);
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,10);
    if (CV_TRANSITION_EVAL(10U, (int32_T)_SFD_CCP_CALL(10,0,(((uint8_T)
            (chartInstance.c2_BitCnt & 15U) == 8U)!=0))) != 0U != 0) {
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,10);
      _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,8);
      chartInstance.c2_tp_Delay = 0U;
      _SFD_CS_CALL(STATE_INACTIVE_TAG,8);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,8);
      chartInstance.c2_is_TxdPro = (uint8_T)c2_IN_STOP;
      _SFD_CS_CALL(STATE_ACTIVE_TAG,11);
      chartInstance.c2_tp_STOP = 1U;
      *c2_TxD = 1U;
      _SFD_DATA_RANGE_CHECK((real_T)*c2_TxD, 1U);
      chartInstance.c2_BitCnt = 9U;
      _SFD_DATA_RANGE_CHECK((real_T)chartInstance.c2_BitCnt, 3U);
    } else {
      _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,11);
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,11);
      _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,8);
      chartInstance.c2_tp_Delay = 0U;
      _SFD_CS_CALL(STATE_INACTIVE_TAG,8);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,8);
      chartInstance.c2_is_TxdPro = (uint8_T)c2_IN_DATA;
      _SFD_CS_CALL(STATE_ACTIVE_TAG,6);
      chartInstance.c2_tp_DATA = 1U;
      c2_u4 = chartInstance.c2_Tmp;
      if (c2_u4 > 1) {
        sf_debug_overflow_detection(0U, 0U);
      }

      *c2_TxD = (uint8_T)(c2_u4 & 1U);
      _SFD_DATA_RANGE_CHECK((real_T)*c2_TxD, 1U);
      c2_d1 = (real_T)*c2_TxD;
      sf_mex_printf("%s =\\n", "TxD");
      sf_mex_call("disp", 0U, 1U, 6, c2_d1);
      chartInstance.c2_Tmp = c2__u8_s32_(chartInstance.c2_Tmp >> 1);
      _SFD_DATA_RANGE_CHECK((real_T)chartInstance.c2_Tmp, 2U);
    }

    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,8);
    break;

   case c2_IN_IDLE:
    CV_STATE_EVAL(5,0,4);
    _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,9);
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,12);
    if (CV_TRANSITION_EVAL(12U, (int32_T)_SFD_CCP_CALL(12,0,(((uint8_T)
            (*c2_Ready & 1U) == 1)!=0))) != 0U != 0) {
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,12);
      chartInstance.c2_Tmp = *c2_TxDData;
      _SFD_DATA_RANGE_CHECK((real_T)chartInstance.c2_Tmp, 2U);
      *c2_Wr = 1U;
      _SFD_DATA_RANGE_CHECK((real_T)*c2_Wr, 5U);
      _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,9);
      chartInstance.c2_tp_IDLE = 0U;
      _SFD_CS_CALL(STATE_INACTIVE_TAG,9);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,9);
      chartInstance.c2_is_TxdPro = (uint8_T)c2_IN_START;
      _SFD_CS_CALL(STATE_ACTIVE_TAG,10);
      chartInstance.c2_tp_START = 1U;
      *c2_TxD = 0U;
      _SFD_DATA_RANGE_CHECK((real_T)*c2_TxD, 1U);
    } else {
      _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,13);
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,13);
      _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,9);
      chartInstance.c2_tp_IDLE = 0U;
      _SFD_CS_CALL(STATE_INACTIVE_TAG,9);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,9);
      chartInstance.c2_is_TxdPro = (uint8_T)c2_IN_IDLE;
      _SFD_CS_CALL(STATE_ACTIVE_TAG,9);
      chartInstance.c2_tp_IDLE = 1U;
      chartInstance.c2_BitCnt = 0U;
      _SFD_DATA_RANGE_CHECK((real_T)chartInstance.c2_BitCnt, 3U);
      *c2_TxD = 1U;
      _SFD_DATA_RANGE_CHECK((real_T)*c2_TxD, 1U);
      *c2_Wr = 0U;
      _SFD_DATA_RANGE_CHECK((real_T)*c2_Wr, 5U);
    }

    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,9);
    break;

   case c2_IN_START:
    CV_STATE_EVAL(5,0,5);
    _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,10);
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,14);
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,14);
    _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,10);
    chartInstance.c2_tp_START = 0U;
    _SFD_CS_CALL(STATE_INACTIVE_TAG,10);
    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,10);
    chartInstance.c2_is_TxdPro = (uint8_T)c2_IN_DELAY2;
    _SFD_CS_CALL(STATE_ACTIVE_TAG,7);
    chartInstance.c2_tp_DELAY2 = 1U;
    *c2_Wr = 0U;
    _SFD_DATA_RANGE_CHECK((real_T)*c2_Wr, 5U);
    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,10);
    break;

   case c2_IN_STOP:
    CV_STATE_EVAL(5,0,6);
    _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,11);
    _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG,15);
    if (CV_TRANSITION_EVAL(15U, (int32_T)_SFD_CCP_CALL(15,0,(((uint8_T)
            (chartInstance.c2_RateCnt & 31U) == 0)!=0))) != 0U != 0) {
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,15);
      _SFD_CS_CALL(STATE_ENTER_EXIT_FUNCTION_TAG,11);
      chartInstance.c2_tp_STOP = 0U;
      _SFD_CS_CALL(STATE_INACTIVE_TAG,11);
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,11);
      chartInstance.c2_is_TxdPro = (uint8_T)c2_IN_IDLE;
      _SFD_CS_CALL(STATE_ACTIVE_TAG,9);
      chartInstance.c2_tp_IDLE = 1U;
      chartInstance.c2_BitCnt = 0U;
      _SFD_DATA_RANGE_CHECK((real_T)chartInstance.c2_BitCnt, 3U);
      *c2_TxD = 1U;
      _SFD_DATA_RANGE_CHECK((real_T)*c2_TxD, 1U);
      *c2_Wr = 0U;
      _SFD_DATA_RANGE_CHECK((real_T)*c2_Wr, 5U);
    }

    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,11);
    break;

   default:
    CV_STATE_EVAL(5,0,0);
    chartInstance.c2_is_TxdPro = (uint8_T)c2_IN_NO_ACTIVE_CHILD;
    _SFD_CS_CALL(STATE_INACTIVE_TAG,6);
    break;
  }

  _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,5);
}

static void init_script_number_translation(uint32_T c2_machineNumber, uint32_T
  c2_chartNumber)
{
}

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

static uint8_T c2__u8_s32_(int32_T c2_b)
{
  uint8_T c2_a;
  c2_a = (uint8_T)c2_b;
  if (c2_a != c2_b) {
    sf_debug_overflow_detection(0U, 0U);
  }

  return c2_a;
}

static void init_test_point_addr_map(void)
{
  chartInstance.c2_testPointAddrMap[0] = &chartInstance.c2_Tmp;
  chartInstance.c2_testPointAddrMap[1] = &chartInstance.c2_BitCnt;
  chartInstance.c2_testPointAddrMap[2] = &chartInstance.c2_RateCnt;
  chartInstance.c2_testPointAddrMap[3] = &chartInstance.c2_tp_S;
  chartInstance.c2_testPointAddrMap[4] = &chartInstance.c2_tp_CntPro;
  chartInstance.c2_testPointAddrMap[5] = &chartInstance.c2_tp_DEC;
  chartInstance.c2_testPointAddrMap[6] = &chartInstance.c2_tp_Last;
  chartInstance.c2_testPointAddrMap[7] = &chartInstance.c2_tp_WAIT;
  chartInstance.c2_testPointAddrMap[8] = &chartInstance.c2_tp_TxdPro;
  chartInstance.c2_testPointAddrMap[9] = &chartInstance.c2_tp_DATA;
  chartInstance.c2_testPointAddrMap[10] = &chartInstance.c2_tp_DELAY2;
  chartInstance.c2_testPointAddrMap[11] = &chartInstance.c2_tp_Delay;
  chartInstance.c2_testPointAddrMap[12] = &chartInstance.c2_tp_IDLE;
  chartInstance.c2_testPointAddrMap[13] = &chartInstance.c2_tp_START;
  chartInstance.c2_testPointAddrMap[14] = &chartInstance.c2_tp_STOP;
}

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

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

static void init_dsm_address_info(void)
{
}

/* SFunction Glue Code */
static void init_test_point_mapping_info(SimStruct *S);
void sf_c2_MyUART1_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(1218552243U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(4071036903U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(2570282607U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(421449091U);
}

mxArray *sf_c2_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)(3473505401U);
    pr[1] = (double)(166877117U);
    pr[2] = (double)(4002770562U);
    pr[3] = (double)(1170019081U);
    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(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,"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(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));

⌨️ 快捷键说明

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