Ignore:
Timestamp:
Oct 18, 2010, 3:19:27 PM (9 years ago)
Author:
mulligan
Message:

Fixed type errors relating to serial output. The serial port code (for
output at least) seems to correctly simulate the compiled C code that I
sent Roberto on Friday.

File:
1 edited

Legend:

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

    r191 r193  
    1616            | `SerialBuff of [ `Eight of byte | `Nine of BitVectors.bit * byte ]];;
    1717
     18let string_of_line =
     19  function
     20    `P1 b -> "P1: " ^ hex_string_of_vect b
     21  | `P3 b -> "P2: " ^ hex_string_of_vect b
     22  | `SerialBuff (`Eight b) -> "Serial 8bit: " ^ string_of_int <*> int_of_vect b
     23  | `SerialBuff (`Nine (b, b')) -> "Serial 9bit: " ^
     24       let i = int_of_vect b' in
     25         if b then
     26           string_of_int (128 + i)
     27         else
     28           string_of_int i
     29
    1830(* In:  reception time, line of input, new continuation,
    1931   Out: transmission time, output line, expected duration until reply,
     
    2234type continuation =
    2335  [`In of time * line * continuation] option *
    24   [`Out of (time -> line -> time * continuation)] option
     36  [`Out of (time -> line -> time * continuation)]
     37
     38let rec debug_continuation =
     39 None, `Out (
     40  fun time line ->
     41    let _ = prerr_endline <*> string_of_line $ line in
     42      (time + 1),debug_continuation)
    2543
    2644(* no differentiation between internal and external code memory *)
     
    195213  expected_out_time = `None;
    196214
    197   io = (None, None) (* a real assert false: unprepared for i/o *)
     215  io = debug_continuation (* a real assert false: unprepared for i/o *)
    198216}
    199217
     
    14211439                status) in
    14221440       (* Serial port code now follows *)
    1423          let in_cont, out_cont = status.io in
     1441         let in_cont, `Out out_cont = status.io in
    14241442         let status =
    14251443           (* Serial port input *)
     
    14621480           (* Serial port output, part two *)
    14631481           if status.expected_out_time = `Now then
    1464                match out_cont with
    1465                  None -> assert false
    1466                | Some (`Out out_cont') ->
    1467                    if get_bit status.scon 7 then
    1468                      let exp_time, new_cont = out_cont' status.clock (`SerialBuff (`Nine ((get_bit status.scon 3), status.sbuf))) in
    1469                        { status with expected_out_time = `At exp_time; io = new_cont }
    1470                    else
    1471                      let exp_time, new_cont = out_cont' status.clock (`SerialBuff (`Eight status.sbuf)) in
    1472                        { status with expected_out_time = `At exp_time; io = new_cont }               
     1482             if get_bit status.scon 7 then
     1483               let exp_time, new_cont = out_cont status.clock (`SerialBuff (`Nine ((get_bit status.scon 3), status.sbuf))) in
     1484                 { status with expected_out_time = `At exp_time; io = new_cont }
     1485             else
     1486               let exp_time, new_cont = out_cont status.clock (`SerialBuff (`Eight status.sbuf)) in
     1487                 { status with expected_out_time = `At exp_time; io = new_cont }               
    14731488           else
    14741489             status
Note: See TracChangeset for help on using the changeset viewer.