summaryrefslogtreecommitdiff
path: root/minijazz/src/netlist/netlist_ast.ml
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2013-10-31 15:35:11 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2013-10-31 15:35:11 +0100
commit0b269f32dd9b8d349f94793dad44e728473e9f0a (patch)
tree066a30fee1efe19d897f5e153d7ea9aa3d7448af /minijazz/src/netlist/netlist_ast.ml
downloadSystDigit-Projet-0b269f32dd9b8d349f94793dad44e728473e9f0a.tar.gz
SystDigit-Projet-0b269f32dd9b8d349f94793dad44e728473e9f0a.zip
First commit ; includes first TP and minijazz compiler
Diffstat (limited to 'minijazz/src/netlist/netlist_ast.ml')
-rw-r--r--minijazz/src/netlist/netlist_ast.ml50
1 files changed, 50 insertions, 0 deletions
diff --git a/minijazz/src/netlist/netlist_ast.ml b/minijazz/src/netlist/netlist_ast.ml
new file mode 100644
index 0000000..00100b6
--- /dev/null
+++ b/minijazz/src/netlist/netlist_ast.ml
@@ -0,0 +1,50 @@
+type ident = string
+
+(* Environment using ident as key *)
+module Env = struct
+ include Map.Make(struct
+ type t = ident
+ let compare = compare
+ end)
+
+ let of_list l =
+ List.fold_left (fun env (x, ty) -> add x ty env) empty l
+end
+
+type ty = TBit | TBitArray of int
+type value = VBit of bool | VBitArray of bool array
+
+type binop = Or | Xor | And | Nand
+
+(* argument of operators (variable or constant) *)
+type arg =
+ | Avar of ident (* x *)
+ | Aconst of value (* constant *)
+
+(* Expressions (see MiniJazz documentation for more info on the operators) *)
+type exp =
+ | Earg of arg (* a: argument *)
+ | Ereg of ident (* REG x : register *)
+ | Enot of arg (* NOT a *)
+ | Ebinop of binop * arg * arg (* OP a1 a2 : boolean operator *)
+ | Emux of arg * arg * arg (* MUX a1 a2 : multiplexer *)
+ | Erom of int (*addr size*) * int (*word size*) * arg (*read_addr*)
+ (* ROM addr_size word_size read_addr *)
+ | Eram of int (*addr size*) * int (*word size*)
+ * arg (*read_addr*) * arg (*write_enable*)
+ * arg (*write_addr*) * arg (*data*)
+ (* RAM addr_size word_size read_addr write_enable write_addr data *)
+ | Econcat of arg * arg (* CONCAT a1 a2 : concatenation of arrays *)
+ | Eslice of int * int * arg
+ (* SLICE i1 i2 a : extract the slice of a between indices i1 and i2 *)
+ | Eselect of int * arg
+ (* SELECT i a : ith element of a *)
+
+(* equations: x = exp *)
+type equation = ident * exp
+
+type program =
+ { p_eqs : equation list; (* equations *)
+ p_inputs : ident list; (* inputs *)
+ p_outputs : ident list; (* outputs *)
+ p_vars : ty Env.t; } (* maps variables to their types*)