Top Up Prev Next Bottom Contents Index Search

12.3 An overview of stars in DE


The model of computation in the DE domain makes it amenable to high-level system modeling. For this reason, stars in the DE domain are often more complicated, and more specialized than those in the SDF domain. The stars that are distributed with the domain, therefore, should be viewed primarily as examples. They do not form a comprehensive set.

We have made every attempt to include in the distribution all of the reasonably generic stars that have been developed, plus a selection of the more esoteric ones (as examples). Keep in mind that the star libraries of the other domains are also available through the wormhole mechanism. Users that find themselves frequently needing stars from other domains may wish to build a library of single-star galaxies. Such galaxies can be used in any domain, regardless of the domain in which the single star resides. Ptolemy automatically implements this as a wormhole.

The top-level palette is shown in figure

12-4.
The following star is available in all the palettes:

BlackHole Discard all input particles.

12.3.1 Source stars

Strictly speaking, source stars are stars with no inputs. They generate signals, and may represent external inputs to the system, constant data, or synthesized stimuli. By convention, these stars are fired once at time zero automatically. During this and all subsequent firings, the star itself must determine when its next firing should occur. It schedules this next firing with a call to the method refireAtTime(time). The source palette is shown in figure 12-5.

Clock Generate events at regular intervals, starting at time zero.
Impulse Generate a single event at time zero.
Null Do nothing. This is useful for connecting to unused input ports.
Poisson Generate events according to a Poisson process. The first event is generated at time zero. The mean inter-arrival time and magnitude of the events are given as parameters.
PulseGen Generate events with specified values at specified moments. The events are specified in the value array, which consists of time-value pairs, given in the syntax of complex numbers.
TclScript (Two icons.) Invoke a Tcl script. The script is executed at the start of the simulation, from within the star's begin method. It may define a procedure to be executed each time the star fires, which can in turn produce output events. There is a chapter of the Programmer's Manual devoted to how to write these scripts.
TkButtons (Two icons.) Output the specified value when buttons are pushed. If the allow_simultaneous_events parameter is YES, the output events are produced only when the button labeled "PUSH TO PRODUCE EVENTS" is pushed. The time stamps of each output event is set to the current time of the scheduler when the button is pushed.
TkSlider Output a value determined by an interactive on-screen scale slider.
For convenience, some stars are included in the source palette that are not really source stars, in the above sense. They require an input event in order to produce an output. These are listed below. The value of the input event is ignored; it is only its time stamp that matters.

Const Produce an output event with a constant value (the default value is zero) when stimulated by an input event. The time stamp of the output is the same as that of the input.
Ramp Produce an output event with a monotonically increasing value when stimulated by an input event. The value of the output event starts at value and increases by step each time the star fires.
RanGen (Four icons.) Generate a sequence of random numbers. Upon receiving an input event, it generates a random number with uniform, exponential, or normal distribution, as determined by the distribution parameter. Depending on the distribution, other parameters specify either the mean and variance or the lower and upper extent of the range.
singen Generate a sample of a sine wave when triggered. This DE galaxy contains an SDF singen galaxy (i.e., a wormhole).
WaveForm Upon receiving an input event, output the next value specified by the array parameter value (default "1 -1"). This array can periodically repeat with any period, and you can halt a simulation when the end of the array is reached. The following table summarizes the capabilities:
haltAtEnd periodic period operation
NO YES 0 The period is the length of the array
NO YES N>0 The period is N
NO NO anything Output the array once, then zeros
YES anything anything Stop after outputting the array once

The first line of the table gives the default settings. The array may be read from a file by simply setting value to something of the form < filename.

12.3.2 Sink stars

The sink stars pointed to by the palette in figure
12-6 are those with no outputs. They display signals in various ways, or write them to files. Several of the stars in this palette are based on the pxgraph program. This program has many options, summarized in "pxgraph - The Plotting Program" on page 20-1. The differences between stars often amount to little more than the choice of default options. Some, however, preprocess the signal in useful ways before passing it to the pxgraph program. The first two icons actually correspond to only one star, with two different configurations. The first allows only one input signal, the second allows any number (notice the double arrow on the input port).

BarGraph (Two icons.) Generate a plot with the pxgraph program that uses a zero-order hold to interpolate between event values. Two points are plotted for each event, one when the event first occurs, and the second when the event is supplanted by a new event. A horizontal line then connects the two points. If draw_line_to_base is YES then a vertical line to the base of the bar graph is also drawn for each event occurrence.
Printer Print the value of each arriving event, together with its time of arrival. The fileName parameter specifies the file to be written; the special names <stdout> and <cout> (specifying the standard output stream), and <stderr> and <cerr> (specifying the standard error stream), are also supported.
Xhistogram Generate a histogram with the pxgraph program. The parameter binWidth determines the width of a bin in the histogram. The number of bins will depend on the range of values in the events that arrive. The time of arrival of events is ignored. This star is identical to the SDF star Xhistogram, but is used often enough in the DE domain that it is provided here for convenience.
XMgraph (Two icons.) Generate a plot with the pxgraph program with one point per event. Any number of event sequences can be plotted simultaneously, up to the limit determined by the XGraph class. By default, a straight line is drawn between each pair of events.
TclScript (Two icons.) Invoke a Tcl script. The script is executed at the start of the simulation, from within the star's begin method. It may define a procedure to be executed each time the star fires, which can in turn read input events. There is a chapter of the Programmer's Manual that explains how to write these scripts.
TkBarGraph (Two icons.) Take any number of inputs and dynamically display their values in bar-chart form.
TkMeter (Two icons.) Dynamically display the value of any number of input signals on a set of bar meters.
TkPlot (Two icons.) Plot Y input(s) vs. time with dynamic updating. Retracing is done to overlay successive time intervals, as in an oscilloscope. The style parameter determines which plotting style is used: dot causes individual points to be plotted, whereas connect causes connected lines to be plotted. The repeat_border_points parameter determines whether rightmost events are repeated on the left.
Drawing a box in the plot will reset the plot area to that outlined by the box. There are also buttons for zooming in and out, and for resizing the box to just fit the data in view.
TkShowEvents (Two icons.) Display input event values together with the time stamp at which they occur. The print method of the input particles is used to show the value, so any data type can be handled, although the space allocated on the screen may need to be adjusted.
TkShowValues (Two icons.) Display the values of the inputs in textual form. The print method of the input particles is used, so any data type can be handled, although the space allocated on the screen may need to be adjusted.
TkStripChart (Two icons.) Display events in time, recording the entire history. The supported styles are hold for zero-order hold, connect for connected dots, and dot for unconnected dots. An interactive help window describes other options for the plot.
TkText (Two icons.) Display the values of the inputs in a separate window, keeping a specified number of past values in view. The print method of the input particles is used, so any data type can be handled.
TkXYPlot (Two icons.) Plot Y input(s) vs. X input(s) with dynamic updating. Time stamps are ignored. If there is an event on only one of a matching pair of X and Y inputs, then the previously received value (or zero if none) is used for the other. The style parameter determines which plotting style is used: dot causes individual points to be plotted, whereas connect causes connected lines to be plotted.
Drawing a box in the plot will reset the plot area to that outlined by the box. There are also buttons for zooming in and out, and for resizing the box to just fit the data in view.
Beep Cause a beep on the terminal when fired.

12.3.3 Control stars

Control stars (figure
12-7) manipulate the flow of tokens. All of these stars are polymorphic; they operate on any data type. From left to right, top to bottom, they are:

Discard Discard input events that occur before the threshold time. Events after the threshold time are passed immediately to the output. This star is useful for removing transients and studying steady-state effects.
Fork (Five icons.) Replicate input events on the outputs with zero delay.
LossyInput Route inputs to the "sink" output with the probability lossProbability set by the user. All other inputs are sent immediately to the "save" output.
Merge (Four icons.) Merge input events, keeping temporal order. Simultaneous events are merged in the order of the port number on which they appear, with port #1 being processed first.
PassGate If the gate (bottom input) is open, then particles pass from "input" (left input) to "output." When the gate is closed, no outputs are produced. If input particles arrive while the gate is closed, the most recent one will be passed to "output" when the gate is reopened.
Router (Three icons.) Route an input event randomly to one of its outputs. The probability is equal for each output. The time delay is zero.
Sampler Sample the input at the times given by events on the "clock" input. The data value of the "clock" input is ignored. If no input is available at the time of sampling, the latest input is used. If there has been no input, then a "zero" particle is produced. The exact meaning of zero depends on the particle type.
LeakBucket Discard inputs that arrive too frequently. That is, any input event that would cause a queue of a given size followed by a server with a given service rate to overflow are discarded. Inputs that are not discarded are passed immediately to the output.
Case (Three icons.) Switch input events to one of N outputs, as determined by the last received control input. The value of the control input must be between 0 and N-1, inclusive, or an error is flagged.
EndCase (Three icons,) Select an input event from one of N inputs, as specified by the last received control input. The value of the control input must be between 0 and N-1 inclusive, or an error is flagged.

12.3.4 Conversion stars

The palette in figure
12-10 is intended to house a collection of stars for format conversions of various types. As of this writing, however, this collection is very limited. The first two stars in the conversion palette illustrate the consolidation of multiple data sample into single particles that can be transmitted as a unit. These stars use the class FloatVecData, which is simply a vector of floating-point numbers.

Packetize Convert a number of floating-point input samples into a packet of type FloatVecData. A packet is produced when either an input appears on the demand input or when maxLength data values have arrived. Note that a null packet is produced if a demand signal arrives and there is no data.
UnPacketize Convert a packet of type FloatVecData into a number of floating-point output samples. The "data" input feeds packets to the star. Whenever a packet arrives, the previous packet, if any, is discarded; any remaining contents are discarded. The "demand" input requests output data. If there is no data left in the current packet, the last output datum is repeated (zero is used if there has never been a packet). Otherwise the next data value from the current input packet is output.
MxtoImage Convert a Matrix to a GrayImage output. The double values of the FloatMatrix are converted to the integer values of the GrayImage representation.
ImageToMx Accept a black-and-white-image from an input image packet, and copy the individual pixels to a FloatMatrix. Note that even though the GrayImage input contains all integer values, we convert to a FloatMatrix to allow easier manipulation.

12.3.5 Queues, servers, and delays

The palette in figure
12-9 contains stars that model queues, servers, and time delays of various types. In the DE domain, the delay icon (the small green diamond at the upper left of the palette) does not represent a time delay. See "The DE target and its schedulers" on page 12-1.

Delay Send each input event to the output with its time stamp incremented by an amount given by the delay parameter.
VarDelay Delay the input by a variable amount. The delay parameter gives the initial delay, and the delay is changed using the "newDelay" input.
PSServer Emulate a deterministic, processor-sharing server. If input events arrive when it is not busy, it delays them by the nominal service time. If they arrive when it is busy, the server is shared. Hence prior arrivals that are still in service will be delayed by more than the nominal service time.
Server Emulate a server. If input events arrive when it is not busy, it delays them by the service time (a constant parameter). If they arrive when it is busy, it delays them the service time plus however long it takes to become free of previous tasks.
VarServer Emulate a server with a variable service time. If input events arrive when it is idle, they will be serviced immediately and will be delayed only by the service time. If input events arrive while another event is being serviced, they will be queued. When the server becomes free, it will service any events waiting in its queue.
FIFOQueue Implement a first-in first-out (FIFO) queue with finite or infinite length. Events on the "demand" input trigger a dequeue on the "outData" port if the queue is not empty. If the queue is empty, then a "demand" event enables the next future "inData" particle to pass immediately to "outData". The first particle to arrive at "inData" is always passed directly to the output, unless numDemandsPending is initialized to 0. If consolidateDemands is set to TRUE (the default), then numDemandsPending is not permitted to rise above one. The size of the queue is sent to the size output whenever an "inData" or "demand" event is processed. Input data that doesn't fit in the queue is sent to the "overflow" output.
FlushQueue Implement a FIFO queue that when full, discards all inputs until it empties completely.
PriorityQueue Emulate a priority queue. Inputs have priorities according to the number of the input, with "inData#1" having highest priority, "inData#2" being next, etc. When a "demand" is received, outputs are produced by selecting first based on priority, and then based on time of arrival, using a FIFO policy. A finite total capacity can be specified by setting the capacity parameter to a positive integer. When the capacity is reached, further inputs are sent to the "overflow" output, and not stored. The numDemandsPending and consolidateDemands parameters have the same meaning as in other queue stars. The size of the queue is sent to the "size" output whenever an "inData" or "demand" event is processed.
Stack Implement a stack with either finite or infinite length. Events on the "demand" input pop data from the stack to "outData" if the stack is not empty. If it is empty, then a "demand" event enables the next future "inData" particle to pass immediately to "outData." By default, numDemandsPending is initialized to 1, so the first particle to arrive at "inData" is passed directly to the output. If consolidateDemands is set to TRUE (the default), then numDemandsPending is not permitted to rise above one. The size of the stack is sent to the "size" output whenever an "inData" or "demand" event is processed. Input data that doesn't fit on the stack is sent to the "overflow" output.
The following star does not appear in the palette.

QueueBase Serve as the base class for FIFO and LIFO queues. This star is not intended to be used except to derive useful stars. All inputs are simply routed to the "overflow" output. None are stored.

12.3.6 Timing stars

The palette in figure
12-10 contains stars that are primarily concerned with either simulated or real time.

MeasureDelay Measure the time difference between the first arrival and the second arrival of an event with the same value. The second arrival and the time difference are each sent to outputs.
MeasureInterval The value of each output event is the simulated time since the last input event (or since zero, for the first input event). The time stamp of each output event is the time stamp of the input event that triggers it.
StopTimer Generate an output at the stopTime of the DEScheduler under which this block is running. This can be used to force actions at the end of a simulation. Within a wormhole, it can used to force actions at the end of each invocation of the wormhole. An input event is required to enable the star.
Timeout Detect time-out conditions and generate an alarm if too much time elapses before resetting or stopping the timer. Events arriving on the "Set" input reset and start the timer. Events arriving on the "Clear" input stop the timer. If no "Set" or "Clear" events arrive within timeout time units of the most recent "Set", then that "Set" event is sent out the "alarm" output.
TimeStamp The value of the output events is the time stamp of the input events. The time stamp of the output events is also the time stamp of the input events.
Synchronize Hold input events until the time elapsed on the system clock since the start of the simulation is greater than or equal to their time stamp. Then pass them to the output.
Timer Upon receiving a trigger input, output the elapsed real time in seconds, divided by timeScale, since the last reset input, or since the start of the simulation if no reset has been received. The time stamp of the output is the same as that of the trigger input. The time in seconds is related to the scheduler (simulated) time through the scaling factor timeScale.
The following star does not appear in the palette, because it is not intended to be used directly in Ptolemy applications.

TimeoutStar Serve as the base class for stars that check time-out conditions. The methods "set", "clear", and "expired" are provided for setting and testing the timer.

12.3.7 Logic stars

The logic palette in figure
12-10 is made up of only three stars, with the multiplicity of icons representing different configurations of these stars.

Test (Six icons) Compare two inputs. The test condition can be any of {EQ NE LT LE GT GE} or {== != < <= > >=}, resulting in equals, not equals, less-than, less-than or equals, etc.
If crossingsOnly is TRUE, then an output event is generated only when the value of the output changes. Hence the output events will always alternate between true and false.
Logic (Nineteen Icons) Apply a logical operation to any number of inputs. The inputs are integers interpreted as Booleans, where zero is a FALSE and nonzero is a TRUE. The logical operations supported are {NOT AND NAND OR NOR XOR XNOR}.
TestLevel Detect threshold crossings if the crossingsOnly parameter is TRUE. Otherwise, it simply compares the input against the "threshold."
If crossingsOnly is TRUE, then: (1) a TRUE is sent to "output" when the "input" particle exceeds or equals the "threshold" value, having been previously smaller; (2) a FALSE is sent when the "input" particle is smaller than "threshold" having been previously larger. Otherwise, no output is produced.
If crossingsOnly is FALSE, then a TRUE is sent to "output" whenever any "input" particle greater than or equal to "threshold" is received, and a FALSE is sent otherwise.
FlipFlop Stars Binary state is afforded in the DE logic palette with the inclusion of flip flop circuits. Three synchronous sequential circuit components, FlipFlopJK, FlipFlopT and FlipFlopD, serve as basic memory elements.

12.3.8 Networking stars

The palette shown in
figure
12-12 includes stars that have been designed to model communication networks. These are illustrative of a common use of the DE domain, for modeling packet-switched networks. However, many of the stars are specialized to a particular type of network design. Thus, they should be viewed as illustrative examples, rather than as a comprehensive library.

A NetworkCell class is used in many of these stars. It models packetized data that is transmitted through cell-relay networks. Each NetworkCell object can carry any user data of type Message. In addition to this user data, the NetworkCell contains a destination address and a priority. These are used by stars and galaxies to route the cell through the network. The definition of the NetworkCell class may be found in $PTOLEMY/src/domains/sdf/image/kernel, since it is used in the SDF and DE domains, and was developed primarily for modeling packet-switched video.

Cell creation and access

CellLoad Read in an Envelope, extract its Message, and output that Message in a NetworkCell. Append a destination and priority to the packet.
CellUnload Remove a Message from a NetworkCell.
ImageToCell Packetize an image. Each image is divided up into chunks no larger than CellSize. Each cell is delayed from its predecessor by TimePerCell. If a new input arrives while an older one is being processed, the new input is queued.
CellToImage Read NetworkCell packets containing image data and output whole images. The current image is sent to the output when the star reads image data with a higher frame id than the current image. For each frame, the fraction of input data that was lost is sent to the "lossPct" output.

Cell routing, control, and service

CellRoute Read NetworkCell packets from multiple input sources and route them to the appropriate output using a routing table that maps addresses into output ports.
PriorityCheck Read NetworkCell packets from multiple input sources. If the priority of an input NetworkCell is less than the most recent "priority" input, then the cell is sent to the "discard" output. Otherwise it is sent to the "output" port.
Switch4x4 Implement a four-input, four-output network switch that can process objects of type NetworkCell, or any type derived from NetworkCell. Each NetworkCell object contains a destination address. This galaxy uses the destination address as an index into its Routes array parameter to choose an output port over which the input object will leave. A prioritized queueing scheme is used.
VirtClock Read a NetworkCell. It identifies which virtual circuit number the cell belongs to and then computes the virtual time stamp for the cell by applying the virtual clock algorithm (see the source code in $PTOLEMY/src/domains/de/stars/DEVirtClock.pl). It then outputs all cells in order of increasing virtual time stamp.
Upon receiving a "demand" input, the cell with the smallest time stamp is output. An output packet is generated for every demand input unless all of the queues are empty. Demand inputs arriving when all queues are empty are ignored.
The number of stored cells is output after the receipt of each "input" or "demand."
When a cell arrives and the number of stored cells equals MaxSize then the cell with the biggest virtual time stamp is discarded. This cell may or may not be the new arrival. If MaxSize is zero or negative, then infinitely many cells can be stored.

Lost cell recovery

The stars in this subgroup implement a variety of mechanisms for replacing lost cells in a packet-switched network. They use a class called SeqATMCell that is designed to model packets in the proposed broadband integrated services digital network (BISDN). The class is derived from Message, but has added facilities for marking the packet with a sequence number, and setting and reading individual bits. The sequence number is used to determine when packets have been lost.

PCMVoiceRecover Input a stream of SeqATMCell objects. All the information bits in objects received with correct sequence numbers are sent to "output."
If a missing SeqATMCell object is detected, this star sends the most recent 8 * tempSize received bits to the "temp" output, and the most recent (8 * searchWindowSize + numInfoBits) received bits to the "window" output.
The bits output on the "window" and "temp" outputs can be used by the PatternMatch galaxy to implement lost-speech recovery.
SeqATMSub Read a sequence of SeqATMCells. It will check sequence numbers, and if a SeqATMCell is found missing, the information bits of the previously arrived SeqATMCell will be output in its place.
The information bits from each correctly received SeqATMCell are unloaded and sent to the output port.
SeqATMZero Read a sequence of SeqATMCell objects. For each object input correctly in sequence, headerLength bits are skipped over and the next numInfoBits bits in the cell are output.
If this star finds, by checking sequence numbers, that a SeqATMCell is missing, it will substitute numInfoBits 0-bits for the missing bits.

Wireless network simulation

Ether (Not shown in the palette.) This is the base class for transmitter and receiver stars that communicate over a shared medium. Each transmitter can communicate with any or all receivers that have the same value for the "medium" parameter. The communication is accomplished without graphical connections, and the communication topology can be continually changing. This base class implements the data structures that are shared between the transmitters and receivers.
EtherRec Receive floating-point particles transmitted to it by an EtherSend star. The particle is produced at the output after some duration of transmission specified at the transmitter.
EtherRecMes See the explanation for the EtherRec star.The only difference is that this stars forces the output to be a message.
EtherSend Transmit particles of any type to any or all receivers that have the same value for the medium parameter. The receiver address is given by the "address" input, and it must be an string. If the string begins with a dash "-", then it is interpreted as a broadcast request, and copies of the particle are sent to all receivers that use the same medium.
The transmitter "occupies" the medium for the specified duration. A collision occurs if the medium is occupied when a transmission is requested. In this case, the data to be transmitted is sent to the "collision" output.

12.3.9 Miscellaneous stars

These stars are shown in
figure
12-12.

Hardware modeling

Arbitrate Act as a non-preemptive arbitrator, granting requests for exclusive control. If simultaneous requests arrive, priority is given to port A. When control is released, any pending requests on the other port will be serviced. The "requestOut" and "grantIn" connections allow interconnection of multiple arbitration stars for more intricate control structures.
HandShake Cooperate with a possibly preemptive arbitrator through the "request" and "grant" controls. "Input" particles are passed to "output", and an "ackIn" particle must be received before the next "output" can be sent. This response is made available on "ackOut."
handShakeQ Handshake with queued input events.
TclScript Invoke a Tcl script. The script is executed at the start of the simulation, from within the star's begin method. It may define a procedure to be executed each time the star fires, which can in turn read input events and produce output events. There is a chapter of the Programmer's Manual devoted to how to write these scripts.

Statistics and monitoring

Statistics Calculate the average and variance of the input values that have arrived since the last reset. An output is generated when a "demand" input is received. When a "reset" input arrives, the calculations are restarted. When "demand" and "reset" particles arrive at the same time, an output is produced before the calculations are restarted.
UDCounter Implement an up/down counter. The processing order of the ports is: countUp -> countDown -> demand -> reset. Specifically, all simultaneous "countUp" inputs are processed. Then all simultaneous "countDown" inputs are processed. If there are multiple simultaneous "demand" inputs, all but the first are ignored. Only one output will be produced.

Signal processing

Filter Filter the input signal with a first-order, autoregressive (AR) impulse response. The data input is interpreted as weighted impulses (Dirac delta functions). An output is triggered by a clock input.

12.3.10 HOF Stars

For a discussion of the HOF stars, please see the "An overview of the HOF stars" on page 6-15.



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.