Project

General

Profile

NML Language Reference » History » Version 36

Andrei Tatarnikov, 02/14/2014 02:37 PM

1 21 Andrei Tatarnikov
h1. Sim-nML Language Reference
2
3
*UNDER CONSTRUCTION*
4 1 Alexander Kamkin
5 20 Andrei Tatarnikov
_~By Andrei Tatarnikov~_
6
7 1 Alexander Kamkin
This reference manual describes syntax and semantics of the Sim-nML language. It covers language facilities supported by MicroTESK and does not attempt to be complete. It may differ from documentation provided by other vendors as there are differences in language implementations.
8 22 Andrei Tatarnikov
9 27 Andrei Tatarnikov
{{toc}}
10 6 Andrei Tatarnikov
11 24 Andrei Tatarnikov
h2. Introduction
12 23 Andrei Tatarnikov
13
*_Sim-nML_* is an architecture description language (ADL) used in MicroTESK to describe the architecture of a microprocessor under verification. It is a flexible and easy-to-use language based on attribute grammar. Sim-nML was designed to provide a retargetable way to specify microprocessor architecture for various microprocessor-related software tools including instruction-set simulators, assemblers, disassemblers, compiler back-ends etc. It works at the instruction-set level concentrating on behavioral properties and hiding implementation details of the microprocessor. A Sim-nML specification represents a programmer''s model of the microprocessor that covers the following aspects:
14
15
* supported data types;
16
* registers and memory;
17
* addressing modes;
18
* syntax and semantics of instructions.
19
20
Sim-nML uses a hierarchical tree-like structure to describe an instruction set. Such a structure facilitates grouping related instructions and sharing their common parts. An instruction is described as a path in the tree from the root node to a leaf node. The set of all possible paths represents an instruction set. A node describes a primitive operation responsible for some task within an instruction. Nodes have attributes that can be shared with their parents. Actions performed by instructions are described as operations with registers and memory represented by bit vectors of arbitrary size.
21
22
A specification in Sim-nML starts with definitions of types and constants. For example, a type definition for a 32-bit word looks as follows:
23
24 35 Andrei Tatarnikov
<pre><code>let WORD_SIZE = 32
25 23 Andrei Tatarnikov
type word = card(WORD_SIZE)
26
</code></pre>
27
28 28 Andrei Tatarnikov
Type definitions and constants can be used to describe registers and memory. In addition to registers and memory, it is also possible to define temporary variables, internal abstractions provided by Sim-nML to store intermediate results of operations. They do not correspond to any data storage in real hardware and do not save their data across instruction calls. Also, there is often a need to specify some properties of the described model. For this purpose, special constants are used. For example, the code below defines general-purpose registers, memory and a temporary variable. Also, it includes a special constant to establish a correspondence between the general purpose register number 15 and the program counter (PC). Here is the code:
29 23 Andrei Tatarnikov
30 36 Andrei Tatarnikov
<pre><code>reg GPR[32, word]
31 23 Andrei Tatarnikov
mem M[2 ** 20, byte]
32
var carry[1, bit]
33
let PC = "GPR[15]"
34
</code></pre>
35
36 31 Andrei Tatarnikov
As stated above, an instruction set is described as a tree of primitive operations. There two kinds of primitives: _operations_ and _addressing modes_. Operations describe parts of instructions responsible for specific tasks and can be used as leaf and root nodes. Addressing modes are aimed to customize operations (for example, they encapsulate rules for accessing microprocessor resources). They can only be used as leaf nodes. For example, here are simplified examples of operation and addressing mode specifications:
37 29 Andrei Tatarnikov
38 32 Andrei Tatarnikov
<pre><code>
39 33 Andrei Tatarnikov
mode REG(i: nibble) = R[i]
40 32 Andrei Tatarnikov
syntax = format("R%d", i)
41 33 Andrei Tatarnikov
image  = format("01%4b", i)
42 34 Andrei Tatarnikov
<pre><code>
43
</code></pre>
44 32 Andrei Tatarnikov
op Add()
45
syntax = "add"
46 33 Andrei Tatarnikov
image  = "00"
47 32 Andrei Tatarnikov
action = { DEST = SRC1 + SRC2; }
48
</code></pre>
49
50 18 Andrei Tatarnikov
h2. Overview of Sim-nML