Index: /firmware/FAD/doc/memory_manager.tex
===================================================================
--- /firmware/FAD/doc/memory_manager.tex	(revision 10139)
+++ /firmware/FAD/doc/memory_manager.tex	(revision 10139)
@@ -0,0 +1,117 @@
+\documentclass[a4paper,twoside]{article}
+
+\setlength{\topmargin}{0mm}  %1 inch is always there!
+\setlength{\oddsidemargin}{0mm}  %1 inch is always there!
+\setlength{\evensidemargin}{0mm}  %1 inch is always there!
+
+\setlength{\textwidth}{16cm} 
+
+% keine Kopfzeile?
+\setlength{\headheight}{0mm} 
+\setlength{\headsep}{0mm}
+
+ 
+%um die deutschen Umlaute eingeben zu können
+% müssen diese 3 Pakete eingebunden werden.
+% welches der Pakete was macht, weiss ich nicht.
+\usepackage[T1]{fontenc}
+\usepackage[latin1]{inputenc}
+%\usepackage{ngerman}					% nur wenn z.B. 'Inhaltsverzeichnis' auch deutsch sein soll.
+
+\usepackage{graphicx} % for pictures
+\usepackage{float} % for figures with english descriptions
+
+\restylefloat{figure}
+\restylefloat{table}
+
+\begin{document}
+
+%\maketitle
+
+%\tableofcontents
+%\listoffigures
+%\listoftables
+
+\section{\tt memory manager.vhd}
+
+The Memory Manager is used to calculate:
+\begin{itemize}
+\item
+\end{itemize}
+
+\subsection{data order in 64bit address space}
+
+When data is input into Data-RAM by the DataGenerator, the data is fed in as words of 64bit,
+because the 13bits of each of the four ADCs is processed in a parallel manner.
+
+Each Event constists of an EventHeader, the so called ChannelData, and a small EventFooter.
+Figure (\ref{64bitRAM}) shows how the data is stored as 64bit words in the DataRAM.
+Assume the Event Start-Address beeing {\tt 0x2000} and each package of ChannelData consists of 100 samples.
+
+Erklaeren, dass auch wenn nur ein channel kleiner ist, die selbe Anzahl Daten versendet wird.
+
+
+\begin{table}[htbp]
+
+\begin{tabular}{||l||l|l|l|l||l||} %6 linkbuendige spalten
+\hline
+address & word 3 & word 2 & word 1 & word 0 & mnemonic \\
+\hline
+0x2000 	& 0x0000 & Version	& 0xLLLL & 0xFB01	& Header	\\  
+0x2001	& 0x0000 & TRG-ID 4,5	& TRG-ID 1,0	& TRG-ID 3,2	& Externl trigger ID	\\
+0x2002	& 0x0000 & TRG-ID 4,5	& TRG-ID 1,0	& TRG-ID 3,2	& Internal trigger ID	(now just a copy\\
+0x2003	& 0x0000	& 0x0000	& 0x0000	& 0x0(cid)8(bid)	& Board ID 	\\
+0x2004	& Temp 3	& Temp 2	& Temp 1	& Temp 0	& Temperatures \\
+0x2005	& DAC 3	& DAC 2	& DAC 1	& DAC 0	& DAC values part 1	\\
+0x2006	& DAC 7	& DAC 6	& DAC 5	& DAC 4	& DAC values part 2	\\
+\hline
+0x2007	& 0x0030	& 0x0020	& 0x0010	& 0x0000	& chip-n-channel ID (channel group 0) \\
+0x2008	& trg pos 3	& trg pos 2	& trg pos 1	& trg pos 0	& DRS stop positions \\
+0x2009	& ROI 3	& ROI 2	& ROI 1	& ROI 0	& width of region of interest \\
+0x200A	& data adc3	& data adc2	& data adc1	& data adc0	& ADC Data start of ROI \\
+0x20..  &&&&& ... \\
+0x206D	& data adc3	& data adc2	& data adc1	& data adc0	& ADC Data end of ROI \\
+\hline
+0x206E	& 0x0031	& 0x0021	& 0x0011	& 0x0001	& chip-n-channel ID (channel group 1) \\
+0x206F	& trg pos 3	& trg pos 2	& trg pos 1	& trg pos 0	& DRS stop positions \\
+0x2070	& ROI 3	& ROI 2	& ROI 1	& ROI 0	& width of region of interest \\
+0x2071	& data adc3	& data adc2	& data adc1	& data adc0	& ADC Data start of ROI \\
+0x20..  &&&&& ... \\
+0x20D4	& data adc3	& data adc2	& data adc1	& data adc0	& ADC Data end of ROI \\
+\hline
+0x20..  &&&&& ... \\
+\hline
+0x233F	& 0x0039	& 0x0029	& 0x0019	& 0x0009	& chip-n-channel ID (channel group 9) \\
+0x2340	& trg pos 3	& trg pos 2	& trg pos 1	& trg pos 0	& DRS stop positions \\
+0x2341	& ROI 3	& ROI 2	& ROI 1	& ROI 0	& width of region of interest \\
+0x2342	& data adc3	& data adc2	& data adc1	& data adc0	& ADC Data start of ROI \\
+0x23..  &&&&& ... \\
+0x23A5	& data adc3	& data adc2	& data adc1	& data adc0	& ADC Data end of ROI \\
+\hline
+0x23A6	& ??	& ??	& ??	& ??	& FOOTER \\
+\hline
+\end {tabular}
+
+\caption{word order of event in Data RAM. 64bit addressing.}
+\label{64bitRAM}
+\end{table}
+
+
+During DRS readout and data digitzation, the Trigger ID is coming in through RS485 interface from FTM board.
+The Trigger ID reciption takes about $40 {\mu}$s. Therefor the 2 words containing Trigger information in the EventHeader are
+left empty in the first place. The digitazed analog data is read in as quickly as possible. Only after finishing the Readout,
+the Trigger ID is filled into the EventHeader.
+Then the EventFooter is added and the Readout is finished.
+
+\subsection{role of memory manager for DataGenerator}
+After FAD-configuration memory manager informs data generator, whether additional Data may be read out or not.
+{\tt ram write ea } is used to inform DataGenerator.\\
+
+DataGenerator needs to know how many samples to read out of each channel. 
+{\tt roi max} is carriing this information. \\
+
+
+\appendix
+
+
+\end{document}
