Commit 09dd7a0e authored by Aliaume Lopez's avatar Aliaume Lopez

Coherence and Readme

parent 0aaecf8e
......@@ -12,12 +12,6 @@ This program needs
## Building and running
To build the project and create the `comp` executable run
```
make comp
```
To run the tests use
```
......@@ -51,12 +45,63 @@ The basic circuits are the following ones
4. The trace operator
5. The switch operator
### Linking
...
### Syntax Definition
#### Constant circuits
The constant circuits are in capital letters. The following circuits are available
* FORK
* JOIN
* MUX
* NMOS
* PMOS
* BOT (value bottom)
* TOP (value illegal)
* HIGH (value high)
* LOW (value low)
* DISC (disconnect gate)
* Any other capital letter circuit is considered as a « box » with type 1->1, except `F`, `G` and `H` (for debugging purpose)
The symmetry is not a circuit yet.
#### Operators
Link operator works with the syntax
# Things that would be done differently
```
link a:b c:d ... for CIRCUIT
```
There is also the `.` for sequential composition and the `|` for parallel composition.
#### SEQ and PAR
Inside a `SEQ ... END` bloc the newlines are replaced with sequential composition of the lines (with implicit parenthesis
around each line). The same goes for parallel composition and `PAR ... END`.
1. Separate labelling from meaning : a label is just a string
2. Do all the stuff directly on liDAGS rather than the PTG version
3. Use name translation rather than a global ref count (leads to mistakes)
### Building circuits with the AST direcly
It is possible to direcly generate AST code by importing `ast.ml` and then printing it into a file
with the pretty printing function in `ast.ml`.
Ast construction is made simple by the helper functions to construct it
```ocaml
val ( === ) : circ -> circ -> circ
val ( ||| ) : circ -> circ -> circ
val vari : string -> circ
val varo : string -> circ
val const : string -> int -> int -> circ
val id : int -> circ
val idpoly : circ
val links : (string * string) list -> circ -> circ
val symmetry : circ
val trace : circ -> circ
val bindi : string -> circ -> circ
val bindo : string -> circ -> circ
val empty : circ
val print_ast : circ -> string
```
......@@ -93,7 +93,7 @@ let id x = Circ (Id x);;
let idpoly = Circ IdPoly;;
let links l c = Circ (Links (l,c));;
let twist =
let symmetry =
let x = newvarname () in
let y = newvarname () in
let z = newvarname () in
......
......@@ -295,6 +295,7 @@ let () =
"lines.txt"
in
let x = ref (get_ptg_of_file file) in
x := Rewriting.normal_timed_form !x;
report "INIT" !x;
report "INIT" (snd (Rewriting.rewrite_delays !x));
......
......@@ -135,7 +135,7 @@ let test5 =
bindi "x" ((id 1 ||| vari "x") === const "F" 2 1);;
let test6 =
const "F" 2 2 === twist === const "G" 2 2;;
const "F" 2 2 === symmetry === const "G" 2 2;;
let tests = List.mapi (fun i x -> ("test " ^ string_of_int i, fun () -> typecheck_and_compile x; ()))
[ test1a; test1b; test1c; test2; test3; test4; test5; test6 ];;
......@@ -155,8 +155,8 @@ let circuit_of_name = function
| "F" -> const "F" 1 1
| "G" -> const "G" 1 1
| "H" -> const "H" 2 2
| "P" -> const "PMOS" 2 1
| "N" -> const "NMOS" 2 1
| "PMOS" -> const "PMOS" 2 1
| "NMOS" -> const "NMOS" 2 1
| "HIGH" -> const "HIGH" 0 1
| "LOW" -> const "LOW" 0 1
| "MUX" -> const "MUX" 3 1
......
......@@ -406,6 +406,11 @@ let rewrite_delays g1 =
|> mk_join ~fst:new_delays
~snd:g2.oports
~towards:new_outputs
(* TODO do it more efficiently !!!
* We already know the delay nodes
* that are added !
*)
|> normal_timed_form
in
(new_trace, new_ptg);;
......@@ -421,12 +426,10 @@ let unfold_trace g1 =
let (pre2,g2) = rewrite_delays (snd (replicate g1)) in
let (pre1,post1,g1) = trace_split g1 in
(*let (pre2,post2,g2) = trace_split g2 in *)
let new_inputs = newids (List.length g1.iports) in
ptg_merge g1 g2
(*|> batch ~f:(label_set ~label:Disconnect) ~nodes:post2 *)
|> batch ~f:(label_set ~label:Disconnect) ~nodes:g1.oports
|> mk_fork ~from:post1 ~fst:pre2 ~snd:pre1
......
......@@ -286,7 +286,7 @@ let test5 =
bindi "x" ((id 1 ||| vari "x") === const "F" 2 1);;
let test6 =
const "F" 2 2 === twist === const "G" 2 2;;
const "F" 2 2 === symmetry === const "G" 2 2;;
let tests = [
("test1 a", fun () -> let _ = calcul_type test1a in ());
......@@ -296,6 +296,6 @@ let tests = [
("test3", fun () -> let _ = calcul_type test3 in ());
("test trace", fun () -> let _ = calcul_type test4 in ());
("test bind", fun () -> let _ = calcul_type test5 in ());
("test twist", fun () -> let _ = calcul_type test6 in ());
("test symmetry", fun () -> let _ = calcul_type test6 in ());
];;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment