Project

General

Profile

Download (1.53 KB) Statistics
| Branch: | Tag: | Revision:
1
(* An application that loads json provided input and produces Lustre
2

    
3
Usage:
4
lustrei -vhdl myvhdl.json 
5
lustrei -scade myscademodel.json 
6
  will produce a lustre file that can be compiled and analyzed
7

    
8
VHDL is handled in a double way: as a backend and as an import language
9
In a first step, lustrei -vhdl -print myvhdl.json shall print the VHDL model in stdout
10

    
11
 *)
12
(*
13
open Vhdl_ast
14
open Vhdl_test
15
  *)
16
open Yojson.Safe
17
open Vhdl_to_lustre
18
open Vhdl_ast_utils
19
open Vhdl_ast_map
20
open Vhdl_ast
21
open Mini_vhdl_ast
22
open Mini_vhdl_ast_pp
23
open Vhdl_ast_pp
24
open Vhdl_ast_yojson
25
open Printf
26
open Printers
27
open Format
28

    
29
let _ =
30
  (* Load model with Yojson *)
31
  let vhdl_json = from_file Sys.argv.(1) in
32

    
33
  (* Create VHDL values *)
34
  let vhdl = vhdl_file_t_of_yojson vhdl_json in
35

    
36
  (* Simplify VHDL values *)
37
  match vhdl with
38
    Ok x ->
39
      (* Parsed VHDL JSON value *)
40
      (* Format.printf "Parsed VHDL: \n%s\n" (pretty_to_string (vhdl_file_t_to_yojson x)); *)
41
      (* Fold Op vhdl_expr_t values *)
42
      let folded = replace_op_expr#vhdl_file_t x in
43
      (* Pretty-print vhdl *)
44
      Format.printf "============ Parsed VHDL ============\n%s\n" (show_vhdl_file_t folded);
45

    
46
      (* Translate vhdl_file_t value as mini_vhdl value *)
47
      let mini_vhdl = to_mini_vhdl#vhdl_design_file_t folded.design_file in
48
      Format.printf "============ Mini-VHDL ============\n%s\n" (show_mini_vhdl_design_file_t mini_vhdl);
49
      (* Pretty print lustre value *)
50
 (*     Printers.pp_prog std_formatter program; *)
51
      
52
  | Error e -> failwith (Format.sprintf "Error: %s\n" e);
(1-1/2)