North- Holland Microprocessing and Microprogramming 22 (1988) 125-140
125
A Technique to Transform Programs into Circuits Jan
Kazimierczak
Institute of Engineering Cybernetics, Technical University of Wroclaw, Poland In this paper a technique to transform programs of the operating system nucleus into sequential circuits is introduced and a concept of a new solution of the os-nucleus is discussed. According to the presented concept the operating system nucleus should be realized as hardware, in the form of an automaton with internal and external parameters, that generates the operation code and addresses parts of the programs belonging to the os-nucleus. Note that in the current os-nucleus the same opcode appearing in different instructions is stored in a large number of memory locations. In the presented solution one opcode appearing in many instructions is represented by only one elementary memory element (e.g. by one flip-flop), included in the designed hardware. Similar reasoning concerns the addresses of operands. In this paper the synthesis of circuits of such a type of hardware is considered and also its result in the form of block diagram of this hardware is shown.
Keywords. Operating system, Computer hardware, Finite automaton, Software, Sequential circuits, Transformation of software into hardware.
I. Introduction
It is generally known that an operating system (os) of a computer consists of programs implemented in either software or firmware which make the hardware usable. On the other hand, we know that the current operating systems possess some disadvantages. These disadvantages, discussed below, may be removed by a partial transformation of software into hardware. The execution of such transformation is especially desirable for programs included in the operating system nucleus. The transformation of software into hardware may comprise all programs of the current os-nucleus or only its most significant components. This approach is conformable with future trends in the development of operating systems. These future trends include the migration of the operating systems functions from software to firmware or hardware [2]. For example, we can note
that the hardware costs of computer systems decrease every year. However, the cost of producing software increases every year. As a result, there is a growing payoff in the use of more hardware to automata functions previously performed by using software [9]. Some approach to the design of an osnucleus, of which all programs, or only part of them will be implemented in hardware, is introduced briefly below. The idea for a new design of the operating system nucleus, presented in this paper, arises from necessity of removal of a disadvantage of the current osnucleus organization. Namely, the present os-nucleas is a set of control programs, which are stored in the main memory. A single program of the ()s-nucleus is a sequence of instructions. Each instruction consists of two components: the operation code and the address of one or two operands. In a program there are many instructions with the same operation code. This means that the given operation code is stored in many locations of the main memory. Since the current os-nucleus consists of a number of control programs, the number of memory locations with the same operation code is very large. Similar considerations apply to the addresses of operands. The mentioned feature of the current os-nucleus we treat as a disadvantage. This disadvantage we want to remove in the presented design of the new type of os-nucleus. In our opinion, the os-nucteus will possess better advantage, if the same opcodes, and the same addresses of operands, are represented by only one elementary memory element, not by a great number of memory locations. Hence, according to the mentioned property of the present os-nucleus, designed hardware should represent each opcode by only one elementary memory element, i.e. by one flip-flop. The same reasoning refers to the addresses of operands. There['ore, the hardware representing a new type of the os-nucleus should include two sets of elementary memory elements, i.e. a set Y representing opcodes
126
J. Kazimierczak / Transforming Programs into Circuits
and a set 2 representing addresses of operands. On the sets Y and X, under influence of an external parametric signal p, which for example can represent an interrupt, a suitable program of the os-nucleus is created. According to this remark, such a type of the os-nucleus may be called a "self-organizing" osnucleus. The hardware to execute functions of the self-organizing os-nucleus can be realized in the form of a finite automaton < A > , further called the automaton with internal and external parameters [3]. Hence the above mentioned sets X and Y are treated as sets of memory elements of the automaton < A > . Each pair < y , x > of excited memory elements from sets Y and 2 uniquely determines the internal state of < A > and an instruction which is generated on the output of < A > . Hence, the automaton < A > has two outputs, on the first output operation codes are generated, while on the second output addresses of operands are generated. The synthesis of the automaton < A > may be explained in the following way. Namely, for simplicity, we assume that a current os-nucleus has only two programs written in an assembly language, denoted by o~i and '~i' Then, we assume that we want to replace the mentioned os-nucleus by the hardware which will be able to generate either instructions of ~ l or .~2- At the beginning each program is split into two parts, i.e. the operating part and the addressing part (Fig. 1). At first the operating part of the program s~i is considered. The operating part of the program .~i is expressed in the form of a graph G i whose vertices are labeled by opcodes and whose edges represent transitions between opcodes. The number of vertices of the graph Gi is equal to the number of instructions in the program ~i- There are many vertices with the same opcode. According to the presented concept, the graph Gi is collapsed to combine all vertices labeled by the same opc0de into one vertex representing an internal state of an automaton < A } > with internal parameter [3]. As a result of performing this operation the transition state diagram G} of the operating part of an automaton < A} > is obtained. The same procedure, as above, is performed on the operating part of the program ~'i, and as a result the transition state diagram G~ of an automaton < A ) > is obtained. Next the diagram G) is put on
A
'
×s
Fig. 1. Design philosophy and action of the self-organizing os-nucleus.
the diagram G} to obtain covering vertices labeled by the same opcodes. As a result of performing such covering, the state diagram of the operating part of the automaton < A > with internal and external parameters is obtained. In a similar way, the synthesis of the addressing part of the automaton < A > is performed. A design philosophy and an action of the self-organizing os-nucleus is illustrated in Fig. 1. In this figure the set Y represents the operating part of the automaton < A > , whereas the set X represents its addressing part. Moreover, in Fig. 1 the symbol Yr denotes the opcode, the symbol x,. denotes the address of an operand and the symbol p denotes the external parameter that assumes, in the considered example, either value Pi for creating the program ~ , or value pj for creating the program ,~j. The symbol z in Fig. 1 means that the operation indicated by the opcode of a running instruction is finished. There are several advantages in using the synthesized os-nucleus. The most natural advantage would be an increase of performance speed of the os-nucleus, because instructions of its programs are not fetched from memory to cpw but are generated by the automaton < A > . The second advantage is that part of the main memory is saved which so far was occupied by programs of the current osnucleus. The third advantage is that organization of
J. Kazimierczak / Transforming Programs into Circuits
the self-organizing os-nucleus seems more a mirror of the organization of memory in the human brain than organization of the current os-nucleus. For this reason the concept of the self-organizing osnucleus may be the germ to solve the problem of a machine intelligence by using hardware. The fourth advantage, as was already mentioned above, is a decrease of the cost of such computers that contain the os-nucleus made in the form of the presented hardware. A method of synthesis of the proposed hardware is described in following sections of this paper.
2. Transformation of a Program into the Hardware
Let us assume that we have a program .~i of the current o> nucleus which will be transformed into the hardware. We also assume that the program .~/: is written down in a symbolic assembly language. A schematic example is shown in Fig. 2, where c~= < y , . v > is a single computer instruction, y is an operation code, x is either an address of the operand on which the operation ), is performed or an address in the jump instruction. For simplicity, we assume that the program .~/i is applied in one-ad-
127
dress machine whose c e u contains only one accumulator. This means that every symbol _v/ in description of .e/i designates only an address of memory location. The program .~/i may be expressed in the form of a transition state diagram Gi of a finite automaton < A i > . The transition state diagram Gi of the automaton < A i > , further called the graph G~, is shown in Fir;. 3. The vertices of the graph G,, designated by symbols qr ~ Qi, represent internal states of the automaton < Ai>. With respect to program .c~/, (see Fig. 2), the given symbol qr denotes a place of the instruction in the program .eJ~. To the vertex qr the opcode )!: and the address .v~ of an operand or address of a jump in the program are assigned. -['he edges of the graph G, represent input signals of the automaton < A i > and are labeled by symbols zr ~: Z,. With respect to the program .c/, the symbol z,. :; Z, either means a sign of a result of performing the operation included in the given instruction or only means that the given operation is finished. The graph (~, can be split into two parts, i.e. into a graph Gi whose vertices q,. will be labeled by 3) ~: Y, H2×o,
93x~
C3
~z
0C9
~i ~4
x4 x4
~Z
X04
~13
~t
X4 x3
~3 ~4
XZ XI
~.~
X3
.gz
xo~
93
X4
93×z 9~x
I
x~
,
XZ X3
Xo~ x,I
Fig. 2. A schematic example of a program :1,.
Fig. 3. The graph G, of the program .~/:treated as the state diagram of an automaton < A, >
128
J. Kazimierczak / Transforming Programs into Circuits
and into a graph Hi whose vertices qr will be labeled by x, e Xi. These graphs represent the operating part and addressing part of the program ,~¢i, respectively. The graph Gi is shown in Fig. 4. According to the concept of the self-organizing os-nucleus, discussed in the first section, the graphs G i and Hi are collapsed in order to obtain covering vertices labeled by the same elements, i.e. by the same opcodes in Gi and by the same addresses in Hi. The result of this operation are graphs G} and H} that determine the behaviour of an a u t o m a t o n < A } > with internal parameter. This a u t o m a t o n made in the form a hardware is able to issue instructions of the program ~ i . The above mentioned operation, performed on the graphs Gi and Hi, is equivalent to transform the automaton < A~> with transition state diagram Gi, shown in Fig. 3, into the a u t o m a t o n < A ) > determined by the state diagrams G~ and H}. The operation of transforming the graphs Gi and Hi into the graphs G} and H}, respectively, is performed by using computer on an expression G,y which describes the graph Gi (see Fig. 3) and on a Table Ti,,, (qr~-,Yi,X,) including the assignments between vertices qr of Gi and the pairs Yi,x,.. The expression G + representing the graph Gi has the following form: G + = °(q ll(zlq22(zlq33(zzq44(zlq55(zlq66 ( 6((Zlq77(Zlq88(Zlq99(z2qlolO(zlqll I l(Zlq1212 ( 12(Zlq1313(Zlq1414(z2q1515(Zlq16)15,Z3qll)14) 13 •..) 1°,z3q l 3) 9) 8... )4, Z3q7)3)2)1)0. ( 1) We shall briefly explain the transformation of the graph Gi (see Fig. 3) into the symbolic expression Gi+. In the first step we write the open bracket 0( with index k=O, and after this bracket we write symbol ql of the first vertex of G i. In the second step we write the open bracket 1( with index k = 1, after it we write symbol zl of the edge that issues from the wertex ql standing before bracket l(. After symbol z~ we write symbol q2 of the vertex to which this edge leads. After five steps we obtain
G+ = O(qll(zlq22(zlq33(z2q4a(zlqs... Note that from the vertex q3 two edges z2 and z3 issue, at first the edge z2 is considered. Performing the same procedure further, we reach the last vertex q16 of the graph G~Gi
G/" . . . .
q1313(zlq1414(z2q15 ! 5(zlq16)ls...
Since from vertex q16 of G,Gi does not any edge issue, after symbol q16 in Gi+ we write close bracket )15 with index k = 15. In the next step we decrease by one the current value k = 15 of the index of brackets and we return to the vertex ql4 written in G + before the open bracket 14(. We check whether there is an edge z~ issuing from q14 that was not written down in G? yet. In our case such an edge exists, it is denoted by symbol z3 and leads to the vertex qtt- Hence, after close bracket )15 we write c o m m a and term z3q]l. Since all edges issuing from q14 were already considered, after the term z3qll a close bracket should be placed. On next items of G/+ we also write close brackets )13)12)1J)lo because from each vertex q~3,ql:,ql l,qlo only one edge z~ issues. We obtain ...Zlq16)15,Z3qll)14) 13) 12)11)10 .... The final steps of building the expression Gff are similar the above mentioned ones. The expression Gi+ and the Table Ti,o (q:--*yj, xs) constitute a basis to synthesis of the automaton < A ~ > with internal parameters. The synthesis of the a u t o m a t o n < A~> is divided into the synthesis of the operating part of < A~> and synthesis of the addressing part of < A ~ > . At first we shall consider the synthesis of the operating part of the automaton .