<?xml version="1.0" encoding="UTF-8"?>
<net name="uart_recv" type="iopt-flow">
  <signal id="RxD" x="230" y="35" mode="input" type="boolean" min="0" max="1" microstep="0" nano-step="0"/>
  <event id="Recv" x="655" y="45" mode="output" microstep="2" nano-step="1"/>
  <signal id="DataOut" x="655" y="125" mode="output" type="range" min="0" max="255" dynamic="none" frac="0" value="0" io_pin="0" microstep="2" nano-step="2"/>
  <signal id="ClkDiv" x="140" y="515" mode="input" type="range" min="4" max="65535" frac="0" value="4" dynamic="none" io_pin="0" microstep="0" nano-step="0"/>
  <operation id="o11" x="225" y="450" rot="0" shape="arrow" size="32">
    <name off_x="-27" off_y="-32" text="BaudClk"/>
    <input off_x="-35" off_y="-20" name="Rst" id="o11.Rst" type="event" min="0" max="1" frac="0"/>
    <input off_x="-35" off_y="20" name="ClkDiv" id="o11.ClkDiv" type="range" min="4" max="65535" dynamic="all" frac="0"/>
    <input off_x="-35" off_y="0" name="ClkCntr" id="o11.ClkCntr" type="range" min="0" max="64535" dynamic="name" frac="0"/>
    <output off_x="32" off_y="0" name="out" id="o11.out" type="range" min="0" max="65535" dynamic="type" frac="0" microstep="1" nano-step="1">
      <expression>
        <operand type="literal" value="1"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="Rst"/>
          <operator type="or"/>
          <operand type="signal" idRef="ClkCntr" delay="1"/>
          <operator type="more-or-equal"/>
          <operand type="signal" idRef="ClkDiv"/>
        </operand>
        <text>1 WHEN (Rst OR ClkCntr[-1] &gt;= ClkDiv)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="ClkCntr" delay="1"/>
        <operator type="add"/>
        <operand type="literal" value="1"/>
        <text>ClkCntr[-1] + 1 OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="a12" type="read" source="ClkDiv" target="o11.ClkDiv"/>
  <arc id="a15" type="read" source="o11.out" target="o11.ClkCntr" view="symbolic"/>
  <place id="p6" x="325" y="100" init_marking="0">
    <name off_x="-10" off_y="-10" text="WaitStart"/>
    <comment off_x="0" off_y="20" text="-"/>
  </place>
  <transition id="t7" x="325" y="170" priority="0" microstep="0">
    <name off_x="-10" off_y="-10" text="WaitStartBit"/>
    <comment off_x="0" off_y="20" text="-"/>
  </transition>
  <operation id="o8" x="260" y="170" rot="0" shape="arrow" size="16">
    <name off_x="-11" off_y="-16" text="Start"/>
    <input off_x="-16" off_y="0" name="RxD" id="o8.RxD" type="boolean" min="0" max="1" dynamic="all"/>
    <output off_x="16" off_y="0" name="out" id="o8.out" type="boolean" min="0" max="1" dynamic="none" frac="0" microstep="0" nano-step="1">
      <expression>
        <operand type="signal" idRef="RxD"/>
        <operator type="equal"/>
        <operand type="literal" value="0"/>
        <text>RxD = 0</text>
      </expression>
    </output>
  </operation>
  <arc id="a9" type="read" source="RxD" target="o8.RxD" view="symbolic"/>
  <arc id="a10" type="read" source="o8.out" target="t7"/>
  <arc id="a11" type="normal" source="p6" target="t7"/>
  <arc id="a13" type="read" source="t7" target="o11.Rst" view="symbolic"/>
  <place id="p14" x="325" y="235" init_marking="0">
    <name off_x="-10" off_y="-10" text="StartBit"/>
    <comment off_x="0" off_y="20" text="-"/>
  </place>
  <arc id="a16" type="normal" source="t7" target="p14"/>
  <operation id="o1" x="345" y="505" rot="0" shape="arrow" size="24">
    <name off_x="-19" off_y="-24" text="baud_center"/>
    <input off_x="-24" off_y="-8" name="ClkCntr" id="o1.ClkCntr" type="range" min="0" max="65535" dynamic="all" frac="0"/>
    <input off_x="-24" off_y="8" name="ClkDiv" id="o1.ClkDiv" type="range" min="4" max="65535" dynamic="all" frac="0"/>
    <output off_x="24" off_y="0" name="out" id="o1.out" type="event" min="0" max="1" dynamic="none" frac="0" microstep="1" nano-step="2">
      <expression>
        <operand type="signal" idRef="ClkCntr"/>
        <operator type="equal"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="ClkDiv"/>
          <operator type="div"/>
          <operand type="literal" value="2"/>
        </operand>
        <operator type="add"/>
        <operand type="literal" value="1"/>
        <text>ClkCntr = (ClkDiv / 2) + 1</text>
      </expression>
    </output>
  </operation>
  <arc id="a2" type="read" source="ClkDiv" target="o1.ClkDiv"/>
  <arc id="a3" type="read" source="o11.out" target="o1.ClkCntr"/>
  <transition id="t6" x="395" y="170" priority="0" microstep="0">
    <name off_x="-10" off_y="-10" text="t6"/>
    <comment off_x="-10" off_y="20" text="-"/>
  </transition>
  <transition id="t8" x="325" y="305" priority="0" microstep="1">
    <name off_x="-10" off_y="-10" text="StartBitOk"/>
    <comment off_x="0" off_y="20" text="-"/>
  </transition>
  <arc id="a14" type="read" source="RxD" target="t6" view="symbolic"/>
  <arc id="a17" type="normal" source="p14" target="t6" c2_x="0" c2_y="35" c1_x="0" c1_y="0"/>
  <arc id="a18" type="normal" source="t6" target="p6" c2_x="40" c2_y="0" c1_x="0" c1_y="0"/>
  <place id="p2" x="325" y="365" init_marking="0">
    <name off_x="-10" off_y="-10" text="DataBit"/>
    <comment off_x="0" off_y="20" text="-"/>
  </place>
  <arc id="a4" type="normal" source="p14" target="t8"/>
  <arc id="a6" type="normal" source="t8" target="p2"/>
  <transition id="t9" x="410" y="365" priority="0" microstep="1">
    <name off_x="-10" off_y="-10" text="NextBit"/>
    <comment off_x="0" off_y="20" text="-"/>
  </transition>
  <arc id="a19" type="normal" source="p2" target="t9" c2_x="-30" c2_y="25" c1_x="0" c1_y="0"/>
  <arc id="a22" type="normal" source="t9" target="p2" c2_x="20" c2_y="-25" c1_x="0" c1_y="0"/>
  <operation id="o23" x="525" y="365" rot="0" shape="arrow" size="32">
    <name off_x="-27" off_y="-32" text="BitCnt"/>
    <input off_x="-32" off_y="-16" name="Rst" id="o23.Rst" type="event" min="0" max="1" frac="0"/>
    <input off_x="-32" off_y="0" name="Inc" id="o23.Inc" type="event" min="0" max="1" frac="0"/>
    <input off_x="-32" off_y="16" name="Cntr" id="o23.Cntr" type="range" min="0" max="8" frac="0" dynamic="type"/>
    <output off_x="32" off_y="0" name="out" id="o23.out" type="range" min="0" max="8" dynamic="none" frac="0" microstep="2" nano-step="1">
      <expression>
        <operand type="literal" value="0"/>
        <operator type="when"/>
        <operand type="signal" idRef="Rst"/>
        <text>0 WHEN (Rst)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="Cntr" delay="1"/>
        <operator type="add"/>
        <operand type="literal" value="1"/>
        <operator type="when"/>
        <operand type="signal" idRef="Inc"/>
        <text>Cntr[-1] + 1 WHEN (Inc)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="Cntr" delay="1"/>
        <text>Cntr[-1] OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="a24" type="read" source="t8" target="o23.Rst"/>
  <arc id="a25" type="read" source="t9" target="o23.Inc"/>
  <signal id="BitCntr" x="625" y="365" mode="internal" type="range" min="0" max="8" frac="0" value="0" dynamic="type" microstep="2" nano-step="1"/>
  <arc id="a28" type="read" source="BitCntr" target="o23.Cntr" view="symbolic"/>
  <arc id="a31" type="read" source="o23.out" target="BitCntr"/>
  <event id="Center" x="425" y="505" mode="internal" microstep="1" nano-step="2"/>
  <arc id="a40" type="read" source="o1.out" target="Center"/>
  <arc id="a41" type="read" source="Center" target="t9" view="symbolic"/>
  <arc id="a42" type="read" source="Center" target="t8" view="symbolic"/>
  <signal id="DataByte" x="625" y="240" mode="internal" type="range" min="0" max="255" frac="0" value="0" dynamic="none" microstep="2" nano-step="1"/>
  <transition id="t28" x="145" y="365" priority="0" microstep="0">
    <name off_x="-10" off_y="-10" text="Bit8"/>
    <comment off_x="0" off_y="20" text="-"/>
  </transition>
  <arc id="a30" type="normal" source="p2" target="t28"/>
  <operation id="o33" x="80" y="365" rot="0" shape="arrow" size="16">
    <name off_x="-11" off_y="-16" text="LastBit"/>
    <input off_x="-16" off_y="0" name="Cntr" id="o33.Cntr" type="range" min="0" max="8" dynamic="all" frac="0"/>
    <output off_x="16" off_y="0" name="out" id="o33.out" type="boolean" min="0" max="1" dynamic="type" frac="0" microstep="0" nano-step="1">
      <expression>
        <operand type="signal" idRef="Cntr" delay="1"/>
        <operator type="equal"/>
        <operand type="literal" value="8"/>
        <text>Cntr[-1] = 8</text>
      </expression>
    </output>
  </operation>
  <arc id="a34" type="read" source="BitCntr" target="o33.Cntr" view="symbolic"/>
  <arc id="a35" type="read" source="o33.out" target="t28"/>
  <place id="p36" x="145" y="285" init_marking="0">
    <name off_x="-10" off_y="-10" text="StopBit"/>
    <comment off_x="0" off_y="20" text="-"/>
  </place>
  <arc id="a37" type="normal" source="t28" target="p36"/>
  <transition id="t38" x="145" y="195" priority="0" microstep="1">
    <name off_x="-10" off_y="-10" text="StopBitEnd"/>
    <comment off_x="0" off_y="20" text="-"/>
  </transition>
  <arc id="a43" type="normal" source="p36" target="t38"/>
  <arc id="a47" type="read" source="Center" target="t38" view="symbolic"/>
  <operation id="o51" x="430" y="45" rot="0" shape="arrow" size="24">
    <name off_x="-19" off_y="-24" text="StopBitOK"/>
    <input off_x="-25" off_y="10" name="StopBit" id="o51.StopBit" type="event" min="0" max="1" frac="0"/>
    <input off_x="-25" off_y="-10" name="RxD" id="o51.RxD" type="boolean" min="0" max="1" dynamic="all"/>
    <output off_x="24" off_y="0" name="out" id="o51.out" type="event" min="0" max="1" dynamic="none" frac="0" microstep="2" nano-step="1">
      <expression>
        <operand type="signal" idRef="StopBit"/>
        <operator type="and"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="RxD"/>
          <operator type="equal"/>
          <operand type="literal" value="1"/>
        </operand>
        <text>StopBit AND (RxD = 1)</text>
      </expression>
    </output>
  </operation>
  <arc id="a52" type="read" source="t38" target="o51.StopBit" view="symbolic"/>
  <arc id="a53" type="read" source="RxD" target="o51.RxD"/>
  <operation id="o59" x="560" y="125" rot="0" shape="arrow" size="32">
    <name off_x="-27" off_y="-32" text="Output"/>
    <input off_x="-32" off_y="-16" name="RecvOK" id="o59.RecvOK" type="event" min="0" max="1" dynamic="type" frac="0"/>
    <input off_x="-32" off_y="0" name="DataByte" id="o59.DataByte" type="range" min="0" max="255" dynamic="all" frac="0"/>
    <input off_x="-32" off_y="16" name="DataOut" id="o59.DataOut" type="range" min="0" max="255" dynamic="all" frac="0"/>
    <output off_x="32" off_y="0" name="out" id="o59.out" type="range" min="0" max="255" dynamic="type" frac="0" microstep="2" nano-step="2">
      <expression>
        <operand type="signal" idRef="DataByte"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="RecvOK"/>
        </operand>
        <text>DataByte WHEN (RecvOK)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="DataOut" delay="1"/>
        <text>DataOut[-1] OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="a60" type="read" source="DataByte" target="o59.DataByte" view="symbolic"/>
  <arc id="a61" type="read" source="DataOut" target="o59.DataOut" view="symbolic"/>
  <arc id="a62" type="read" source="o59.out" target="DataOut"/>
  <arc id="a63" type="read" source="o51.out" target="o59.RecvOK"/>
  <place id="p1" x="145" y="100" init_marking="1">
    <name off_x="-10" off_y="-10" text="Ready"/>
    <comment off_x="0" off_y="20" text="-"/>
  </place>
  <transition id="t2" x="230" y="100" priority="0" microstep="0">
    <name off_x="-10" off_y="-10" text="WaitTxdOn"/>
    <comment off_x="0" off_y="20" text="-"/>
  </transition>
  <arc id="a5" type="normal" source="t38" target="p1"/>
  <arc id="a20" type="normal" source="p1" target="t2"/>
  <arc id="a29" type="normal" source="t2" target="p6"/>
  <arc id="a33" type="read" source="RxD" target="t2"/>
  <operation id="o3" x="525" y="240" rot="0" shape="arrow" size="40">
    <name off_x="-35" off_y="-40" text="o3"/>
    <input off_x="-40" off_y="-24" name="rst" id="o3.rst" type="event" min="0" max="1" frac="0"/>
    <input off_x="-40" off_y="-8" name="shift" id="o3.shift" type="event" min="0" max="1" frac="0"/>
    <input off_x="-40" off_y="8" name="RxD" id="o3.RxD" type="boolean" min="0" max="1" dynamic="all"/>
    <input off_x="-40" off_y="24" name="DataByte" id="o3.DataByte" type="range" min="0" max="255" dynamic="all" frac="0"/>
    <output off_x="40" off_y="0" name="out" id="o3.out" type="range" min="0" max="255" dynamic="type" frac="0" microstep="2" nano-step="1">
      <expression>
        <operand type="literal" value="0"/>
        <operator type="when"/>
        <operand type="signal" idRef="rst"/>
        <text>0 WHEN (rst)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="DataByte" delay="1"/>
        <operator type="div"/>
        <operand type="literal" value="2"/>
        <operator type="add"/>
        <operand type="literal" value="128"/>
        <operator type="when"/>
        <operand type="signal" idRef="shift"/>
        <operator type="and"/>
        <operand type="signal" idRef="RxD"/>
        <text>DataByte[-1] / 2 + 128 WHEN (shift AND RxD)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="DataByte" delay="1"/>
        <operator type="div"/>
        <operand type="literal" value="2"/>
        <operator type="when"/>
        <operand type="signal" idRef="shift"/>
        <text>DataByte[-1] / 2 WHEN (shift)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="DataByte" delay="1"/>
        <text>DataByte[-1] OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="a7" type="read" source="t8" target="o3.rst"/>
  <arc id="a8" type="read" source="t9" target="o3.shift"/>
  <arc id="a21" type="read" source="RxD" target="o3.RxD" view="symbolic"/>
  <arc id="a23" type="read" source="DataByte" target="o3.DataByte" view="symbolic"/>
  <arc id="a26" type="read" source="o3.out" target="DataByte"/>
  <operation id="o2" x="560" y="45" rot="0" shape="arrow" size="16">
    <name off_x="-11" off_y="-16" text="Delay"/>
    <input off_x="-16" off_y="0" name="StopBitOK" id="o2.StopBitOK" type="event" min="0" max="1" dynamic="all" frac="0"/>
    <output off_x="16" off_y="0" name="out" id="o2.out" type="event" min="0" max="1" dynamic="none" frac="0">
      <expression>
        <operand type="signal" idRef="StopBitOK" delay="1"/>
        <text>StopBitOK[-1]</text>
      </expression>
    </output>
  </operation>
  <arc id="a27" type="read" source="o51.out" target="o2.StopBitOK"/>
  <arc id="a32" type="read" source="o2.out" target="Recv"/>
</net>
