Noith-HoLland Microprocessingand Microprograrnnling 12 (1983) 245--248
245
Concurrent Pascal as a Simulation Language Carlos Fern&ndez, J.A. Martfnez Centro de Investigaci6n y Estudios C. 7".N.E., Madrid, Spain
C o n c u r r e n t P a s c a l a p p e a r s as a p r o g r a m m i n g l a n g u a g e d i r e c t e d to i m p l e m e n t o p e r a t i n g s s y s t e m s . C o n c u r r e n t P a s c a l is p r e s e n t e d in this p a p e r as a s y s t e m simul a t i o n l a n g u a g e . The end o b j e c t i v e is the d e f i n i t i o n of a set of v a r i a b l e types w h i c h a l l o w s for the c o n s t r u c t i o n of a h i e r a r c h y c a l s t r u c t u r e w h i c h s h o u l d be able to c h a r a c t e r i z e s y s t e m s . N e w types of d e f i n i t i o n s w i l l a l l o w for the b u i l d i n g of a l i b r a r y of type c o m p o n e n t s . In o r d e r to c a r r y out a s i m u l a t i o n the s y s t e m m u s t be b l o c k - s t r u c t u r e d . E a c h b l o c k w i l l be b u i l t in a t o p d o w n d e v e l o p m e n t . We s h a l l limit o u r s e l v e s to p r ~ sent discret system simulations.
I.- I N T R O D U C T I O N T h e s y s t e m s i m u l a t i o n by a c o m p u t e r is a p o w e r f u l t o o l that a l l o w s for p r e d i c t i n g s y s t e m p e r f o r m a n c e . Concurrent P a s c a l is v e r y in o r d e r to i m p l e m e n t s y s t e m s si mulation p r o g r a m s . In this p a p e r we s h o w the C o n c u r r e n t P a s c a l as a s i m u l a t i o n l a n g u a g e for d i s c r e t s y s t e m s . T h e se p r o g r a m s h a v e an e s s e n t i a l feature; the are i m p l e m e n t i n g n e w c o m p l e x c o m p o nents. A hierarchycal structure allows f o r i ~ p l e m e n t i n g new c o m p l e x c o m p o n e n t s w h i c h can be a g r e g a t e d as macrocomponents. useful
2.- G E N E R A L
STRUCTURE
SIMULATIONS 2.1.
FOR DISCRET
SYSTEMS
-
PROGRAMS
DESCRIPTION
OF B A S I C C O M P O N E N T S
Any d i s c r e t s y s t e m can be implemented from a structure inclu ding four t y p e s of b l o c k s : - The u n i t
delay
- The m u l t i p l i e r - The a d d e r - The
link
Monitors
T h e s e type c o m p o n e n t s of C o n c u r r e n t P a s c a l .
are
T w o m o n i t o r s h a v e to be d e f i n e d , one as a s i g n a l g e n e r a t o r a n d the o t h e r as a d i s p l a y for the o u t p u t signal. T h e r e is a s i n g l e p r o c e s s "Time". It w i l l a c c e s to m o n i t o r s by c o m i n g t h r o u g h access p o i n t s c a l l e d "tic and tac". T H E LINK: It has two ent r y p o i n t s w h i c h are "read" (to a c q u i r e the p r e s e n t v a l u e of an i n t e r n a l v a r i a b l e ) and "write" (to u p d a t e its value). T H E U N I T DELAY: It has a c c e s s to two links (input and o u t p u t ) . T w o e n t r y p o i n t s for "ti me": tic (to read the input and t o store it in an i n t e r n a l v a r i a ble '"~I") and tac (to carry the c a l u e of "VI" to "72"). THE M U L T I P L I E R : It has a c c e s s to two links (input and o u t p u t ) . It has two e n t r y points for "time": tic (to read the inp u t and to m u l t i p l y it by a coefi cient) and tac (to carry the res u l t to the o u t p u t link).
246
C. Fernandez, J.A. Mart;nez / Concurrent Pascal as a Simulation Language
THE ADDER: It has two links as inputs and one as output. It has two entry points: tic (to add the inputs) and tac (to put the result in the output). THE SIGNAL GENERATOR: It has an entry point "tic -tac" wich generates every sample, and it has a link as an output. THE DISPLAY: It has access to an input link and, it has one en try point "tic-tac" which presents the value on a peripheral. TIME: This is the only process in the sytem, it performs the followings operations: tic-tac
to the generator
tic to internal
system com
ponents
tac to internal
system com
performs the filter's multiplier elements, RETI and RET2 p e r f o r m s the delays, I and 2 performs the adder elements. The blocks El to E6 p e r form the link beetween the other blocks. The figure 2 shows also the generator and the display as input and output elements of a filter. The only process in the p r o g r a m is "the Time"; this process will handle the system elements. The schedule is provided from the filter equation. Once the values X(n), X(n-1), X(n-2) are in the internal variable of the link elements El, E2 a n d E3, the sequence pattern for the TIME PROCESS is as follows:
ponents
tic-tac
2.2.
DESCRIPTION
A.-
" T i c " to the multipliers al to a3; the p r o g r a m performs the f o l l o w i n g operations al.X(n), a2.X(n-1), a3.X(n-2). Although these values are not in the link elements E4 to E6.
B.-
"Tac" to multipliers al, a2, a3; transfers the results above to the suitable link elements E4, E5, E6.
C.-
"Tic" to the adder I; performs the addition a1.X(n) a2.X(n-1). That partial addition will be available in E7 to the adder 2, when the "Time" performs a tac over the adder I.
to the display.
OF PROGRAM
STRUCTURE
AS an example, we show the p r o g r a m structure that will simulate a digital filter. The filter dia g r a m appears in the figure I whic~ shows the typical structure of a t r a n s v e r s a l filter. The basic cells of a discret system: the delay, the m u l t i p l i e r and the adder, are presented here.
x(.)
D.- "Tac" 'f
03
2
-
FIGURE
YIn)
1
In Figure 2 the system diagram, for p r o g r a n ~ i n g in Concurrent Pascal is shown. Which has been imp l e m e n t e d the from basic units discribed above. The blocks a I to a 3 -
over the adder
~ I.
E.- "Tic" over the adder
~ 2.
F.- "Tac"
~ 2.
G.-
over the adder
"tic-tac"
over the display.
At end of this sequence the disp l a y has the value b(n) in the link E8. H.- The process "Time" must do "tic" over the delays RETI and RET2, then it must "tac" over thim.
247
C. Fernandez, J.A. Mart[nez / Concurrent Pascal as a Simulation Language
I.- "Tic-tac"
The next operation consists r e p e a t i n g the cycle.
over the generator.
in -
FE.E.,oo.] RET
I
1
I
RET
2
I
E3
F
[ FIGURE
The system advantage comes from the p o s s i b i l i t y to decla re easily the internal blocks as a new macrocomponent. This new ma c r o c o m p o n e n t will has only two en try points "tic a n d tac". It needs two link elements also; one as input and the other as output. T h e figure 3 shows the n e w macrocomponent, We can implem e n t the above mentioned component as a monitor. W e call this monitor "Internal time". The internal time p e r f o r m s the internal operations above that were p e r f o r m e d by the p r o c e s s "time". The new process -
2
"Time" does not p e r f o r m t~ese in ternal ~perations. It does "tic and tac" over the "Internal T i me", the generator and the display. We feel this job philosophy shows, a higther degree of reliability when system simulations are p e r f o r m e d structurely. It allows the building of a component library with predefined types.
248
C. Fernandez, J.A. Mart[nez / Concurrent Pascalas a Simulation Language
JGENERADORJ
"~"1
I
RET 2
E:1
E
'T u
i-,-
~
\f/
%
J
f
Fq
E T I C - TAC
FIGURE
3
R E F E R E N C E S
I.- B r i n c h Hansen, P., "Structured Multiprogramming", CACM Vol. 15 No. 7, J u l y 1.972. 3.- B r i n h Hansen, P., "The Programming Language Concurrent Pascal", IEEE Transactions on Software Engineering, June 1.975.
4.- Brinch Hansen, P., "The Architecture of Concurrent Programs", Prentice Hall, New Jersey, 1.977. 5.- Alan V. O p p e n h e i m and R o n a l d W. Schafer, "Digital Signal Processing", Prentice Hall, New Jersey, 1.975.