Changeset 2321


Ignore:
Timestamp:
Sep 3, 2012, 4:44:08 PM (7 years ago)
Author:
campbell
Message:

Add toolstick branch of the prototype.

Location:
Deliverables/D2.2/8051-toolstick
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051-toolstick/src/ASM/ASMInterpret.ml

    r1708 r2321  
    387387    "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
    388388
    389 (* timings taken from SIEMENS *)
     389(* timings taken from C8051F33x.pdf; higher figure taken for variable time ops *)
    390390
    391391let fetch pmem pc =
     
    400400      (a10,a9,a8,true),(false,false,false,true) ->
    401401        let pc,b1 = next pc in
    402         `ACALL (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2
     402        `ACALL (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 3
    403403    | (false,false,true,false),(true,r1,r2,r3) ->
    404404      `ADD (`A,`REG (r1,r2,r3)), pc, 1
    405405    | (false,false,true,false),(false,true,false,true) ->
    406406      let pc,b1 = next pc in
    407       `ADD (`A,`DIRECT b1), pc, 1
     407      `ADD (`A,`DIRECT b1), pc, 2
    408408    | (false,false,true,false),(false,true,true,i1) ->
    409       `ADD (`A,`INDIRECT i1), pc, 1
     409      `ADD (`A,`INDIRECT i1), pc, 2
    410410    | (false,false,true,false),(false,true,false,false) ->
    411411      let pc,b1 = next pc in
    412       `ADD (`A,`DATA b1), pc, 1
     412      `ADD (`A,`DATA b1), pc, 2
    413413    | (false,false,true,true),(true,r1,r2,r3) ->
    414414      `ADDC (`A,`REG (r1,r2,r3)), pc, 1
    415415    | (false,false,true,true),(false,true,false,true) ->
    416416      let pc,b1 = next pc in
    417       `ADDC (`A,`DIRECT b1), pc, 1
     417      `ADDC (`A,`DIRECT b1), pc, 2
    418418    | (false,false,true,true),(false,true,true,i1) ->
    419       `ADDC (`A,`INDIRECT i1), pc, 1
     419      `ADDC (`A,`INDIRECT i1), pc, 2
    420420    | (false,false,true,true),(false,true,false,false) ->
    421421      let pc,b1 = next pc in
    422       `ADDC (`A,`DATA b1), pc, 1
     422      `ADDC (`A,`DATA b1), pc, 2
    423423    | (a10,a9,a8,false),(false,false,false,true) ->
    424424      let pc,b1 = next pc in
    425       `AJMP (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2
     425      `AJMP (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 3
    426426    | (false,true,false,true),(true,r1,r2,r3) ->
    427427      `ANL (`U1 (`A, `REG (r1,r2,r3))), pc, 1
    428428    | (false,true,false,true),(false,true,false,true) ->
    429429      let pc,b1 = next pc in
    430       `ANL (`U1 (`A, `DIRECT b1)), pc, 1
     430      `ANL (`U1 (`A, `DIRECT b1)), pc, 2
    431431    | (false,true,false,true),(false,true,true,i1) ->
    432       `ANL (`U1 (`A, `INDIRECT i1)), pc, 1
     432      `ANL (`U1 (`A, `INDIRECT i1)), pc, 2
    433433    | (false,true,false,true),(false,true,false,false) ->
    434434      let pc,b1 = next pc in
    435       `ANL (`U1 (`A, `DATA b1)), pc, 1
     435      `ANL (`U1 (`A, `DATA b1)), pc, 2
    436436    | (false,true,false,true),(false,false,true,false) ->
    437437      let pc,b1 = next pc in
    438       `ANL (`U2 (`DIRECT b1,`A)), pc, 1
     438      `ANL (`U2 (`DIRECT b1,`A)), pc, 2
    439439    | (false,true,false,true),(false,false,true,true) ->
    440440      let pc,b1 = next pc in
    441441      let pc,b2 = next pc in
    442       `ANL (`U2 (`DIRECT b1,`DATA b2)), pc, 2
     442      `ANL (`U2 (`DIRECT b1,`DATA b2)), pc, 3
    443443    | (true,false,false,false),(false,false,true,false) ->
    444444      let pc,b1 = next pc in
     
    450450      let pc,b1 = next pc in
    451451      let pc,b2 = next pc in
    452       `CJNE (`U1 (`A, `DIRECT b1), `REL b2), pc, 2
     452      `CJNE (`U1 (`A, `DIRECT b1), `REL b2), pc, 4
    453453    | (true,false,true,true),(false,true,false,false) ->
    454454      let pc,b1 = next pc in
    455455      let pc,b2 = next pc in
    456       `CJNE (`U1 (`A, `DATA b1), `REL b2), pc, 2
     456      `CJNE (`U1 (`A, `DATA b1), `REL b2), pc, 4
    457457    | (true,false,true,true),(true,r1,r2,r3) ->
    458458      let pc,b1 = next pc in
    459459      let pc,b2 = next pc in
    460       `CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2), pc, 2
     460      `CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2), pc, 4
    461461    | (true,false,true,true),(false,true,true,i1) ->
    462462      let pc,b1 = next pc in
    463463      let pc,b2 = next pc in
    464       `CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2), pc, 2
     464      `CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2), pc, 5
    465465    | (true,true,true,false),(false,true,false,false) ->
    466466      `CLR `A, pc, 1
     
    469469    | (true,true,false,false),(false,false,true,false) ->
    470470      let pc,b1 = next pc in
    471       `CLR (`BIT b1), pc, 1
     471      `CLR (`BIT b1), pc, 2
    472472    | (true,true,true,true),(false,true,false,false) ->
    473473      `CPL `A, pc, 1
     
    476476    | (true,false,true,true),(false,false,true,false) ->
    477477      let pc,b1 = next pc in
    478       `CPL (`BIT b1), pc, 1
     478      `CPL (`BIT b1), pc, 2
    479479    | (true,true,false,true),(false,true,false,false) ->
    480480      `DA `A, pc, 1
     
    485485    | (false,false,false,true),(false,true,false,true) ->
    486486      let pc,b1 = next pc in
    487       `DEC (`DIRECT b1), pc, 1
     487      `DEC (`DIRECT b1), pc, 2
    488488    | (false,false,false,true),(false,true,true,i1) ->
    489       `DEC (`INDIRECT i1), pc, 1
     489      `DEC (`INDIRECT i1), pc, 2
    490490    | (true,false,false,false),(false,true,false,false) ->
    491       `DIV (`A, `B), pc, 4
     491      `DIV (`A, `B), pc, 8
    492492    | (true,true,false,true),(true,r1,r2,r3) ->
    493493      let pc,b1 = next pc in
    494       `DJNZ (`REG(r1,r2,r3), `REL b1), pc, 2
     494      `DJNZ (`REG(r1,r2,r3), `REL b1), pc, 3
    495495    | (true,true,false,true),(false,true,false,true) ->
    496496      let pc,b1 = next pc in
    497497      let pc,b2 = next pc in
    498       `DJNZ (`DIRECT b1, `REL b2), pc, 2
     498      `DJNZ (`DIRECT b1, `REL b2), pc, 4
    499499    | (false,false,false,false),(false,true,false,false) ->
    500500      `INC `A, pc, 1
     
    503503    | (false,false,false,false),(false,true,false,true) ->
    504504      let pc,b1 = next pc in
    505       `INC (`DIRECT b1), pc, 1
     505      `INC (`DIRECT b1), pc, 2
    506506    | (false,false,false,false),(false,true,true,i1) ->
    507       `INC (`INDIRECT i1), pc, 1
     507      `INC (`INDIRECT i1), pc, 2
    508508    | (true,false,true,false),(false,false,true,true) ->
    509       `INC `DPTR, pc, 2
     509      `INC `DPTR, pc, 1
    510510    | (false,false,true,false),(false,false,false,false) ->
    511511      let pc,b1 = next pc in
    512512      let pc,b2 = next pc in
    513       `JB (`BIT b1, `REL b2), pc, 2
     513      `JB (`BIT b1, `REL b2), pc, 4
    514514    | (false,false,false,true),(false,false,false,false) ->
    515515      let pc,b1 = next pc in
    516516      let pc,b2 = next pc in
    517       `JBC (`BIT b1, `REL b2), pc, 2
     517      `JBC (`BIT b1, `REL b2), pc, 4
    518518    | (false,true,false,false),(false,false,false,false) ->
    519519      let pc,b1 = next pc in
    520       `JC (`REL b1), pc, 2
     520      `JC (`REL b1), pc, 3
    521521    | (false,true,true,true),(false,false,true,true) ->
    522       `JMP `IND_DPTR, pc, 2
     522      `JMP `IND_DPTR, pc, 3
    523523    | (false,false,true,true),(false,false,false,false) ->
    524524      let pc,b1 = next pc in
    525525      let pc,b2 = next pc in
    526       `JNB (`BIT b1, `REL b2), pc, 2
     526      `JNB (`BIT b1, `REL b2), pc, 4
    527527    | (false,true,false,true),(false,false,false,false) ->
    528528      let pc,b1 = next pc in
    529       `JNC (`REL b1), pc, 2
     529      `JNC (`REL b1), pc, 3
    530530    | (false,true,true,true),(false,false,false,false) ->
    531531      let pc,b1 = next pc in
    532       `JNZ (`REL b1), pc, 2
     532      `JNZ (`REL b1), pc, 3
    533533    | (false,true,true,false),(false,false,false,false) ->
    534534      let pc,b1 = next pc in
    535       `JZ (`REL b1), pc, 2
     535      `JZ (`REL b1), pc, 3
    536536    | (false,false,false,true),(false,false,true,false) ->
    537537      let pc,b1 = next pc in
    538538      let pc,b2 = next pc in
    539       `LCALL (`ADDR16 (mk_word b1 b2)), pc, 2
     539      `LCALL (`ADDR16 (mk_word b1 b2)), pc, 4
    540540    | (false,false,false,false),(false,false,true,false) ->
    541541      let pc,b1 = next pc in
    542542      let pc,b2 = next pc in
    543       `LJMP (`ADDR16 (mk_word b1 b2)), pc, 2
     543      `LJMP (`ADDR16 (mk_word b1 b2)), pc, 4
    544544   | (true,true,true,false),(true,r1,r2,r3) ->
    545545         `MOV (`U1 (`A, `REG(r1,r2,r3))), pc, 1
    546546   | (true,true,true,false),(false,true,false,true) ->
    547547       let pc,b1 = next pc in
    548          `MOV (`U1 (`A, `DIRECT b1)), pc, 1
     548         `MOV (`U1 (`A, `DIRECT b1)), pc, 2
    549549   | (true,true,true,false),(false,true,true,i1) ->
    550          `MOV (`U1 (`A, `INDIRECT i1)), pc, 1
     550         `MOV (`U1 (`A, `INDIRECT i1)), pc, 2
    551551   | (false,true,true,true),(false,true,false,false) ->
    552552       let pc,b1 = next pc in
    553          `MOV (`U1 (`A, `DATA b1)), pc, 1
     553         `MOV (`U1 (`A, `DATA b1)), pc, 2
    554554   | (true,true,true,true),(true,r1,r2,r3) ->
    555555         `MOV (`U2 (`REG(r1,r2,r3), `A)), pc, 1
     
    559559   | (false,true,true,true),(true,r1,r2,r3) ->
    560560       let pc,b1 = next pc in
    561          `MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))), pc, 1
     561         `MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))), pc, 2
    562562   | (true,true,true,true),(false,true,false,true) ->
    563563       let pc,b1 = next pc in
    564          `MOV (`U3 (`DIRECT b1, `A)), pc, 1
     564         `MOV (`U3 (`DIRECT b1, `A)), pc, 2
    565565   | (true,false,false,false),(true,r1,r2,r3) ->
    566566       let pc,b1 = next pc in
     
    569569       let pc,b1 = next pc in
    570570       let pc,b2 = next pc in
    571          `MOV (`U3 (`DIRECT b1, `DIRECT b2)), pc, 2
     571         `MOV (`U3 (`DIRECT b1, `DIRECT b2)), pc, 3
    572572   | (true,false,false,false),(false,true,true,i1) ->
    573573       let pc,b1 = next pc in
     
    578578         `MOV (`U3 (`DIRECT b1, `DATA b2)), pc, 3
    579579   | (true,true,true,true),(false,true,true,i1) ->
    580          `MOV (`U2 (`INDIRECT i1, `A)), pc, 1
     580         `MOV (`U2 (`INDIRECT i1, `A)), pc, 2
    581581   | (true,false,true,false),(false,true,true,i1) ->
    582582       let pc,b1 = next pc in
     
    584584   | (false,true,true,true),(false,true,true,i1) ->
    585585       let pc,b1 = next pc in
    586          `MOV (`U2 (`INDIRECT i1, `DATA b1)), pc, 1
     586         `MOV (`U2 (`INDIRECT i1, `DATA b1)), pc, 2
    587587   | (true,false,true,false),(false,false,true,false) ->
    588588       let pc,b1 = next pc in
    589          `MOV (`U5 (`C, `BIT b1)), pc, 1
     589         `MOV (`U5 (`C, `BIT b1)), pc, 2
    590590   | (true,false,false,true),(false,false,true,false) ->
    591591       let pc,b1 = next pc in
     
    594594       let pc,b1 = next pc in
    595595       let pc,b2 = next pc in
    596          `MOV (`U4 (`DPTR, `DATA16(mk_word b1 b2))), pc, 2
     596         `MOV (`U4 (`DPTR, `DATA16(mk_word b1 b2))), pc, 3
    597597   | (true,false,false,true),(false,false,true,true) ->
    598          `MOVC (`A, `A_DPTR), pc, 2
     598         `MOVC (`A, `A_DPTR), pc, 3
    599599   | (true,false,false,false),(false,false,true,true) ->
    600          `MOVC (`A, `A_PC), pc, 2
     600         `MOVC (`A, `A_PC), pc, 3
    601601   | (true,true,true,false),(false,false,true,i1) ->
    602          `MOVX (`U1 (`A, `EXT_INDIRECT i1)), pc, 2
     602         `MOVX (`U1 (`A, `EXT_INDIRECT i1)), pc, 3
    603603   | (true,true,true,false),(false,false,false,false) ->
    604          `MOVX (`U1 (`A, `EXT_IND_DPTR)), pc, 2
     604         `MOVX (`U1 (`A, `EXT_IND_DPTR)), pc, 3
    605605   | (true,true,true,true),(false,false,true,i1) ->
    606          `MOVX (`U2 (`EXT_INDIRECT i1, `A)), pc, 2
     606         `MOVX (`U2 (`EXT_INDIRECT i1, `A)), pc, 3
    607607   | (true,true,true,true),(false,false,false,false) ->
    608          `MOVX (`U2 (`EXT_IND_DPTR, `A)), pc, 2
     608         `MOVX (`U2 (`EXT_IND_DPTR, `A)), pc, 3
    609609   | (true,false,true,false),(false,true,false,false) ->
    610610         `MUL(`A, `B), pc, 4
     
    615615   | (false,true,false,false),(false,true,false,true) ->
    616616       let pc,b1 = next pc in
    617          `ORL (`U1(`A, `DIRECT b1)), pc, 1
     617         `ORL (`U1(`A, `DIRECT b1)), pc, 2
    618618   | (false,true,false,false),(false,true,true,i1) ->
    619          `ORL (`U1(`A, `INDIRECT i1)), pc, 1
     619         `ORL (`U1(`A, `INDIRECT i1)), pc, 2
    620620   | (false,true,false,false),(false,true,false,false) ->
    621621       let pc,b1 = next pc in
    622          `ORL (`U1(`A, `DATA b1)), pc, 1
     622         `ORL (`U1(`A, `DATA b1)), pc, 2
    623623   | (false,true,false,false),(false,false,true,false) ->
    624624       let pc,b1 = next pc in
    625          `ORL (`U2(`DIRECT b1, `A)), pc, 1
     625         `ORL (`U2(`DIRECT b1, `A)), pc, 2
    626626   | (false,true,false,false),(false,false,true,true) ->
    627627       let pc,b1 = next pc in
    628628       let pc,b2 = next pc in
    629          `ORL (`U2 (`DIRECT b1, `DATA b2)), pc, 2
     629         `ORL (`U2 (`DIRECT b1, `DATA b2)), pc, 3
    630630   | (false,true,true,true),(false,false,true,false) ->
    631631       let pc,b1 = next pc in
     
    641641         `PUSH (`DIRECT b1), pc, 2
    642642   | (false,false,true,false),(false,false,true,false) ->
    643          `RET, pc, 2
     643         `RET, pc, 5
    644644   | (false,false,true,true),(false,false,true,false) ->
    645          `RETI, pc, 2
     645         `RETI, pc, 5
    646646   | (false,false,true,false),(false,false,true,true) ->
    647647         `RL `A, pc, 1
     
    656656   | (true,true,false,true),(false,false,true,false) ->
    657657       let pc,b1 = next pc in
    658          `SETB (`BIT b1), pc, 1
     658         `SETB (`BIT b1), pc, 2
    659659   | (true,false,false,false),(false,false,false,false) ->
    660660       let pc,b1 = next pc in
    661          `SJMP (`REL b1), pc, 2
     661         `SJMP (`REL b1), pc, 3
    662662   | (true,false,false,true),(true,r1,r2,r3) ->
    663663       `SUBB (`A, `REG(r1,r2,r3)), pc, 1
    664664   | (true,false,false,true),(false,true,false,true) ->
    665665       let pc,b1 = next pc in
    666          `SUBB (`A, `DIRECT b1), pc, 1
     666         `SUBB (`A, `DIRECT b1), pc, 2
    667667   | (true,false,false,true),(false,true,true,i1) ->
    668          `SUBB (`A, `INDIRECT i1), pc, 1
     668         `SUBB (`A, `INDIRECT i1), pc, 2
    669669   | (true,false,false,true),(false,true,false,false) ->
    670670       let pc,b1 = next pc in
    671          `SUBB (`A, `DATA b1), pc, 1
     671         `SUBB (`A, `DATA b1), pc, 2
    672672   | (true,true,false,false),(false,true,false,false) ->
    673673         `SWAP `A, pc, 1
     
    676676   | (true,true,false,false),(false,true,false,true) ->
    677677       let pc,b1 = next pc in
    678          `XCH (`A, `DIRECT b1), pc, 1
     678         `XCH (`A, `DIRECT b1), pc, 2
    679679   | (true,true,false,false),(false,true,true,i1) ->
    680          `XCH (`A, `INDIRECT i1), pc, 1
     680         `XCH (`A, `INDIRECT i1), pc, 2
    681681   | (true,true,false,true),(false,true,true,i1) ->
    682          `XCHD(`A, `INDIRECT i1), pc, 1
     682         `XCHD(`A, `INDIRECT i1), pc, 2
    683683   | (false,true,true,false),(true,r1,r2,r3) ->
    684684         `XRL(`U1(`A, `REG(r1,r2,r3))), pc, 1
    685685   | (false,true,true,false),(false,true,false,true) ->
    686686       let pc,b1 = next pc in
    687          `XRL(`U1(`A, `DIRECT b1)), pc, 1
     687         `XRL(`U1(`A, `DIRECT b1)), pc, 2
    688688   | (false,true,true,false),(false,true,true,i1) ->
    689          `XRL(`U1(`A, `INDIRECT i1)), pc, 1
     689         `XRL(`U1(`A, `INDIRECT i1)), pc, 2
    690690   | (false,true,true,false),(false,true,false,false) ->
    691691       let pc,b1 = next pc in
    692          `XRL(`U1(`A, `DATA b1)), pc, 1
     692         `XRL(`U1(`A, `DATA b1)), pc, 2
    693693   | (false,true,true,false),(false,false,true,false) ->
    694694       let pc,b1 = next pc in
    695          `XRL(`U2(`DIRECT b1, `A)), pc, 1
     695         `XRL(`U2(`DIRECT b1, `A)), pc, 2
    696696   | (false,true,true,false),(false,false,true,true) ->
    697697       let pc,b1 = next pc in
    698698       let pc,b2 = next pc in
    699          `XRL(`U2(`DIRECT b1, `DATA b2)), pc, 2
     699         `XRL(`U2(`DIRECT b1, `DATA b2)), pc, 3
    700700   | (true,false,true,false),(false,true,false,true) ->
    701701       (* undefined opcode *) assert false
  • Deliverables/D2.2/8051-toolstick/src/ASM/I8051.ml

    r1589 r2321  
    178178let spl_init = 255
    179179let sph_addr = sph
    180 let sph_init = 255
     180let sph_init = 2
    181181let isp_addr = 129
    182182let isp_init = 47
     
    210210
    211211(* External RAM size *)
    212 let ext_ram_size = MiscPottier.pow 2 16
     212let ext_ram_size = MiscPottier.pow 2 12
    213213(* Internal RAM size *)
    214214let int_ram_size = MiscPottier.pow 2 8
  • Deliverables/D2.2/8051-toolstick/src/LIN/LINToASM.ml

    r1580 r2321  
    157157    | None -> []
    158158    | Some main ->
    159       [`MOV (`U3 (`DIRECT (byte_of_int I8051.isp_addr),
     159      (* Disable watchdog timer and initialise *)
     160      [`MOV (`U3 (`DIRECT (byte_of_int 0xD9), data_of_int 0));
     161       `MOV (`U3 (`DIRECT (byte_of_int I8051.isp_addr),
    160162                  data_of_int I8051.isp_init)) ;
    161163       `MOV (`U3 (`DIRECT (byte_of_int I8051.spl_addr),
  • Deliverables/D2.2/8051-toolstick/src/RTLabs/RTLabsToRTL.ml

    r1635 r2321  
    422422      let insts_rest = List.map f_rest rest in
    423423      let insts = firsts @ insts_rest in
     424      (* Set the carry flag if >0, then dump that in the destination *)
     425      let squash_result =
     426        [RTL.St_op2 (I8051.Add, destr, RTL.Reg destr, RTL.Imm 255, start_lbl);
     427         RTL.St_op2 (I8051.Addc, destr, RTL.Imm 0, RTL.Imm 0, start_lbl)] in
    424428      let epilogue = translate_cst (AST.Cst_int 0) destrs in
    425       add_translates [ adds_graph insts ; epilogue] start_lbl dest_lbl def
     429      add_translates [ adds_graph (insts @ squash_result); epilogue]
     430        start_lbl dest_lbl def
    426431
    427432(* this requires destrs to be either 0 or 1 to be truly correct
Note: See TracChangeset for help on using the changeset viewer.