UVM binary code file format

Up: (dir)  

Top

A general format of instruction is:

<command code byte> <parameter bytes>

Next: , Up: Top  

1 Common elements of different commands


Next: , Up: Structures  

1.1 The cnt format

Natural numbers of any size are represented by cnt format.

Only coding of numbers < 0x8000 is implemented now.

If cnt < 0x80U then it is coded as a one byte (this number themself), but if it is not equal to 0x7f. If this number is 0 then it is coded as 7f.

The coding of 0x7f is not implemented now!

If 0x80 <= cnt < 0x8000 then it is coded as two bytes, the first - (the high byte of this number | 0x80), the second - (the low byte of this number).

Coding of numbers >= 0x8000 is not implemented by this coding mechanism.


Next: , Previous: , Up: Structures  

1.2 Selector coding

If the selector is AU selector and its number is less than 8 and module number is less then 16 then it is coded as follows:

[1|n|n|n|m|m|m|m]

where nnn is a selector number (1..7), mmmm - the module (1..15).

If nnn = 0 then the selector number follows in cnt format. If mmmm = 0 then the module code follows in cnt format. If both are 0 then the cnt for a module preceades the cnt for a number.

For selectors other than AU the format is:

[0|t|t|t|n|n|n|n]

where ttt is a selector type code (0..7) and nnnn is a selector number (1..15). If nnnn = 0 then a selector number follows in cnt format.

Selector types coding:


Next: , Previous: , Up: Structures  

1.3 Order coding

An order is represented as a sequence of fixed size words. This sequence is preceded by a size prefix:

[w|w|w|w|n|n|n|n]

where wwww - word size in bytes for one order element (1..15, 0 is reserverd for large words), mmmm - order depth (1..15, 0 is reserved for deeper orders).

All words are big-endian.

Example:

[0|0|1|0|0|0|1|1]  [[0 || 0]]  [[0 || 1]]  [[255 || 255]]

represents the order [0:1:65535].


Next: , Previous: , Up: Structures  

1.4 Cell reference coding

Each cell is represented as selector code and order (see above).

cell_ref ::= selector order

Next: , Previous: , Up: Structures  

1.5 Descriptor coding

NB: Any descriptor code always starts with a zero bit (7 bit in the any first byte of descriptor declaration).

descriptor ::= prim_type | structure | union | array | discriminated

prim_type is coded as follows:

[0|0|0|m|m|c|c|c]

where cccc codes a type:

and mm is an access mode

structure ::= STU_prefix {descriptor}(1,k)

STU_prefix:

[0|0|1|k|k|k|k|k]

kkkkk - is a number of elements, if = 0 then this number follows in cnt format.

union ::= UNI_prefix {descriptor}(1,k)
[0|1|0|k|k|k|k|k]

kkkkk - is a number of elements, if = 0 then this number follows in cnt format.

array ::= ARR_prefix descriptor
ARR_prefix ::= array_control_word cnt1 cnt2

array_control_word is coded as follows:

[0|1|1|x1|x2|y1|y2|0]

Previous: , Up: Structures  

1.6 Arbitrary strings coding

Now strings are used as parts of debug commands. ASCII string don’t contain zeros, so its coding is trivial:

string ::= cnt { string_character }

cnt is a length of string in cnt format (== 0 for an empty string). string_character is any non-zero byte.


Next: , Previous: , Up: Top  

2 Command codes


Next: , Up: Commands  

2.1 nop

[0|0|0|1|0|0|0|0]

Next: , Previous: , Up: Commands  

2.2 Enter block instruction

The block instruction consists of a number of selector groups. Each selector group is a set of selector declarations with optionally following map.

enter_block ::= {selector_group}
 selector_group ::= sel_group_prefix 
sel_decl { sel_decl } 
sel_group_postfix [map_decl] 
sel_decl ::= descriptor selector
map_decl ::= cnt { cell_ref cell_ref }

sel_group_prefix is coded as follows:

[1|1|1|0|1|0|0|t]

where t = 1 then a map declaration follows these selectors.

sel_group_postfix is coded as follows:

[1|1|1|0|0|0|0|0]

NB: sel_decl always starts with a zero bit (7 bit in the any first byte of descriptor declaration).

map_decl consists of cnt prefix which is the number of cell pairs.

map_decl ::= cnt { cell_ref cell_ref }

Next: , Previous: , Up: Commands  

2.3 mov

[0|0|1|1|0|0|0|0]  <cell_ref>  <cell_ref>

Next: , Previous: , Up: Commands  

2.4 act

[0|1|0|0|0|0|0|0]  <selector>

Next: , Previous: , Up: Commands  

2.5 if block

If block is coded as one or two parts. The second part is else part and is optional part.

If part:

[1|0|0|1|1|0|0|i] cell_ref

if i = 1 then it is inverse if (if not) condition.

Else part (optional):

[1|0|0|1|0|1|0|0]

End part (always):

[1|0|0|1|0|0|0|0]

Next: , Previous: , Up: Commands  

2.6 loop block

Each loop starts and ends with a special code.

The leading sequence:

[1|0|1|0|1|x|c|t] [cell_ref] [label_id]

if x = 1 then the loop is labeled and label_id is present (in the cnt format);

if c = 1 then there is a check of condition at the start (and cell_ref element is present);

if t = 1 then loop exits when the condition != 0.

The ending sequence:

[1|0|1|0|0|0|c|t] [cell_ref]

if c = 1 then there is a check of condition at the end (and cell_ref element is present);

if t = 1 then loop exits when the condition != 0.


Next: , Previous: , Up: Commands  

2.7 exit

[1|0|1|1|t|n|n|n] [label_id] cell_ref

where t = 1 - exit when the cell contains zero, otherwize when non zero; nnn - the label of the loop (when = 0 follows in the cnt format).


Next: , Previous: , Up: Commands  

2.8 call

[0|1|1|0|x|p|p|p]  [<proc_id>] [<selector>]

x = 1 - selector follows, ppp - proc_id, = 0 - follows in cnt format.


Previous: , Up: Commands  

2.9 debugging commands: print and printn

[1|1|0|0|0|0|s|ln] ( <string> | <cell_ref> )

where

ln == 0 - doesn’t feed line after printing; s == 1 - print a string (otherwise print a cell).


Previous: , Up: Top  

3 A list of command codes

This is a list of command codes (high 4 bits in the command byte).

0000 - reserver
0001 - nop
0010 - end of block
0011 - mov
0100 - act
0101 - not used
0110 - call
0111 - not used
1000 - not used
1001 - if block
1010 - loop block
1011 - exit
1100 - debugging instructions
1110 - the selector group