Index News Downloads Price list Forum Distributors Events Contacts


Description of the programlanguage HPL rev 2.0 03.05.2004


The HPL language (Hardware Programming Language) is developed
specially for description of the low level protocols of exchange
with various devices.

Let's consider implementation of the HPL language in the compiler of the
programmator "Orange".
The examples are designated in character (*), Changes - character '!'.

Character ';' is tag of the comment - the end of line since this character not

> Numbers. The numbers can be set in a binary, decimal and hexadecimal format:
(*) 1234 - decimal constant
(*) 010101B - binary
(*) 0x1234 or 01234H - hexadecimal.

> Address. The ADR key word contains current value of the address, on which the
reading/record is executed.

> Data. For data access in the buffer on a current address the DATA key word is
used. The data are availablis word by word
( 8 or 16 bits) or digit-by-digit.

> Registers. For execution of mathematical and logical operations, the
descriptions of constants and data storage can be used
16 registers R0... R9, RA... RF.
The registers R0... R9 universal, registers RA-RF of special assignment.
Through them are transferred parameters:
RB - size of the block of reading /record
RE - global opcode (1-READ, 2-VERIFY, 3-WRITE, 4-USER)
RF - total size of memory.
Other registers (RA, RC, RD) are reserved.

If the value transmitted by the special register is not used, it can be
used as universal inside sections.

The description of the protocol consists from several sections,
mandatory of them three are: initial, [READ] - reading of a word
and [WRITE] - record of a word.

Besides, in addition it is possible to use unessential of section:

[SETUP] - initial installation, is called unitary after hpl loading.
[INIT] - initialization, is called unitary before all operations.
[WRITEINIT] - initialization of record, is called once before the
beginning of record EEPROM.
[WRITEEND] - completion of record, is called once after record of all
words EEPROM.
[READBLOCK] - Reading of the block
[WRITEBLOCK] - Record of the block
[END] - completion of operation, is called once for any operation.

Can be if necessary described additional user's of section, which are
called unitary at a choice in the menu.
Their names also are written in brackets [].

! It is possible to use of local section (function). For the description of
functions before the name character '_' is added:

(*) [_START] ; the Functions should be described in the unit before their use.

The call of the function is carried out on the name:
(*) _START.

The transmission of parameters is possible with use of the registers.
It is authorized to use inside functions calls of other functions.
Use of recursive calls is not recommended.

Section of reading and the records are called at execution of
operations Read and Write for each word.

In read mode the order of call sections the following:

The order of call sections in a mode of record:
IF (Check of record)

The order of call for user's commands:

In initial section are described:

Entry and output signals for connection to EEPROM (pins):
(*) PINO=SCL ; 0 - Output, SCL - name of a signal, 0 - number of bit for
the driver
(*) PINI=SDA ; 1 - Input, SDA - name of a signal, 1 - number of bit
for the driver

The entry and output signals can have identical names. The names should
be not longer than eight characters. The names can not coincide with
reserved key words:

Character # before the name is tag of inversion of a signal:
(*) PINO=#DTA,0

Delay after each operation of installation (in microseconds):
(*) CDELAY=10
Allows to regulate speed of exchange. The real delays can
It turn out as far as more given.

Socket number for installation EEPROM (under the scheme Orange-1)
(*) SOCKET=1

If the SOCKET parameter is not indicated, it is considered equal 0.
It is possible to create new Socket, but that the conditional graphics
image of a chip was displayed in the Chip Info window, the table of
the outputs should be brought in to the driver.

Of the Declaration of the registers, availablis for review and editing
through the menu (Buffer - > Registers). The names of the registers should not
If the registers are used locally inside sections, to declare them it is not

(*) R0=Protect - where "Protect" - name of the register

After the name of the register through a comma the mode of imaging of value of
the register can be indicated: H - hex, D - Dec, B - Bin

(*) R1=CODE,H

All others of section have an identical format of record.
In one line some instructions can be described, among themselves they
are divided by commas.

The brief description of the instructions is given below:

Set pin by a constant, bit of data, address or register:
(*) SDA=1
(*) SDA=DATA[2]
(*) SCL=ADR[3]
(*) PIN=R2[3]

Check of a current state of bit (lines of input) or bit of the register
(*) DAT?1
(*) R2[4]? 0
or registers:
(*) R4?0x1234

If after operation of matching in brackets {} the block of the instructions is
described, it is executed at equality of bit (register) and constant, the
instruction following for brackets differently is executed.
If such block is not described, at an incongruity of checked up value the
execution of operation interrupts with the output of the message
"Error: Chip not respond!" And line number HPL of the file, on which
there was a stop.

(*) R2[4]?0 {P1=0},P2=1
If 4 bits of the register R2 is equal 0, the
instruction P1 = 0 is executed, and then P2 = 1,
if bit is equal 1 - that at once P2 = 1

If before compared number there is a character '!', the condition varies on
opposite. (the Block is executed at an incongruity of values).

(*) R2?!1234H {P1=0}
If R2 1234H is not equal, the instruction P1 = 0 is
executed, if R2 = 1234H, the following instruction is executed.

Installation of a constant. The values of constants should lay within the
limits of 0... 65535.
(*) CONST=159

Operation with the registers.
1) Operation of assignment (copying):
the register - register
(*) R2=R5
the register - data
(*) R2=DATA
(*) DATA=R3
the digit Capacity of data depending on a placed type of a
chip makes 8 or 16 bits.

2) Arithmetic and logical operations
( the constant or other register) can participate In operations:
installation "=" (*) R0=356H
addition "+" (*) R0=+123 ; R0=R0+123
subtraction "-" (*) R0=-R1 ; R0 = R0-R1
multiplying "*" (*) R0=*R1 ; R0 = R0*R1
division "/" (*) R0=/5 ; R0 = R0/5
remainder "% (*) R0=%10 ; R0=R0%10
circular shift "<<", ">>" (*) R0 = >> 1; shift R0 to the right on 1 bit Logical
And "&" (*) R0=&R2 ; R0 = R0 and R2
Or "|" (*) R0=|R2 ; R0 = R0 or R2
Xor "^" (*) R0=^R2 ; R0 = R0 xor R2

In operations of division and capture of the rest it is forbidden to use a
constant 0 or register containing 0!

3) Bit operations with the registers
(*) R0[R1]=1 - bit of the register R0, equal R1 to place(install) in 1

Cycles. The variable of cycles can be 3 sorts: the address, data of reading
/ record and constant. Besides the universal cycle, without the
instruction(indication) of a variable can be described, in this case access is
carried out through the counter (index) of a cycle I. Universal cycles can be
nested, in an internal cycle the counter of an internal cycle is directly
availablis only.
For universal cycles of boundary can be also given through the registers. For
compatibility with the future versions it is recommended to use only universal

The constant should be given prior to the beginning a cycle with the help of
the instruction CONST of Boundary of a cycle should lay in bounds:
0.. 32767 - for universal cycles
0.. 32767 - for cycles CONST
0.. 1023 - for cycles DATA
0.. 31 - for cycles ADR At execution of the code for universal cycles the
output(exit) of indexes for bounds of the real size DATA, ADR and CONST is not

The brackets "{", "}" limit an iteration body.

(*) LOOP=(15,0){DI=R0[I]...} the line of the output DI serially accepts
values bit 15.. 0 values of the register R0.

(*) LOOP=(7,0){DI=ADR [I]...}
(*) LOOP=ADR(7,0){DI=I...} - old variant the line of the output DI
serially accepts values bit 7.. 0 of current value of an address word.

(*) LOOP=(0,15){DATA[I]=DO..}
(*) LOOP=DATA(0,15){I=DO..} - old variant serial reading bit 0.. 15 words
of data from a line of input DO.

(*) R1=10H
LOOP=(5,0) {D=R1[I]...}
(*) CONST=10H
LOOP=CONST(5,0){D=I...} - old variant the line of the output D serially
accepts values bit 5.. 0 constants (10H)

(*) LOOP=(R1,R2){R3[I]=DATA[I]} Copying of bits from R1 up to R2 of an
address word in appropriate bits of the register R3

(*) LOOP=(0,7){P1=0,LOOP=(6,1){P1=0,P1=1}} Nested cycles.

Delay (in microseconds). The value of delay can be in bounds 1... 65.
(*) P=200

Output of the message. The output on the screen of the window with the
message, the string(line) should be made in quotes. Inside string(line) it is
possible to use standard modifiers similar used in the C language for printf
( the parameter l (long int)) is necessary For all numerical arguments.

X - Hexadecimal value u - decimal value

The compiler does not check correctness of transmitted arguments!

(*) PRINT=("Hello, World")
(*) PRINT=("Code = %04lX",R1) - Output of value of the register R1 in
hexadecimal sort - minimum of 4 digits.

Completion of current section: EXIT

More in detail to study constructions of the language it is possible an example
delivered in structure of the programmator of files *.hpl.