Project

General

Profile

« Previous | Next » 

Revision aaa8e454

Added by LĂ©lio Brun 7 months ago

it works

View differences:

src/clock_calculus.ml
517 517
and clock_expr ?(nocarrier=true) env expr =
518 518
  let resulting_ck = 
519 519
    match expr.expr_desc with
520
      | Expr_const _ ->
520
    | Expr_const _ ->
521 521
      let ck = new_var true in
522 522
      expr.expr_clock <- ck;
523 523
      ck
524
  | Expr_ident v ->
524
    | Expr_ident v ->
525 525
      let ckv =
526 526
        try
527 527
          Env.lookup_value env v
528 528
        with Not_found -> 
529
	  failwith ("Internal error, variable \""^v^"\" not found")
529
          failwith ("Internal error, variable \""^v^"\" not found")
530 530
      in
531 531
      let ck = instantiate (ref []) (ref []) ckv in
532 532
      expr.expr_clock <- ck;
533 533
      ck
534
  | Expr_array elist ->
535
    let ck = clock_standard_args env elist in
536
    expr.expr_clock <- ck;
537
    ck
538
  | Expr_access (e1, _) ->
539
    (* dimension, being a static value, doesn't need to be clocked *)
540
    let ck = clock_standard_args env [e1] in
541
    expr.expr_clock <- ck;
542
    ck
543
  | Expr_power (e1, _) ->
544
    (* dimension, being a static value, doesn't need to be clocked *)
545
    let ck = clock_standard_args env [e1] in
546
    expr.expr_clock <- ck;
547
    ck
548
  | Expr_tuple elist ->
549
    let ck = new_ck (Ctuple (List.map (clock_expr env) elist)) true in
550
    expr.expr_clock <- ck;
551
    ck
552
  | Expr_ite (c, t, e) ->
553
    let ck_c = clock_standard_args env [c] in
554
    let ck = clock_standard_args env [t; e] in
555
    (* Here, the branches may exhibit a tuple clock, not the condition *)
556
    unify_tuple_clock (Some ck_c) ck expr.expr_loc;
557
    expr.expr_clock <- ck;
558
    ck
559
  | Expr_appl (id, args, r) ->
560
    (try
561
(* for a modular compilation scheme, all inputs/outputs must share the same clock !
562
   this is also the reset clock !
563
*)
564
    let cr =
565
      match r with
566
      | None        -> new_var true
567
      | Some c      -> clock_standard_args env [c] in
568
    let couts = clock_appl env id args (clock_uncarry cr) expr.expr_loc in
569
    expr.expr_clock <- couts;
570
    couts
571
    with exn -> (
572
      Format.eprintf "Current expr: %a@." Printers.pp_expr expr; 
573
      raise exn
574
    ))
575
  | Expr_fby (e1,e2)
576
  | Expr_arrow (e1,e2) ->
577
    let ck = clock_standard_args env [e1; e2] in
578
    unify_tuple_clock None ck expr.expr_loc;
579
    expr.expr_clock <- ck;
580
    ck
581
  | Expr_pre e -> (* todo : deal with phases as in tail ? *)
534
    | Expr_array elist ->
535
      let ck = clock_standard_args env elist in
536
      expr.expr_clock <- ck;
537
      ck
538
    | Expr_access (e1, _) ->
539
      (* dimension, being a static value, doesn't need to be clocked *)
540
      let ck = clock_standard_args env [e1] in
541
      expr.expr_clock <- ck;
542
      ck
543
    | Expr_power (e1, _) ->
544
      (* dimension, being a static value, doesn't need to be clocked *)
545
      let ck = clock_standard_args env [e1] in
546
      expr.expr_clock <- ck;
547
      ck
548
    | Expr_tuple elist ->
549
      let ck = new_ck (Ctuple (List.map (clock_expr env) elist)) true in
550
      expr.expr_clock <- ck;
551
      ck
552
    | Expr_ite (c, t, e) ->
553
      let ck_c = clock_standard_args env [c] in
554
      let ck = clock_standard_args env [t; e] in
555
      (* Here, the branches may exhibit a tuple clock, not the condition *)
556
      unify_tuple_clock (Some ck_c) ck expr.expr_loc;
557
      expr.expr_clock <- ck;
558
      ck
559
    | Expr_appl (id, args, r) ->
560
      (try
561
         (* for a modular compilation scheme, all inputs/outputs must share the same clock !
562
            this is also the reset clock !
563
         *)
564
         let cr =
565
           match r with
566
           | None        -> new_var true
567
           | Some c      -> clock_standard_args env [c] in
568
         let couts = clock_appl env id args (clock_uncarry cr) expr.expr_loc in
569
         expr.expr_clock <- couts;
570
         couts
571
       with exn -> (
572
           Format.eprintf "Current expr: %a@." Printers.pp_expr expr;
573
           raise exn
574
         ))
575
    | Expr_fby (e1,e2)
576
    | Expr_arrow (e1,e2) ->
577
      let ck = clock_standard_args env [e1; e2] in
578
      unify_tuple_clock None ck expr.expr_loc;
579
      expr.expr_clock <- ck;
580
      ck
581
    | Expr_pre e -> (* todo : deal with phases as in tail ? *)
582 582
      let ck = clock_standard_args env [e] in
583 583
      expr.expr_clock <- ck;
584 584
      ck
585
  | Expr_when (e,c,l) ->
585
    | Expr_when (e,c,l) ->
586 586
      let ce = clock_standard_args env [e] in
587 587
      let c_loc = loc_of_cond expr.expr_loc c in
588 588
      let cr = clock_carrier env c c_loc ce in
......
591 591
      let ck' = clock_on ce cr' l in
592 592
      expr.expr_clock <- ck';
593 593
      ck
594
  | Expr_merge (c,hl) ->
594
    | Expr_merge (c,hl) ->
595 595
      let cvar = new_var true in
596 596
      let crvar = new_carrier Carry_name true in
597
      List.iter (fun (t, h) -> let ckh = clock_uncarry (clock_expr env h) in unify_tuple_clock (Some (new_ck (Con (cvar,crvar,t)) true)) ckh h.expr_loc) hl;
597
      List.iter (fun (t, h) ->
598
          let ckh = clock_uncarry (clock_expr env h) in
599
          unify_tuple_clock (Some (new_ck (Con (cvar,crvar,t)) true)) ckh h.expr_loc) hl;
598 600
      let cr = clock_carrier env c expr.expr_loc cvar in
599 601
      try_unify_carrier cr crvar expr.expr_loc;
600 602
      let cres = clock_current ((snd (List.hd hl)).expr_clock) in

Also available in: Unified diff