\documentstyle[zed,11pt,a4wide]{article} \newcommand{\within}{\mathrel{\rm within}} \newcommand{\precedes}{\mathrel{\rm precedes}} \newcommand{\ordered}{\mathord{\rm ordered}} \newcommand{\memfree}{\mathord{\rm memfree}} \newcommand{\bitor}{\mathop{\rm bitor}} \def \iseq {\mathop{\rm iseq}} % copied from fuzz.sty \def\aside#1{\noindent {\it[#1]}\par} \def\EG{EuroGam} \def\signed#1#2{{\unskip\nobreak\hfil\penalty50 \hskip2em\hbox{}\nobreak\hfil#1\quad#2 \parfillskip=0pt \finalhyphendemerits=0 \par}} % TeXBook, p106 \title{Eurogam Spectrum Servers\\Online Histogrammer} \author{David Brightly} \date{Edition 0.9\\December 1990} \begin{document} \begin{titlepage} % a front or cover page for EG docs suitable for inclusion inside % a titlepage environment in a LaTeX document % for use with Plain TeX uncomment the \nopagenumbers and the \eject \hoffset=.5in \hsize=5.25in \vsize=10.25in %---gives left and right margins of 1.5in on A4 paper \font\small=cmssbx10 scaled \magstep2 \font\medium=cmssbx10 scaled \magstep3 \font\large=cmssbx10 scaled \magstep4 %\nopagenumbers \hrule height 0pt \parindent=0pt %\parskip=0pt \hskip 3.9in \large EDOC060\par \vskip .5in \large EUROGAM PROJECT\par \vskip 1.5in \hrule height 2pt \vskip 20pt \large NSF DATA ACQUISITION SYSTEM\par \vskip .5in \baselineskip 25pt Eurogam Spectrum Servers:\\ Online Histogrammer\par \vskip 20pt \hrule height 2pt \vskip 1in \medium Edition 0.9\par \vskip 5pt December 1990\par \vfill \medium NSF Software Systems Group\par \vskip 5pt UK Science and Engineering Research Council\par \vskip 5pt Daresbury Laboratory\par \vskip .5in %\eject \end{titlepage} \maketitle \noindent [As usual this document is not yet complete but is published in its present form for comments. More work needs to be done in defining functions for returning some form of compressed histogram data and for obtaining cuts and slices from histograms of dimension $>1$. XDR bindings for all the procedures also need to be worked out. Author's remarks and asides are in square brackets. \signed{D.B.}{Monday 10 December 1990]} \section{Introduction} This document is in two parts: the first part specifies the properties of spectra in general and defines generic operations on them; the second part describes the \EG\ online histogrammer hardware and shows how the operations defined in the first part can be mapped onto it. Further documents in this series will describe similar specialisations for online sorter spectra and saved disc spectra. \section{Generic spectra} \subsection{Shapes, tuples, and domains} This section will describe the foundations which we will need to talk about histograms and spectra. \begin{zed} SHAPE == \seq_1 (\num \cross \num) \\ TUPLE == \seq_1 \num \\ DOMAIN == \power TUPLE \end{zed} Histograms are essentially arrays of a certain {\sl shape\/}. For example, a simple one dimensional histogram might have a shape given by $\langle (0,1024) \rangle$. This means it starts with channel $0$ and has $1024$ channels. A two dimensional histogram with 64 channels in the first dimension and 4096 in the second could have the shape $\langle (1,64),(0,4096) \rangle$. In this example the channels in the first dimension are numbered $1$ to $64$. A {\sl tuple\/} is a sequence of numbers labelling a channel in a histogram. The tuple $\langle 23 \rangle$ labels channel 23 of our first histogram and the tuple $\langle 44, 2753 \rangle$ labels a channel in our two dimensional example. A {\sl domain\/} is just a set of tuples. We will use domains to talk about subsets of all the channels in a histogram. Both tuples and shapes have a {\sl dimension\/} defined in the obvious way: \begin{axdef} dimension : TUPLE \fun \nat_1 \\ shapedimension : SHAPE \fun \nat_1 \where \forall t:TUPLE @ dimension (t) = \# t \\ \forall s:SHAPE @ shapedimension (s) = \# s \end{axdef} We can count the total number of channels in a histogram of a certain shape. Our first example has $1024$ channels and the second has $64*4096$ channels: \begin{axdef} size : SHAPE \fun \num \where \forall a,b : \num; s: SHAPE @ \\ \t1 size~\langle (a,b) \rangle = b \land \\ \t1 size (s) = size (\langle head~s \rangle) * size (tail~s) \end{axdef}% %%inrel \precedes When reading or writing counts in channels we need to present them in some fixed order. In this ordering, the rightmost channel coordinate varies fastest, so we have $\langle 100\rangle \precedes \langle 200 \rangle$ and $\langle 23, 3192 \rangle \precedes \langle 44 , 1024 \rangle$. \begin{axdef} \_ \precedes \_ : TUPLE \rel TUPLE \where \forall a,b:\num; x,y:TUPLE | \#x = \#y @ \\ \t1 (\langle a \rangle \precedes \langle b \rangle \iff a < b) \land \\ \t1 (x \precedes y \iff (head~x < head~y \lor (head~x = head~y \land tail~x \precedes tail~y))) \end{axdef} %%prerel \ordered We can say whether a given sequence of tuples is ordered or not: \begin{axdef} \ordered \_ : \power (\seq TUPLE) \where \forall s: \seq TUPLE @ \\ \t1 \ordered~s \iff (\forall i,j:\dom s @ (i < j) \iff s~i \precedes s~j) \end{axdef} and given a set of tuples we can order them: \begin{axdef} order : DOMAIN \fun \seq TUPLE \where \forall d:DOMAIN; s: \seq TUPLE @ \\ \t1 s = order (d) \iff \ran s = d \land \ordered~s \end{axdef} %%inrel \within We can also say whether a given tuple lies within a given shape. For example, we have $\langle 11, 999 \rangle \within \langle (1,64), (0,4096) \rangle$ but not $\langle 2048\rangle \within \langle (0,1024) \rangle$. \begin{axdef} \_ \within \_ : TUPLE \rel SHAPE \where \forall x,a,b:\num; t:TUPLE; s:SHAPE @ \\ \t1 (\langle x\rangle \within \langle(a,b)\rangle \iff 0 \leq x-a membase(h)+c\] and that, \[\forall h @ \exists m @ membase (h) \mod 2^m = 0 \land 2^m > c.\] These conditions are readily met by demanding that all histograms have power of two size and be aligned on their size and that $RMrange$ also be a power of two with $RMbase \mod RMrange = 0$. \begin{axdef} validranges : \power \nat \where validranges = \{1024,2048,4096,8192\} \\ RMbase \mod RMrange = 0 \end{axdef} \aside{Finally, note that $d=c$ and $c \within h.shape$ implies $d \within h.shape$ also. If the data presented to the histogrammer does not meet this condition, e.g., through some external hardware or programming fault, then spurious counts may appear in some spectra. It may be worthwhile widening the histogrammer's lookup table with per-tag mask fields to prevent this} The next schema describes how the histogrammer system starts---basically nothing is known and all tags are disabled, but overall operation of the card is enabled. This avoids the need for explicit ``halt'' and ``go'' operations on the histogrammer hardware. It is not essential to zero the real memory at this point, though clearly some sort of memory self-test is desirable. \begin{schema}{InitHistogrammer} Histogrammer \where state = enabled \\ \forall t:TAG @ tagstate ~t = disabled \\ membase = \empty \\ memrange = \empty \\ baseaddress = RMbase \\ store = \empty \end{schema} In the foregoing we have tried to keep separate operations on abstract histograms from hardware descriptions. We now have to say how a histogram gets associated with a particular tag. First we reserve space for a histogram in the memory and then we {\sl map\/} a certain tag onto that histogram. \begin{schema}{MapTag} \Delta HistogrammerCard \\ \Xi HistogramMemory \\ h? : Histogram \\ t? : TAG \where state = disabled = state' \\ tagstate~t? = disabled \\ tagstate' = tagstate \oplus \{ t? \mapsto enabled \} \\ tagbase' = tagbase \oplus \{ t? \mapsto membase~h? \div 1024 \} \\ baseaddress' = baseaddress \end{schema} When we no longer require a histogram we must unmap the associated tag (if any) before we can free the memory belonging to the histogram. \begin{schema}{UnMapTag} \Delta HistogrammerCard \\ \Xi HistogramMemory \\ t? : TAG \where state = disabled = state' \\ tagstate~t? = enabled \\ tagstate' = tagstate \oplus \{ t? \mapsto disabled \} \\ tagbase' = \{t?\} \ndres tagbase \\ baseaddress' = baseaddress \end{schema} Both these operations require that the histogrammer hardware be in the disabled state, so let us give ourselves operations for enabling and disabling the histogrammer card. \begin{schema}{Go} \Delta HistogrammerCard \\ \Xi HistogramMemory \where state = enabled \end{schema} \begin{schema}{Stop} \Delta HistogrammerCard \\ \Xi HistogramMemory \where state' = disabled \end{schema} We can now promote these operations to the spectrum level: \begin{zed} StopMapTagGo \defs Stop \semi MapTag \semi Go \\ StopUnMapTagGo \defs Stop \semi UnMapTag \semi Go \end{zed} \begin{schema}{AssociateTag} AccessSpectrum \\ StopMapTagGo \\ i? : \nat \where h?=s.arrays~i? \end{schema} \begin{schema}{DissociateTag} AccessSpectrum \\ StopUnMapTagGo \\ i? : \nat \\ h : Histogram \where h = s.arrays~i? \\ t? = (\mu t:TAG | tagbase~t * 1024 = membase~h) \end{schema} We can now completely define the operations of creating a new histogrammer spectrum and of deleting one: \begin{schema}{CreateHistogrammerSpectrum} \Delta Histogrammer \\ \Xi HistogrammerCard \\ CreateSpectrum \\ m,r : \num \where shapedimension~spectrum.sshape = 1 \land first (head~spectrum.sshape) = 0 \\ r = size~s? \land r \in validranges \\ m \mod r = 0 \\ \memfree (m,r) \also membase' = membase \oplus \{ h \mapsto m \} \\ memrange' = memrange \oplus \{ h \mapsto r \} \end{schema} \begin{schema}{DeleteHistogrammerSpectrum} \Delta Histogrammer \\ t? : TAG \\ DeleteSpectrum \\ h : Histogram \where h = (store~name?).arrays~1 \\ (\exists t?:TAG | tagbase~t? * 1024 = membase~h @ StopUnMapTagGo) \lor \\ (\lnot (\exists t?:TAG | tagbase~t? * 1024 = membase~h @ \Xi HistogrammerCard))\\ membase' = \{ h \} \ndres membase \\ memrange = \{ h \} \ndres memrange \end{schema} \subsection{Error conditions} \begin{syntax} REPORT & ::= & ok \\ & | & domain\_outside\_spectrum \\ & | & invalid\_calibration\_number \\ & | & invalid\_annotation\_number \\ & | & invalid\_histogram\_number \\ & | & counts\_dont\_fill\_shape \\ & | & spectrum\_not\_known \\ & | & spectrum\_already\_exists \\ & | & shape\_unsuitable\_for\_histogrammer \\ & | & insufficient\_histogramming\_memory \\ & | & tag\_already\_being\_histogrammed \\ & | & histogram\_not\_associated\_with\_tag \end{syntax} \begin{schema}{Ok} r! : REPORT \where r! = ok \end{schema} \begin{schema}{BadShape} r! : REPORT \\ s?:SHAPE \\ h: Histogram \where \lnot rectdomain~s? \subseteq rectdomain~h.shape \\ r! = domain\_outside\_spectrum \end{schema} \begin{schema}{BadCalibration} r! : REPORT \\ s: Spectrum \\ i?: \nat \where \lnot i? \in 1 \upto shapedimension~s.sshape \\ r! = invalid\_calibration\_number \end{schema} \begin{schema}{BadAnnotation} r! : REPORT \\ i?: \nat \where \lnot i? \in 1 \upto maxannotations \\ r! = invalid\_annotation\_number \end{schema} \begin{schema}{BadCounts} r! : REPORT \\ i?: \nat \\ s? : SHAPE \\ z? : \seq \num \where \# z? \neq size~s? \\ r! = counts\_dont\_fill\_shape \end{schema} \begin{schema}{BadHistogram} r! : REPORT \\ i?: \nat \\ s : Spectrum \where \lnot i? \in \dom s.arrays \\ r! = invalid\_annotation\_number \end{schema} \begin{schema}{UnknownSpectrum} \Xi Histogrammer \\ r! : REPORT \\ n? : NAME \where \lnot n? \in \dom store \\ r! = spectrum\_not\_known \end{schema} \begin{schema}{AlreadyExists} \Xi Histogrammer \\ r! : REPORT \\ n?: NAME \where n? \in \dom store \\ r! = spectrum\_already\_exists \end{schema} \begin{schema}{UnsuitableShape} s? : SHAPE \\ r! : REPORT \where \lnot (shapedimension~s? = 1 \land first (head~s?) = 0 \land second (head~s?) \in validranges) \\ r! = shape\_unsuitable\_for\_histogrammer \end{schema} \begin{schema}{NoMemory} \Xi Histogrammer \\ s? : SHAPE \\ r! : REPORT \where \lnot (\exists m,r: \nat @ r = size~s? \land m \mod r = 0 \land \memfree (m,r)) \\ r! = insufficient\_histogramming\_memory \end{schema} \begin{schema}{TagInUse} \Xi HistogrammerCard \\ t? : TAG \\ r! : REPORT \where tagstate~t? = enabled \\ r! = tag\_already\_being\_histogrammed \end{schema} \begin{schema}{NotAssociated} \Xi HistogrammerCard \\ \Xi HistogramMemory \\ t? : TAG \\ r! : REPORT \\ h : Histogram \where \lnot (\exists t:TAG @ tagbase~t * 1024 = membase~h) \\ r! = histogram\_not\_associated\_with\_tag \end{schema} \subsection{Total operations} We can now specify total versions of our earlier operations: \begin{zed} CreateSpectrumOp \defs (CreateHistogrammerSpectrum \land Ok) \lor AlreadyExists \\ \t1 \lor BadShape \lor NoMemory \\ DeleteSpectrumOp \defs (DeleteHistogrammerSpectrum \land Ok) \lor UnknownSpectrum \\ ReadHistogramOp \defs (ReadHistogram \land Ok) \lor UnknownSpectrum \lor BadHistogram \\ \t1 \lor BadShape \\ WriteHistogramOp \defs (WriteHistogram \land Ok) \lor UnknownSpectrum \lor BadHistogram \lor BadShape \\ \t1 \lor BadCounts \\ ZeroHistogramOp \defs (ZeroHistogram \land Ok) \lor UnknownSpectrum \lor BadHistogram \lor BadShape \\ \t1 \lor BadCounts \\ ReadExtremaOp \defs (ReadExtrema \land Ok) \lor UnknownSpectrum \lor BadHistogram \\ WriteExtremaOp \defs (WriteExtrema \land Ok) \lor UnknownSpectrum \lor BadHistogram \\ ReadAnnotationOp \defs (ReadAnnotation \land Ok) \lor UnknownSpectrum \lor BadAnnotation \\ WriteAnnotationOp \defs (WriteAnnotation \land Ok) \lor UnknownSpectrum \lor BadAnnotation \\ ReadCalibrationOp \defs (ReadCalibration \land Ok) \lor UnknownSpectrum \lor BadCalibration \\ WriteCalibrationOp \defs (WriteCalibration \land Ok) \lor UnknownSpectrum \lor BadCalibration \\ AssociateTagOp \defs (AssociateTag \land Ok) \lor UnknownSpectrum \lor BadHistogram \lor TagInUse \\ DissociateTagOp \defs (DissociateTag \land Ok) \lor UnknownSpectrum \lor BadHistogram \lor NotAssociated \end{zed} \begin{thebibliography}{99} \bibitem{JRA}{\em Eurogam Project: Specification of Histogrammer}, John Alexander, October 1990, EDOC???. \end{thebibliography} \end{document}