35 A MICROPROGRAM
GUYOT
A.,
MARTIN
E.N.S.I.M.A.G.
METACQMPILER
P.,
ME_RMET J.
- Grenoble
- FRANCE
ABSTRACT We shall call a microprogram metaco~iler a system of programs accepting two inputs : a description of an algorithm and a description of a machine on which this algorithm is to be micro-programmed. In our exe~ple, the machine is a CASSANDRE description of the ZOO01 and the algorithm is an Algol W description of multiplication. The first part of the system analyses the hardware in order to provide a functionnal ne~oork corresponding to the data path, the control hierarchy and a list of inco,~atibilities. The second part of the system uses this material to produce microprogram schemate. The third part of the system tries to find a time optimized microprogrcon by a careful allocation of resources. INTRODUCTION The microprogram metacompiler to be described takes as input a machine description at the logical level in a L I language and the algorithms to be con~oiled in a L 2 language. At present L I and L 2 are the same i.e. CASSANDRE. In a version being developped at the moment the algorithm will be described in reduced Algol W language. A d~scription of the CASSA~DRE language and system can be found in the IF1-P 71 procee-
ding~ Is[ The hardware co,~iler system will undertake 3 main tasks : I. Hardware analysis which extracts the necessary parameters. 2. A compiler-generator which takes into account these parameters. 3. An optimizer which tries to reduce execution time and memory size of the microprogran~nes. The flow chart of the software system associated with the metaco,~iler is presented below. The boxes in the diagram are represented as follows : I. rectangles - software modules. 2. circles - input or intermediary data files.
36
•
L2 " PROGRAM DESCRIPTION
MACHII.IE DESCRIPTION
CONTROL
HIERARCHY i-4
CONTROL ANALY S I S
GENERATOR INCOMPATIB!LITIES
IIi
~a
DATA PATH AHALYSIS
]
GENErAtOR
FUNCTIONAL
I I~
~F EICROP~OGXA~'~ I p,
NETWORK
S CHE~.IATA
TI~m OPTIMISER
I./
w
I
1 H
\
0
ASSEMBLER
- EXAMPLE OF A MACHINE Here can be found a block d i a g r a m and a CASSANDRE description of a small but rather comelicated machine : ZOO01. A simD]ified version of this example has already been described in the a b o v e - m e n t i o n n e d paper. This machine
contains
:
1. Functional Unit UAL w h i c h performs operations. 2.
16 ]ogical
Another functional U n i t DEC w h i c h may p e r f o r m on Buses E1 and E2 l o g i c a l shifts,
SEQUENCING
3. R e g i s t e r Unit R which may equally accept 16 bits or 4 datas o$ 4 bits (paralle1--serial transformer). The internal data path has a width of 4 bits ; 2 local memories LMEM of 16 words of 4 bits are connected to it. The e x t e r n a l d a t a p a t h has a width of 16 bits and contains a local memory SPES of 4 words o$ 16 bits whictl is also connected to the main memory and the perioherals of the machine.
37
SSPES
UNIT
ZOOOI
ST
~ONTROLE ..
CASSANDRE OESCRIPTION OF THE MACHINE This description is on~ o~ the inputs
F I L E~ OESC~|PT 'UYIrE'
¢~SSP3R
o~ the m~t~compiler.
~|
CAHBRIUGE
,'sJNITGK
SYSrER
LM~M(IZ.13,)IO:3I.I)IZI|:~I.IIGtSS.CO~IZ;GIO:3IrC{O:)It
TCCIL:+I}; 'HORLOC~' I ? , l J l 'SIgnAL' PE.CJ,CD,CS,SC.T:| e£X|E~N~' [04PTEJ~I*HQF~L~G~I~**..;~f|.~LI'HORLCGE'I~#4#;4p| COqOFEU~{~I.D,OE,~U.~.~OML~;Q*f~I;NLIIt~.D.CS;O|I 'Sl' SAOtZ °~L3RS t (II:U:=LIICU:.~IGII:J:=-tIGIIP~:=SS=~IG;SCI-|) IC3:= IIEO:=~IG)ICO:s-AIG)I C S:=SS.AIG.-SCI 'SI' A | G ' & L 3 ~ $ t I ' S i s CJC~O ' ~ L Q R $ ' ITCCIL):=TC)ITCC(ZI:=rC)) 'S[~3N' { '$Ie CU£~) '&LOR$ s ITECI~|:=T~)ITCCI~|:=TC))| "UNIT~' C~MPTE)R[H,~(O:3)oPE.CU,C0tR~Z:QI):3).TC|I *REClSI~E' CT{I:~|; 'SIGNAL* q~llO:3),HOZIO:~|l IHORLOG6O H= ]:-CT:~Ot:~*~III(CT.MOZ*CT.~31÷HOI.t~02)IOi 'SI' C U ~ O 'ALOHS s IV32:=OO)I:TC:,I.CT} (N3Z:=LILL;I~:=I.(°~[||; ICT(sP)ICT<=CrtlN32iMOLI}ICr,=o000|; 'U~ITE' ~LII*AIO:3I,DIO:3),:S;O(0:3]|| 'REGISI~E' MIi:6,O:ISI; 'HURLQGE' I ; '$1' CS 'ALOES* N I . $ I A D ~ I ~ = O | O:-qlt$( A)); *U~IT~' U A L I f | , I Z , O P | I O : 3 1 , ) P 2 I O : 3 ) , : 3 M I O : 3 I t S E T . RAZ;SIO:31~SREPT.$Z); ' R E ~ I S T ~ E ' REPT,LIO:3I: '$1G~&L' ~S7(O:~J,~SSIO:3I,R~IIO:4I.RS2():4),RS3|O:4}.~S4IO:)I.EI(Ot ~1 . ~ Z l O : 3) .E 3( O: 3 | , E ~ ( O: 3 ) , C ~ R $ 5 1 0 : 3 I~RS6( O : ) | ; o HORL OC~ ' I1~ I Z ; E2:=iOPI~-~PZItRSTII=~II E3:-(OPI#U~2I~R$3(I:~); R$I;=~$~£R~PT:RS~:=~SS~I;RS):=~S6CO;RS7:=RSS£REP[|
R$5:=t31L|I3%I3PI.~PZI~O£O) L.R$7~OC-OP2.RS?|; RS4:='DI|IIO~IPPI.gPZI+)~OPL.~SI+O~D'2.R$|); R~:=eOI]~I3~I~PI.'3P2)~OGOJI.R~Z÷O~-gP~'oR$2}I ~$~;=eDII|(O2iUPI.~JPZI~)~OPL.~S)~O~GP2.RS3|; <1|> L<: 'S]' S:3q ' A L 3 R S ' (E[IIEEIIE~}IE41{-3~I.O~Z)[OP~If[1Pt:~PZIIOP[e~e2)|-(OP~÷OP2))
(-|OP1=OP2I}I-f~2]iOOOO|I~Pt.O~ZIiOP|o-~PZJlOP]); ~E)i< = 'Sl' {RS;(O|I(0)I[);
-/~EO~(3:IIE~tlCSE~
°ALORSt
~REPI:*REPf;~Z:=/~LIS~=LI 'UNIT~' O~:G(O~III:~},COt{t:?I;SG||:~I)| ~$IG~AL' ~PIJ:6I,C{0:3;; ~EXr~RNE' V A L ~ 2 1 E ; 4 1 ; V AL N~I C O l : : I ; O P : = O P l ¢ 3 0 0 I ' P ~ O ~ ' 1=3 ' A ' 3 tSI'
CIIJ
'~LDR5"
$G:=)P(|;3~I||
' U ~ I TE' O E C O i O ) 2 1 1 : 4 I , C 0 2 ( I : 2 I ; S ~ ( I : ~ I I : '$I' $CUZ ' A L O E S ' ( S D : = 3 P ~ ( l = k ) I ISO: =~%3P2( 1 : 3 1 1 1 S D : , ) O £ ~ P 2 ( I : ~ )
) ( SO:-O00COPZ{ | 1 1 ;
38
lUCITE*
OECII3, CnECiCOMOECILISI,)=IIL:4J~O~2iI:~I.SAIIL:2}eSAZlli~|!
S3(i:~),SD(l:~)ll . tRFGIST~EI Al[:2); ,SIGNAL t C O t ( L : 2 I , C O 2 ( I s 2 ) ! IHPRLOGE ! 13= eEXTERNEI O E : G I ~ , 2 / 4 ) I O [ C D I 6 e Z i ~ ) ! O~CGiOPI,:OIISGII UE=OIOPZ.=02;SOI/ <13> 'SI' COMOEC ' ¢ L O ~ S ' IA(-S&I/ I ' $ i i $&2 ' a L O R S ' IA(=3)I(A(=O[IIA('tO|IA('I|)) IACsOO)IA(= O[|lA(etO)[ PA$OFCAL: ;01:=03:C32:s00: OECALG i tSl' CUEC ' ALO~.SI ~ O | : = A '$1NON¢ l'Sli ~ i 'ALOES' (CO2:=C31(COZ:=IIICC)Z:-t3I(COZ==Ot)I= OECALO : e l 1 ° COEC IkL~R$1 E O Z : ' & ISiHONI i'Sl* SA *AL3~S i ICOI:.OOII:OI:.IL)I:Oi:=i3IICOi:=Oltll 'J~|tEi C)4PTI~,PIO:I),PEi;J,C3i~AZ$~IO:IIeTC)I 'kFRISTIE' 13OIliZII iSIG,IILI lll(3:ll,tO2lOilll IHORLOGI~.i HI I$ll C U ~ O i4L3RSe
iM~Z:=OIITC:=Io&OOi l~32:=LllrC:=/.-IOO) l ~O[:=ID [tI[~)~.~)~*~UU.~Oi~q3I.NOZI[O;QI-AOO; I&OOE=PIIAOO(=AO3i(~OZe~OiIIIAO0:=OOII IJqlTf'
O~ffl&OOll:2i,CRil:2|iOlO:ll;CAOIi:]llOOLOlii~JlCR3ll/lJe C~III/iIIi iSIGNALI CIIiI:4)I IEXI[IN~I Vac~Zl2;lll 'Sl' -C~ltl.C~(i| ' A L 3 R S ' CRI/=9OLQ| ISl' C~II).CR(2) I A L I ~ $ i CR~:'DOLQi ;13:='Si' C~II).-CI(2I 'ALOIS' 1ill ISIllONI 'Sl' S&C~ ' ~ L 3 ~ S I |IIC%OI31:=ilICA~III:IlCi)lZ):lill
'U~ETE I
CR| l
I(i~,IJ,~OOli:2),~,C~II:ZI,{EO:4Ii:3),EADOIiI2I,SII:;),SSPESIii
'SIGNAL'
T:#.ICIi~IOiII.)3LOILi;I,T:3,T:IiCAOIIi3I,CR3IIi41i:RZII:tI!
llZIJ:I,3:3I,IIIIO:i,Oi3IiIUIIiLSIiICS; IHO~LOG~ m 1 3 , 1 2 ; 'EXIEKN~' CU4PTIi43RLOlEilZt,lII2iIiCOM~IEURIiHORLO(EI,6illill)i OE;0312.2,2ll,lll,4ll iSli C~CR3 'ALOR5" IkRII,OI::SI(RII,IJ:=SIIIIIiZI:=IIIttliII/=SIIIIliOI:=SIP~SIIi&i) IIRII,IIi:$SpESIbi01IIItI.~I:=SS~E$IiiIIIIIIRIi31/:SSPESIIIiIbIII llLi=IIII,01~I+/IiII~RI~I,ZI0~RZII311 ISll O]t+ IAL}IS I ISRI:=RIZI,31IISRZi=RIZI,IIIISRli=RRII,/IIISRIi=IRZ(,3))I TCC:=:4OI31.r:~c~DIzI.r:~CJql3i. TCSCRC£MIZI.fCS; C3~P/II]IEA33iCA3(IliCI) I211~A~I3)IRAZIiIICl; OECqOIIOO,CI.3IC~,~CL~,CR3.~IIll
C~ P I E J R I I I I I Z , R l t I , O i , : 1 2 I i I ~ C R I ( I ) , T C i . R C O M I I i e T C 2 . R C ~ q { ZJ,P~OM(3I;~2il31, IClli CO~PIETRI21II~.RILI,III;RZIZI*CR3IIh/CI~RCOMILIITCI.RIGN I2),~COP(3iiR~2I,II,TCZI; £~PT~JR|3I(IZ.R~II,Zit~R213I~CR3i3iiTC4.R~OHIIIirC~,RCOq I21,I:OMI31itlZI,2I,TE$1; C31PI~BRI4III~,RtII,3I,:RIIIltCRIIIIiRCGMIJI,R:ONIZIIRCOl 13)IltZi,3iiI:~J; T~:-I~I.TCZ.[C).ICII IUllif~ Z00OIIH,I,IIZ,ETII:ISIICqlI:IIICECHII:31,SIII:I611I '$1~L' IEll/8l,~LIl:41.~2ll:~),$llil),101ll:4ltOlll:41,~Olll:llIOl II:;I,$=|(I:IbI,$t2(Ii41,]RIIIiII,3~211:II,CONSII:41,CCMtAROE(I:I511 i]I,10Oli:II.C3RIZI!:2II::II:II,COWfIIIil]I,IIIE$(I:I6II IHIILOG~ i Hill ilMPULSION' llllZ, Itl tEl/fINal V~L131IlSI, LM~MIIH01LIJG~iiIHOtL)~[lill~ItiIItlIIil =Otll}L~liH~/L}l~'~'H~lLO;fllitOlLOGEi1411OilO14}l]llll JlLliHOlLO~fl.14~lL]$~i/t, ll4111411Jl Of~l'H3ttOGf',,l,4, ioZ,4iil4h SP~$Ii~3~LOGEi.iHORL3~I,161[S,4iiili6}! 41'H~IL3GE'.*,31LO3E'.2..~i3.~.I*I61I6.4.41l tOILOGEI i HIIXL3~E'.'H3~LO~t:'I34LOGEii'HORLOGEiliHOKLOGEill 4ici]llllalS~;EllliVat~t|Zll410&Cl2;); 4OlL3G~IHIIilItlI, ilII '$I' V~L~31llllll IAL)lll IEI:~$e2IIEI:=31IIEI:=]ZIIfI:=A~IIIEIi=StIIIEL:'OIII£Ii'OIIIEIi'AO21I 'St' V4L131211ll) 'AL3KS' llll ' C;(l) '4LOR$' ~ Z : = ; O ~ $ 1 I ~ 2 : = S I 2 i I E 2 / = U I ) I E Z : ¢ C 2 1 lill I (~(I) I&L~RSi ~2:=COl$ll~Z/=$1ZllE2:=O2)lE2;~il|
IIII.13. AO3.~O~A~OEIIII.~I.~MIAN~IeiI3I.CGNSZ.SISSPfSISRI.SRIiTESTIOiII)I S):Sll~.I3.Ef.S~Ie:3~$.~HIII,CS~,CCIZI;SSPE$)I I~.CII3. CDEC.:O"~aN)EI::bI~CO~41ND~III:I5I,EllEZiSRJII3:I4IiSIOIIi~P/li U~LIII.|~.~P|.IJPZ.:J&LiC31~AI)EI&I,Cq"~A~OEIIII$iTflTI4II/E$||5|I; LI{~IIJII3.12.$.~OIf.-&IG. SS.;0,w~IOEIIIIIAb21C2.TIIS:81ll C)tT~0. EIH.II.I3,$.TfSIIUigli,ICO~TtII:43]IC~II:3iiCECHIi:t)I; CI:=0PIIIII:TIICIP:,CONPRI]JI $f:=C01T~II~);~OlI:-CO~lllIIiIIII I)3:-C)IIRIII:I5):;EL==CG'IIRIIb:I#II C315~:=~ltllS:[@);Cq'i%:=C~fllZl=llll C~£C==:~trt124i;CO:=Co~IRILS:Zb)I
TESIIb:9):;IE||:~)+[E(5:8);$T:.5$PE$1
39 i
II - CONTROL HIERARCHY In the Qraph theory a hierarchy is an oriented graph containing no circuit (cycle). In a microprogrammed conlouter the control unit is composed of 3 sections : I. The Control Memory. 2. An Automaton which assumes a sequencing of one mlcro-lnstruction and another. 3. The set of Logical circuits which decode the output control memory. This final sectlon-is a hierarchy. The aim of the control analysis module is to extract from the general description of the machine the entire control hierarchy. The treatment of the work is fairly complicated because the language used for description allows a total mingling of control signals and all other kinds of signals. Let a I ... a n be the wires at the output of the control memory. The result of the control analysis is a list of statements in the form o~
:
if f(a I ... an ) then where f is a boolean polynom (of micro-actlon register loading).
Definition of Incompatlbilities Consequently each mlcro-actlon is associated with a boolean polynom. Therefore 2 microactions will be incompatible if their associated polynoms are orthogonal. Micro-instruction is only composed of compatible micro-actions.
III - DATA PATH ANALYSIS Symmetrically with the control analysis, this module from the description all the components of the data path and their inter-connections. After this stage a fairly complicated network has been obtained because it has been transferred directly from the machine. This is simplified into three series : 1. Firstly the elimination of redundant elements and the replacement of the network which represents a memory cell by a single node.
2. Nodes or "gates" appear (symbol ~,). These are the logical gates of 2 inputs i.e. one data input and one control input. These are the only points of contact (i.e. synapses) between the control part and the data path. 3. This series divides longitudinally thee combinatory circuits of the machine ( s y m b o l S ) which transform the multiple boolean functo~onns into a set of simple boolean functiuns - with a single
output C ~ ? . After this sequence of simplification a canonic network of the following type is obtained:
40
PATEPN:=I FOR J:=O UNTIL 3 DO BEGIN IF ~ TESTZE~O(ANDGATE[A(I), PATERN)) THEN IF TESTZERO[J) THEN BEGIN L:=I ; FOR K:=O UNTIL 7 DO BEGIN P[L):=ADD4{P(L),X(K), REP) ; REP:=CARRY4(P(L),X(K), REP) L:=ADO4(L,O,1) j END P[L):=ADD4[P(L),O,REP) ; END ELSE BEGIN L:=I FOP K:=O UNTIL 7 DO BEGIN P(L):=ACC4(P(L), SHIFTLEFT[X(K),J),C) ; REP:=ORGATE(REP,CARRY 4(P(L),SHIFTLEFT(X(K), J),O) L:=AOD4[L,O,1) ; P[L):=ADD4[P[L),SHIFTRIGHT[X[K),J),REP) ; REP:=CARRY4{P(L),SHIF~ RIGHT(X[K),J),REP) ; END ; END ; PATERN:=SHIFTLEFT[PATERN,1) J END ;
There is a bfjection between such a network and a context-free grammar. (Per. : J. MERME~ E t u d e m O t h o d o l o g i q u e de l a c o n c e p t i o n a s s i s t @ e par ordinateur des s y s t ~ m e s l o g i q u e s : CASSANDRE). In particular this network gives the width of the data path, the list of all the existing operations and o f t h e d i s t i n c t memory c e l i a ,
IV - EXAMPLE OF A L G O R I T H M Multiplication o~ two words of 16 bits. The a l g o r i t h m is given to the compiler by Badda schematics.
x15 . . . . . . . .
xo
a15 . . . . . . . .
ao
x15a15 x15alx14a I Sum : P31 -
"'"
....
Xoa o
.... Xoa 1
P16
P
15 ''" P1
P
o
The m a c r o - g e n e r a t o r p o s s e s s e s t h e l i s t of the existing o p e r a t i o n s and t h e w i d t h o f t h e d a t a p a t h . I t a l s o o o s s e s s e s a c e r t a i n number o f rules dealing with substitution, d e c o m p o s i t i o n and the composition of operators. F o r e x a m p l e t h e add i t i o n o f 32 b i t s i s t r a n s l a t e d into 8 groups of 4 bits with carry propagation : the shift is divided i n t o s h i f t s of 4 positions and e v e n t u a l l y one s h i f t o~ 1, 2 o r 3 p o s i t i o n s . END ;
The e x a m p l e d e s c r i b e d i n A l g o l W on t h e c u r r ~ m F r oage i s t h e i n t e r m e d i a t e f o r m between the "macro-generator" and t h e " g e n e r a t o r o£ m i c r o program schemata".
END.
V - OESCRIPTION OF A MICROPROGRAM S C H E M A BEGIN COMMENT SOME OF THE OPERATIONS P E R F O R M E D BY THE MACHINE ; INTEGER PRODEOURE AOO4[INTEGER A , B , R ) ; (A+B+R) REM 16 ; INTEGER PROCEDURE C A R R Y 4 I I N T E G E R A,B,R) ; (A+B+R) DIV 16 ; INTEGER PROCEOUPE S H I F T L E F T ( I N T E G E R A,I) ; ( A ~ x ~ I ) REM 16 ; INTEGER PROCEDURE S H I F T R I G H T ( I N T E G E R A,I) ; A DIV ( 2 x ~ ( 4 - I ) ) ; INTEGER PROCEDURE ANDGATE(INTEGER A,B) ; NUMBER[RITSTRING(A) AND BITSTRING(B)) j INTEGER PROCEOURE ORGATE(INTEGER A,B) NUMBER(BITSTRING[A) OR BITSTRING(B)) • LOGICAL PROCEDURE T E S T Z E R O ( I N T E G E R A) ; A:O ; INTEGER PROCEDURE P L A C E ( I N T E G E R A) ; ENTPAR(LOG(A)/LOG(2))+I ;
Network GB(P), Dominance
[cf (I), [15))
One calls the sequence of a program P a list of instructions, o£ w h i c h the first is an entry-point, the last a branch and which contains n e i t h e r branch nor e n t r y - p o i n t apart from these two instructions. Let Go(P) be the network of w h i c h the nodes are the sequence of P and the connections of the links [by branches) between the sequences. A sequence S 2 is predominated by a set E 1 oE sequences if every path leading to S 2 passes by a least one of the sequences of E I and if this property is no longer valid when a sequence of E I is suppressed. - Using Go[P)
as a starting point we are trying to
obtain another network GB[P'), representing a proCOMMENT ALGORITHM OF THE MULTIPLICATION
INTEGER ARRAY A , X [ O : : 7 ) z INTEGER ARRAY P ( 0 : : 1 5 ) ; INTEGER PATERN,REP INTEGER I , J , K , L ; REP:=O ; FOR 1:=0 UNTIL 7 DO BEGIN
gram P' s e m a n t i c a l l y equlvalent to P, but whose associated m i c r o p r o g r a m will be more efficient. The relation O allows the set of programs semantically equivalent of interest t o u s , t o be d e f i n e d . -
Dependance R e l a t l o n
D (cf
(13))
L e t 11 and 12 be t h e two P i n s t r u c t i o n s
:
41
11012
if
a.
An instruction I which belongs to a sequance S of P may be moved into the sequences which dominate or are dominated by S, taking into account the instructions linked to I by O.
11 is realized be~ore 12
b.
the result of ! 2 appears in 11 or 12 using the result of 1 I.
The relation D applied within a sequence is a relation 0£ partial order ; thus every sequence o~ GB[P) may be described by the hierarchy associa-
- Using GB[P} as a starting ooint, the networks
GB[P'), GB[P''),
... associated with the proRrams
ted with n, whose nodes a r e the 0 instructions for the optimiser to choose one of the networks GqCP). GB[P'}..,
P'. P''... semantically equivalent to m. can be formed :
I IT
i=-o 7
~inter:=patern and a(i)
--LOOP2
k:=O
m:=i
nbshi£t:=patern
J£1ag1:=inter=D~// £1ag"
Lhen g "
,....
T~ST~2 [#{ag2i--p~ter~,--o'O001' i i
£ £1ag2 then goto M-JLT2] MU-~--:~p (m): =ADD (p (m), x (k), car)
/i£ MULTIB
ear: = CARRY (p~m), x (k) ,car)
flag3 then goto M U L I
P(m) :=#.DD(p[m), o,O000', ear) I
I
@arc NEXT2
I
ptm):=ADD(p(~),z,b'O'
car.'-~
or C A R R Y ( p (m) , z ,o '0, )
m : = m + 1 ~ D ( x ( k ) , 4 - n b s h i £ t ) ~(m):=ADD(p(m), , ~ r )
c&r:mOARRY(p(m),z,car) 9~:=k
[
~ -.,
~.
_
...
i_~}l__a_g6then go o LOOPI
g o to
~ooP2
~&k+l =b,lO000'
42
In our example the instruction m:=i may be plaqed either in - MULTI and MULT2 - TEST~2 - LOOP2 LOOP~ and NEXT2 -
NEXTI, INIT and NEXT2.
VI - OPTIMIZER The problem is to transform the elementary instructions o~ the schema o~ the micropro~ram which manipulates the variables into transfers between elements of memorisation, 14e are thus confronted by a problem o~ allocation o~ computer resources. These resources are of 3 types : ~unctional operators, elements o~ memorisation end busses. The time o~ execution o£ the mieropro~ram is taken as criteria o~ allocation. Obviously the resources must be mana~ed using to maximum the parallelism o~ the computer. Choice o~ a network GB(P) The choice o~ one the networks, semantically equivalent to P is made by taking into account the probabilities o~ the oasse~e in the different hierarchies belon~in~ to GB, and to the context ; thus the instruction m:=i ~s placed in TEST12 because it is the node which is passed the least o~ten in LOOP2 ; the optimizer takes into account the context while reducin~ to the maximum the distances between instructions usin~ the same variables.
The arrangement oF 'Patern', 'i' and 'x' in LMEM2 depends on the order in which the instructions menlpulatin~ these variables are executed and on the operations realizable on the address re~Ister A02 o~ LMEM2 ; thus, as the over~low o~ AD2 can be tested, 'x' is placed in the second part oT LMEM2. As 'Patern' is used in NEXT2, thus after MULT~ and MULT2 [eontainin~ the instructions ~hich manipulates 'x') it is placed in LMEM2(O) and 'i' is placed in LMEM2(1), - since A02 may be incremented by I.
-
Manipulation o~ the vector 'a' : In LOOP1, the operations on a(i) are made by re~erence to R. R contains only 4 elements o~ 'a'.
Consequently, the loop LOOP1 havinK been passed 8 times, is replaced by 2 loops : in one o~ these, passed 4 times, operations are carried out on a(i) ; in the other, which includes the ~irst, the 4 elements ~ollowing 'a' are loaded into R. Micropro~ram obtained after the optimization In this mlcropro~ram the actions are separated by the symbol (;). Each ~roup o~ actions is realised by one micro-instruction ~ the actions symbolized by (") are realised automatically ; the others ere described in ~ields o~ micro-instructio~ The symbol (&) represents the adress o~ a variable. ~L~JP
AC the end oF Z~IT , t h e r e ts: /J)1(0:3)=O001;/~x~(o~ 1)=O0;4~O(0:3)=O000:LP:EHl(O:15).OOCO ~YJ~H2(O:7)=0C00;L/T£~(8:~]~X;SPES(O:I]=a;R{O:3)=~(O 3};2J~?T.0;
TSar12
EI~J~a~e~ L H E I ~ 2 ; £ 2 ~ - - - - 0 0 0 1 ; ~ E 1 ~.ND E2;~NDZq~FI~2S~OGO0;
Elementary instructions a. ~n order to realize an elementary instruction one must choose the gunctional operator, the oath by which the ooerands are led to the thresholds og the operator, the place or places into which the operands and results egret the operation are set. These choices ere made while notin~ the parallelism og the computer, the context in which the instruction is situated.
JI<~-~LHCP~.;$4---E1;J~I~.$;
tza~
(Z)NDI$ t h e n gOtO HULT2; I~LT1
~Zag$ AD2~UL~ t h e n ~OtO K[Tr.~T1;
b. Consecutive instructions in the micropro~ram schema may sometimes be realized in the same micro-instruction ; thus the hierarchy corresponding to MULTI has 4 levels. It is however microprogrammed by 2 micro-instructions. Allocation oF the resources In the network describinK the computer a memory is represented by a node ; in our e x a m p l ~ the strategy adopted by the optimizer is to place the variables 'P' (result), 'a' [multiplier) and 'x' (multiplicand) in different nodes at a distance o~ 1 to UAL ; thus the variables 'P' and 'x' are placed respectively in LMEMI and LMEM2 ;
~lqP(m) L 1 ~ 1 ; £ 2 ( x(k~ " ~ K 2 ; ( S , R Z P T J ~ ( m ) ' c a r £1+£2+23~I';
IOtO NI~X"F2;
ItULT2
BI<-~-SHL(,bF~2J;E2q~m~ L~H1;S<----E1.E2;bHEHI~ D(mj $; ]P.£I~~ - 2EP'~, " OR IEFT;ADI~-~-ADI+I; 11~ p(R) LF~H1;E2,p~..~IC0(LHEF.2);(S..-ClC;pF,~:P(m).CL~ 1~1÷]52+2ElV~| ZI~'H'~.p(m) S;J+J)2c-~AD2÷I;"~2~ULL.'- £1a~" A~2d00OO';
izag4
~Lt AD:~NhULL then qoto ~Jb¢2; IfCX~2
I;llPa'~ern LI'4~H'~:1~2 +'Pater~ L-qEH2;$4-"--EI÷E2;L:'~:K2('Patez'rt S ;
:L~ $NNULL t h e n GOtO LOOP2;
P and SPES a r e a l l o c a t e d at the variable 'e' b e c a u s e R may n o t c o n t a l n t h e w h o l e o { ' a ' . As t h e n o d e s LMEM1, LMEM2, R and SPES e r e u s e d , 'Patern' and ' i ' a r e t o be p l a c e d i n t h e n o d e s which are incompletely gilled. O n l y SPES and LMEM2 are usable ; the variables 'Petern' and ' i ' are s t o r e d i n LMEM2 as i t i s a t d i s t a n c e 1 g r o m UAL.
JUX)~ a ~ i )
J~r~÷l ;J~2 L~-~AD24"1;'AOOHblULL ."el&~'7 &..Do,room;
11 ~:~--/Jt£PI2; z2 p
i $ ; AJD2~k Pat e+~n 0001 ; S ¢---E1+E2 ; LKEV~~-" JLD2--1;
oo~Dz~ ,"z ~,~ ,6 sloooo; tlag7 J~ A/X)h'NUr.,I. t h e n g o t o ~,OOpt ; tlag6 R ( 0 : 3 ) ~ (7:1~) SPE${1);lt CO;¢DZ2 then goto LOOPll I~LT~ND
reCUr;
43 Comparison of the mioropro~ram and a mlcropro~ram obtained without the worry of allocations of variables A trivial allocation could be made in conservinK all the variables in the main memory M. In order to realise the operation the operand will be led into LM£MI(O) and L~M2[OJ.
The result will be placed in M ~ the transfers bet ween M and UAL will be made by SPES and P(O). The adverage number of cycles executed will have been about 8000. The average number of cycles executed by the optimized micropro£ram is 590. The galn is 80no thus ~ = 13 which shows the advantaKe of such a treatment.
REFERENCES (I) (2) (3) (4) (5) (6)
(7) (8)
F.E.ALL~N,= "progr%m optimization" ,Annual review in Automatic Programruing; Vol 5 I~.Y.Pergam.on, 1969, pp 239-307 F.ANCEAU,"compilation de microprogramme", S~minaire de logique E.N.S.I.M.A.G. , mars 1969 G.BOGO,A.GUYOT,A.LUX,J.MERMET,C.PAYAN,"CASSANDRE and the computer aided logical system design", IFIF 71, ppiO56-1065 G.BLAIN,NGUYE~ XUAN HONG,M.PERRONE,G.RUGGIN,',g~n6ration automatique de microprogrammes optimis~s", R.A.I.R.O. sept. 1972 B-3 pp 61-90 G.BOULAYE,J.MERMET ads. "International Advanced Summer Institute on Microprogramming", 1972 P.CHATELA!N,A.GU-YOT,A.HANOZAKOWSKI,K.de POLIGNAC, "application du langage CASSANDRE ~ la microprogrammation" raport £inal de contrat D.R.M.E. n ° 69.34.707.00.480.75.O1 W.N.E.DAY, "compiler assignement o£ data items to registers" I.B.M. syst. j. n°4, 1970, pp 281-317 V.M.GLUSHKOV, "automata theory and microprogram trans£ormation,, Cybernetics, 1965, vol.1, pp I-9
A.GUYOT,P.SIARTIN,J.MERMET, "@tude d,un m@tacomDilateur de sequences de commandes., journ6_es AFCET TRIA , octobre 1973 (10) J.HEBENSTREIT, "gene'rateur de microprogrammes" th@se de Docteur-@sSciences Math@matiques, Universit@ de Paris, mai 1969 (11) S.S.HUSSON, "microprogramming: principles and practice", Prentice-H--~]l Engle~ood Cli£?s, N.Y. 1970 (12) A.KEITH T ! R R ~ , "a st'._~y 05 the application o£ compiler tech;~iqu,~c to the generation o~ micro-code", workshop on microprograru~i[~, Grenoble, Juin 1972 (13) R.L.KLEIR, C.V.RAIhiMOU~THY, "optimization strategies £or micropr~g:":~ " IEEE transactions on computers, vol. C-20 n°9, juillet 1971 pp78~;-7 ''~" (9)
(14) (15) (16)
(17)
J.KUNTZ~hNN, "th~orie des r~seaux", DunodF~Paris 1972 E.S.LOWRY,C.W.MEDDOCK, "object code optimization", comm. ass. comput. mach. Voi.12, janvier 1969, pp 281-317 J.MERMET, "~tude m~thodologique de !a conception asslst@e par ordinateur des syst@mes logiques: CASSANDRE" th~se de Docteur-@s-sciences Math@matiques, Universit@ de GRENOBLE, avril 1~72 M.V.WILKES~ "the best way to design an automatic calculating machine" report o9 Manchester University computer inaugural com£erence, 1951