Changeset 166


Ignore:
Timestamp:
Oct 8, 2010, 6:11:14 PM (9 years ago)
Author:
mulligan
Message:

I/O support added for serial buffer.

Location:
Deliverables/D4.1
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.1/ASMInterpret.ml

    r163 r166  
    1212
    1313type time = int;;
    14 type line = [`P0 | `P1 ];; (* ??? *)
     14type line = [ `P0 of byte
     15            | `P1 of byte
     16            | `SerialBuff of [ `Eight of byte | `Nine of BitVectors.bit * byte ]];;
     17
     18(* In:  reception time, line of input, new continuation,
     19   Out: transmission time, output line, expected duration until reply,
     20        new continuation.
     21*)
    1522type continuation =
    16 unit (*
    17  [`In of time * line * byte * continuation] option *
    18  [`Out of (time -> line -> byte -> continuation) ]
    19 *)
     23  [`In of time * line * continuation] option *
     24  [`Out of (time -> line -> time * continuation) ]
    2025
    2126(* no differentiation between internal and external code memory *)
     
    6065   timer1: word;
    6166   timer2: word;  (* can be missing *)
     67   expected_out_time: [ `None | `Now | `At of time ];
    6268   io: continuation
    6369 }
     
    109115  | 0xA0 -> { status with p2 = v }
    110116  | 0xB0 -> { status with p3 = v }
    111   | 0x99 -> { status with sbuf = v }
     117  | 0x99 ->
     118      if status.expected_out_time = `None then
     119        { status with sbuf = v; expected_out_time = `Now }
     120      else
     121        (* a real assert false: trying to initiate a transmission whilst one is still active *)
     122        assert false
    112123  | 0x8A -> { status with tl0 = v }
    113124  | 0x8B -> { status with tl1 = v }
     
    178189  timer2 = zero `Sixteen;
    179190
    180   io = ()
     191  expected_out_time = `None;
     192
     193  io = (None, `Out (fun t l -> assert false)) (* a real assert false: unprepared for i/o *)
    181194}
    182195
     
    13381351                status) in
    13391352          (* Timer 1 follows. *)
     1353        let status =
    13401354          (match b3,b4 with
    13411355            true,true ->
     
    14011415                    { status with tl1 = res }
    14021416              else
    1403                 status)
     1417                status) in
     1418       (* Serial port code now follows *)
     1419         let in_cont, `Out out_cont = status.io in
     1420         let status =
     1421           (* Serial port input *)
     1422           (match in_cont with
     1423             Some (`In(time, line, cont)) when time >= status.clock && get_bit status.scon 4 ->
     1424               let status =
     1425                 match line with
     1426                   `P0 b -> assert false
     1427                 | `P1 b -> assert false
     1428                 | `SerialBuff (`Eight b) ->
     1429                      let b7 = get_bit (status.scon) 7 in
     1430                        (* waiting for nine bits, multiprocessor communication mode requires nine bits *)
     1431                        if b7 || get_bit status.scon 5 then
     1432                          assert false (* really: crash! *)
     1433                        else
     1434                          let status = { status with scon = set_bit status.scon 0 true } in
     1435                          let status = { status with sbuf = b } in
     1436                            status
     1437                 | `SerialBuff (`Nine (b,b')) ->
     1438                      let b7 = get_bit (status.scon) 7 in
     1439                        (* waiting for eight bits *)
     1440                        if not b7 then
     1441                          assert false (* really: crash! *)
     1442                        else
     1443                          let status = { status with scon = set_bit status.scon 2 b } in
     1444                          let status = { status with sbuf = b' } in
     1445                            if (not $ get_bit status.scon 5) || b then
     1446                              { status with scon = set_bit status.scon 0 true }
     1447                            else
     1448                              status
     1449               in
     1450                 { status with io = cont }
     1451           | _ -> status) in
     1452           (* Serial port output, part one *)
     1453           let status =
     1454             (match status.expected_out_time with
     1455               `At t when status.clock >= t ->
     1456                 { status with scon = set_bit status.scon 1 true; expected_out_time = `None }
     1457              | _ -> status) in
     1458           (* Serial port output, part two *)
     1459           if status.expected_out_time = `Now then
     1460             if get_bit status.scon 7 then
     1461               let exp_time, new_cont = out_cont status.clock (`SerialBuff (`Nine ((get_bit status.scon 3), status.sbuf))) in
     1462                 { status with expected_out_time = `At exp_time; io = new_cont }
     1463             else
     1464               let exp_time, new_cont = out_cont status.clock (`SerialBuff (`Eight status.sbuf)) in
     1465                 { status with expected_out_time = `At exp_time; io = new_cont }               
     1466           else
     1467             status
    14041468;;
    14051469
  • Deliverables/D4.1/ASMInterpret.mli

    r143 r166  
    55
    66type time = int;;
    7 type line = [`P0 | `P1 ];; (* ??? *)
     7type line = [ `P0 of byte
     8            | `P1 of byte
     9            | `SerialBuff of [ `Eight of byte | `Nine of BitVectors.bit * byte ]];;
     10(* In:  reception time, line of input, new continuation,
     11   Out: transmission time, output line, expected duration until reply,
     12        new continuation.
     13*)
    814type continuation =
    9 unit (*
    10  [`In of time * line * byte * continuation] option *
    11  [`Out of (time -> line -> byte -> continuation) ]
    12 *)
     15  [`In of time * line * continuation] option *
     16  [`Out of (time -> line -> time * continuation) ]
    1317
    1418type status = private
     
    5256   timer1: word;
    5357   timer2: word;  (* can be missing *)
     58   expected_out_time: [ `None | `Now | `At of time ];
    5459   io: continuation
    5560 }
  • Deliverables/D4.1/Test.hex

    r165 r166  
    11:03000000020008F3
    22:0300610002000397
    3 :050003001200A480FEC4
    4 :08006400AA82AB837C007D0041
    5 :0E006C008C06EDCE25E0CE33FF0EBE00010F58
    6 :0E007A00C3EA9EEB9F401E8C068D070CBC0057
    7 :02008800010D68
    8 :0C008A00EFCE25E0CE33FF0EBE00010FCC
    9 :09009600EAC39EFAEB9FFB80CD4A
    10 :05009F008C828D83221C
    11 :0E00A400900010120064AA82AB83BA0407BB5E
    12 :0600B2000004900005228D
    13 :0400B800900007228B
     3:0500030012015380FE14
     4:0800640085820885830985F0FF
     5:04006C000AF50B8501
     6:03007000081085F0
     7:03007300091185EB
     8:030076000A1285E6
     9:030079000B13AEB8
     10:0A007C0010E511A2E713CE13CEFF2A
     11:0E0086003395E0FAFB74DFC39EFE74599FFFB2
     12:0A00940074379A745F9B8E108F1171
     13:04009E0085100C8538
     14:0300A200110D85B8
     15:0300A500120E85B3
     16:0300A800130FC073
     17:0400AB0008C009C0C0
     18:0A00AF000AC00B900000E4F5F074A5
     19:0E00B9003F1201ACAE82AF83AAF0FBE58124BA
     20:0800C700FCF581C00CC00DC066
     21:0A00CF000EC00F8E828F838AF0EBC3
     22:0E00D9001201ACAA82AB83ACF0FDE58124FCE1
     23:0700E700F581C00CC00DC043
     24:0A00EE000EC00F8A828B838CF0EDA8
     25:0E00F8001201ACAA82AB83ACF0FDE58124FCC2
     26:0E010600F581C002C003C004C0059000007562
     27:0E011400F0C0743F1201A1AA82AB83ACF0FDD3
     28:0E012200E58124FCF581C002C003C004C005C5
     29:07013000850C82850D83851B
     30:050137000EF0E50F12BF
     31:0E013C0001ACAA82AB83ACF0FDE58124FCF59A
     32:09014A00818A828B838CF0ED2286
     33:0E01530090000075F0807441120064AA82AB27
     34:0D01610083ACF0FDC002C003C004C00590D7
     35:0E016E00000075F080743F12039CAA82AB83E0
     36:0E017C00ACF0FDE58124FCF5818A828B838C3A
     37:0E018A00F0ED1202FFAA82AB83BA0407BB009D
     38:050198000490000522A7
     39:04019D0090000722A5
     40:0B01A100A8811818C6B2E7C60202A62B
     41:0601AC0012024FBC00032B
     42:0301B200020354F1
     43:0801B500EF60FA30D502B2D16F
     44:0801BD00E583B4FF0302036AAD
     45:0801C500E582B4FF0302036AA6
     46:0B01CD00258340072482400B020354EE
     47:0801D800248314500302036AA2
     48:0E01E000F582EA8DF0A4A8F0EA8EF0A428F8CB
     49:0E01EE00E435F0F9EB8DF0A428E935F0F9E4E2
     50:0E01FC0033CA8FF0A429F9EA35F0FAEBF88E39
     51:0E020A00F0A429F9EA35F0FAE433FBEC8DF0AC
     52:0E021800A429F9EA35F0FAE43BFBE88FF0A4E4
     53:0E0226002AFAEB35F0FBE433CCFD8EF0A42A6F
     54:0E023400FAEB35F0FBE43CFCED8FF0A42BFB65
     55:0A024200EC35F0FC20E70312027D0A
     56:03024C0002033377
     57:0D024F00AA82AB83A2F73392D16002D2F7EE
     58:0E025C00F582ACF0E58124F9F8E6FD08E6FE37
     59:0E026A000886F008E6A2F73392D56002D2F7BC
     60:05027800F583AFF02248
    1461:06003700E478FFF6D8FD9D
     62:02027D00780403
     63:0E027F00EC700DC9CACBFCE58224F8F582D8DC
     64:02028D00F1225C
     65:02028F007820D5
     66:0E02910020E7111582C3E933F9EA33FAEB33A3
     67:06029F00FBEC33FCD8EC7F
     68:0102A5002236
    1569:080015007900E94400601B7A48
    16 :05001D00009000C07816
     70:05001D000090051378BE
    1771:030022000075A0C6
    1872:0A00250000E493F2A308B8000205FE
    1973:08002F00A0D9F4DAF275A0FF7C
     74:0302A60012024FF2
     75:0902A9007900E583B58202800DA5
     76:0502B20050031203825D
     77:0802B700E583C3958212045F88
     78:0802BF00E5D0C465D020E11771
     79:0E02C700EA2DFAEB3EFBEC3FFC5009740112ED
     80:0602D500045FEC4480FC14
     81:0302DB00020333E8
     82:0E02DE00C3EA9DFAEB9EFBEC9FFC500FC3E4BD
     83:0D02EC0099F9E49AFAE49BFBE49CFCB2D182
     84:0602F90012027D02033336
    2085:08003D007800E84400600A7934
    2186:030045000075A0A3
     
    2388:08004E007800E84400600C7921
    2489:0B00560000900000E4F0A3D8FCD9FAF1
    25 :03000800758107F8
    26 :0A000B001200BCE58260030200034E
    27 :0400BC007582002227
     90:0E02FF001204A2700AE582458345F0700122C8
     91:01030D00E40B
     92:03030E0030D112D9
     93:0E031100F4700BE5F0F47006E58330E701228E
     94:04031F0090800022A8
     95:0C032300700AE5F07006E58320E7012277
     96:04032F00907FFF229A
     97:06033300B98003EA13B3D8
     98:0E0339004010EA2401FAE43BFBE43CFC5004D3
     99:040347007C8005822F
     100:09034B00BC000EBB000BBA000857
     101:08035400E4F5F0F583F58222C7
     102:0E035C00A2D1E582138CF092F78B838A822265
     103:0D036A00E4F583F58275F080F4A2D1132232
     104:0B037700E4F583F58275F0C0747F226E
     105:0E038200E582C583F582A2D133A2D592D113B4
     106:0C03900092D5ECCFFCEBCEFBEACDFA22BC
     107:08039C0012024F30D502B2D16C
     108:0903A400BF0009BC00030203774D
     109:0303AD0002036ADE
     110:0603B000BC00030203542F
     111:0D03B600E583B4FF0BE582B4FF030203777B
     112:0303C300020354DE
     113:0803C600E582B4FF0302036AA3
     114:0C03CE00C395835007247F400B020354AA
     115:0803DA00248014500302036AA1
     116:0E03E200F582C3ED9AEE9BEF9C40111582C38D
     117:0E03F000EA33F9EB33FAEC33FBE433FC80051F
     118:0503FE00E4CCCBCAF9BC
     119:05040300C08275F01934
     120:0E040800C3E99DEA9EEB9FEC9400D5F00280C4
     121:010416002DB8
     122:0E041700400EE99DF9EA9EFAEB9FFBEC940083
     123:02042500FCC316
     124:0E042700B3E833F8E58233F582E58333F583DD
     125:0E043500C3E933F9EA33FAEB33FBEC33FC8016
     126:01044300C4F4
     127:0E044400B3E4F938FAE43582FBE43583FCD0EA
     128:0704520082500405827C804A
     129:0604590012027D02034BBC
     130:03000800758113EC
     131:0A000B001204FDE582600302000309
     132:09045F006040F82582500274FF90
     133:0E046800F582E824F8501ECCCBCAF9E4CC246F
     134:0E047600F85014CBCAF9E4CB24F8500BCAF9A5
     135:09048400E4CA24F85003790022B7
     136:05048D0024086010F8D6
     137:0E049200C3EC13FCEB13FBEA13FAE913F9D8E1
     138:0104A000F16A
     139:0104A1002238
     140:0A04A200120501C3749E95824039D3
     141:0804AC00790012045F30D12633
     142:0E04B400E9F42401F582EAF43400F583EBF458
     143:0E04C2003400F5F0ECF43400700AE582458356
     144:0504D00045F07001225F
     145:0104D500E442
     146:0404D60030E70F22DA
     147:0B04DA00EC20E71489828A838BF0225B
     148:0304E50030D10A09
     149:0A04E800E4F582F583F5F07480223C
     150:0B04F20074FFF582F583F5F0747F22A3
     151:0404FD0075820022E2
     152:0D050100AA82AB83A2F73392D16002D2F739
     153:05050E00F582ACF022B3
    28154:00000001FF
Note: See TracChangeset for help on using the changeset viewer.