Example implementation of Arm's Architecture Specification Language (ASL)
Example implementation of Arm's Architecture Specification Language (ASL).
The ASL interpreter is a collection of resources to help you to understand and make use of Arm's architecture specifications. It consists of lexer, parser, typechecker and interpreter for the ASL language and an interactive interface for evaluating ASL statements and expressions.
To build and run the ASL interpreter, you will need:
The software is provided under the BSD-3-Clause licence. Contributions to this project are accepted under the same licence.
This software includes code from one other open source projects
The CIL project
defines a useful
visitor class
for traversing C ASTs.
The file visitor.ml
is a modified copy of this class that generalizes
the type to work with an arbitrary AST.
CIL is distributed under a BSD-3-Clause licence.
This interpreter consists of a single directory organized as follows
LICENCE
- Software licenceREADME.md
- This fileasli.odocl
- Manifest (for documentation generation)Makefile
- build system file_tags
- OCaml build system configuration filelexer.mll
- ASL lexer (ocamllex file)lexersupport.ml
- indentation-based parsing supportasl.ott
- used to generate the ASL parser and abstract syntax tree (OTT file)asl_visitor.ml
- code to traverse abstract syntax treeasl_utils.ml
- code to transform abstract syntax treetcheck.ml
- typecheckerprimops.ml
- implementation of ASL builtin types and operationsvalue.ml
- interpreter support codeeval.ml
- evaluator for ASL languageprelude.asl
- builtin types and functionsasli.ml
- interactive ASL tooltestlexer.ml
- test program that converts ASL code to list of tokensutils.ml
- utility codevisitor.ml
Platform specific instructions:
MacOS: brew install opam
Ubuntu: sudo apt-get install opam
Platform independent instructions:
opam install ocaml
opam install menhir
opam install ocamlfind
opam install ott
opam install linenoise
opam install pprint
opam install z3.4.7.1
opam install zarith
eval `opam config env`
You also need to execute this command
MacOS: export DYLD_LIBRARY_PATH=`opam config var z3:lib`
Linux: export LD_LIBRARY_PATH=`opam config var z3:lib`
To build the ASL lexer, the ASL interpreter and PDF files containing the ASL grammar, execute these commands.
make testlexer.native asli pdf doc
This displays a list of tokens in an ASL file including the indent and dedent tokens used to support indentation-based parsing.
$ ./testlexer.native prelude.asl
This reads ASL files specified on the command line and provides an interactive environment for executing ASL statements and expressions.
$ ./asli
_____ _ _ ___________________________________
/\ / ____|| | (_) ASL interpreter
/ \ | (___ | | _ Copyright Arm Limited (c) 2017-2019
/ /\ \ \___ \ | | | |
/ ____ \ ____) || |____ | | Version 0.0 alpha
/_/ \_\|_____/ |______||_| ___________________________________
Type :? for help
ASLi> 1+1
2
ASLi> ZeroExtend('11', 32)
'00000000000000000000000000000011'
ASLi> bits(32) x = ZeroExtend('11', 32);
ASLi> x
'00000000000000000000000000000011'
ASLi> :quit
Enjoy!