summaryrefslogtreecommitdiff
path: root/tp1/netlist_parser.mly
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2013-11-04 22:05:57 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2013-11-04 22:05:57 +0100
commitcebd07b64f1f537c5ecf00ec21ff4b7c4032f0a3 (patch)
tree9d2048313fe3ad4c92865c8f0236bed24e64449b /tp1/netlist_parser.mly
parentf253f98136def21b5e50c5922246e2ddfe315442 (diff)
downloadSystDigit-Projet-cebd07b64f1f537c5ecf00ec21ff4b7c4032f0a3.tar.gz
SystDigit-Projet-cebd07b64f1f537c5ecf00ec21ff4b7c4032f0a3.zip
Added stub C simulator (defined dumb-down syntax for netlists).
Diffstat (limited to 'tp1/netlist_parser.mly')
-rw-r--r--tp1/netlist_parser.mly70
1 files changed, 0 insertions, 70 deletions
diff --git a/tp1/netlist_parser.mly b/tp1/netlist_parser.mly
deleted file mode 100644
index 0908703..0000000
--- a/tp1/netlist_parser.mly
+++ /dev/null
@@ -1,70 +0,0 @@
-%{
- open Netlist_ast
-
- let value_of_int n =
- let rec aux n =
- let b =
- match n mod 10 with
- | 0 -> false
- | 1 -> true
- | i -> Format.eprintf "Unexpected: %d@." i; raise Parsing.Parse_error
- in
- if n < 10 then
- [b]
- else
- b::(aux (n / 10))
- in
- match aux n with
- | [] -> Format.eprintf "Empty list@."; raise Parsing.Parse_error
- | [b] -> VBit b
- | bl -> VBitArray (Array.of_list (List.rev bl))
-%}
-
-%token <int> INT
-%token <string> NAME
-%token AND MUX NAND OR RAM ROM XOR REG NOT
-%token CONCAT SELECT SLICE
-%token COLON EQUAL COMMA VAR IN INPUT OUTPUT
-%token EOF
-
-%start program /* the entry point */
-%type <Netlist_ast.program> program
-
-%%
-program:
- INPUT inp=separated_list(COMMA, NAME)
- OUTPUT out=separated_list(COMMA, NAME)
- VAR vars=separated_list(COMMA, var) IN eqs=list(equ) EOF
- { { p_eqs = eqs; p_vars = Env.of_list vars; p_inputs = inp; p_outputs = out; } }
-
-equ:
- x=NAME EQUAL e=exp { (x, e) }
-
-exp:
- | a=arg { Earg a }
- | NOT x=arg { Enot x }
- | REG x=NAME { Ereg x }
- | AND x=arg y=arg { Ebinop(And, x, y) }
- | OR x=arg y=arg { Ebinop(Or, x, y) }
- | NAND x=arg y=arg { Ebinop(Nand, x, y) }
- | XOR x=arg y=arg { Ebinop(Xor, x, y) }
- | MUX x=arg y=arg z=arg { Emux(x, y, z) }
- | ROM addr=INT word=INT ra=arg
- { Erom(addr, word, ra) }
- | RAM addr=INT word=INT ra=arg we=arg wa=arg data=arg
- { Eram(addr, word, ra, we, wa, data) }
- | CONCAT x=arg y=arg
- { Econcat(x, y) }
- | SELECT idx=INT x=arg
- { Eselect (idx, x) }
- | SLICE min=INT max=INT x=arg
- { Eslice (min, max, x) }
-
-arg:
- | n=INT { Aconst (value_of_int n) }
- | id=NAME { Avar id }
-
-var: x=NAME ty=ty_exp { (x, ty) }
-ty_exp:
- | /*empty*/ { TBit }
- | COLON n=INT { TBitArray n }