================================ Befehlsformat und Aufbau der ULM ================================ Ein Computerprogramm besteht aus einer Folge von Befehlen, die in einer festgelegten Reihenfolge ausgeführt werden. Mit jedem Befehl kann eine Komponente des Computers gesteuert werden. Man muss also wissen, welche Komponenten gesteuert werden können, welche Befehle man verwenden kann Gemeinsamkeiten mit der Mini-ALU ================================ Befehle für die ULM bestehen aus 32 Bits, haben aber im Prinzip das gleiche Format wie die Befehle der Mini-ALU: ---- TIKZ ---------------------------- \begin{tikzpicture} \input{memory.tex} \renewcommand\MemCellWidth {1} \DrawMemArray{0}{3} \DrawMemCellContent{0}{Op} \DrawMemCellContent{1}{X} \DrawMemCellContent{2}{Y} \DrawMemCellContent{3}{Z} \end{tikzpicture} -------------------------------------- Die Felder Op, X, Y, Y bestehen aus jeweils 8 Bits. Es bietet sich deshalb an, dass Befehle in der Hexadezimaldarstellung aufgeschrieben werden, womit jedes Feld mit zwei hexadezimalen Ziffern beschrieben wird. In Darstellung wie beispielsweise ---- TIKZ ---------------------------- \begin{tikzpicture} \input{memory.tex} \renewcommand\MemCellWidth {1} \DrawMemArray{0}{3} \DrawMemCellContent{0}{30} \DrawMemCellContent{1}{01} \DrawMemCellContent{2}{02} \DrawMemCellContent{3}{03} \end{tikzpicture} -------------------------------------- kann das Präfix `0x` weggelassen werden, da klar ist, dass hier hexadezimal Ziffern gemeint sind und die Bitmuster der Felder mit Op = 0x30, X = 0x01, Y = 0x02 und Z = 0x03 beschrieben werden. Wie bei der Mini-ALU bezeichnet Op den Opcode, also den Befehlstyp und X, Y und Z werden als Operanden benutzt. Beispielsweise ist Op=0x30 ein Befehl, um Register zu addieren. Hier ein Auszug aus dem Befehlssatz, mit Befehlen und Bezeichnungen analog zum Befehlssatz der Mini-ALU: ---- LATEX --------------------------------------------------------------------- \begin{array}{ll} \text{Op} & \text{Effekt} \\ \text{0x56} & \bigl(u(\text{%00}) + u(\text{XY})\bigr) \bmod 2^{64} \to u(\text{%}Z) \\ \text{0x5D} & \bigl(u(\text{%}Z)\cdot 2^{16} + u(\text{XY})\bigr) \bmod 2^{64} \to u(\text{%}Z) \\ \text{0x30} & \bigl(u(\text{%}Y) + u(\text{%}X)\bigr) \bmod 2^{64} \to u(\text{%}Z) \\ \text{0x31} & \bigl(u(\text{%}Y) - u(\text{%}X)\bigr) \bmod 2^{64} \to u(\text{%}Z) \\ \end{array} -------------------------------------------------------------------------------- Gilt also wie bei obigen Befehl Op = 0x30, X = 0x01, Y = 0x02 und Z = 0x03, dann kann dessen Effekt mit ---- LATEX --------------------------------------------------------------------- \bigl(u(\text{%0x02}) + u(\text{%0x01})\bigr) \bmod 2^{64} \to u(\text{%0x03}) -------------------------------------------------------------------------------- beschrieben werden, d.h. das Register `%0x01` wird mit Register `%0x02` addiert und das Ergebnis in Register `%0x03` geschrieben. Im Unterschied zur Mini-ALU sind die Arbeitsregister der ULM jeweils 64-Bit-Register. Bei der Addition wird also Modulo $2^{64}$ gerechnet. Die Flags CF, OF, SF und ZF im Statusregister werden aber nach den gleichen Regeln gesetzt. Aufbau im Groben ================ ---- TIKZ ---------------------------------------------------------------------- \begin{tikzpicture}[x=1.3cm,y=0.9cm,name=main, font=\sffamily ] %% Bottom \newcommand\XBot{\XTop} % X offset middle \newcommand\YBot{0} % Y offset middle \newcommand\HBot{4.4} % Height middle boxes \newcommand\PXBot{0.4} % padding x at bottom \newcommand\PYBot{0.5} % padding y at bottom % X offset and width of boxes \newcommand\XCpu{\XBot} % CPU \newcommand\WCpu{\WBus} \newcommand\XCu{\XBot+\PXBot} % control unit \newcommand\YCu{\YBot+\PYBot} \newcommand\WCu{8} \newcommand\HCu{2.4} \newcommand\XAlu{\XCu+\WCu+\PXBot} % control unit \newcommand\YAlu{\YBot+\PYBot} \newcommand\WAlu{\WCpu-\WCu-3*\PXBot} \newcommand\HAlu{2.4} %% Middle \newcommand\XMid{\XTop} % X offset middle \newcommand\YMid{\YBot+\HBot+2} % Y offset middle \newcommand\HMid{0.1} % Height middle boxes % X offset and width of boxes \newcommand\XBus{\XMid} % bus \newcommand\WBus{\XOut+\WOut} \newcommand\XBusText{\XBus+0.4} % busText %% Top \newcommand\XTop{0} % X offset top \newcommand\YTop{\YMid+2} % Y offset top \newcommand\HTop{2} % Height top boxes \newcommand\PXTop{0.4} % padding x at top % X offset and width of boxes \newcommand\XMem{\XTop} % memory \newcommand\WMem{10} \newcommand\XIn{\XTop + \WMem + \PXTop} % input \newcommand\WIn{3.6} \newcommand\XOut{\XIn + \WIn + \PXTop} % output \newcommand\WOut{5} %% ----------------- %% At Top % RAM \draw [fill=gray!30] (\XMem,\YTop) rectangle (\XMem+\WMem,\YTop+\HTop); \draw (\XMem + \WMem/2,\YTop + \HTop/2) node {\strut Speicher}; % Input \draw [fill=gray!30] (\XIn,\YTop) rectangle (\XIn+\WIn,\YTop+\HTop); \draw (\XIn + \WIn/2,\YTop + \HTop/2) node {\strut Eingabegerät}; % Output \draw [fill=gray!30] (\XOut,\YTop) rectangle (\XOut+\WOut,\YTop+\HTop); \draw (\XOut + \WOut/2,\YTop + \HTop/2) node {\strut Ausgabegerät}; %% At Middle % BUS \fill (\XBus,\YMid) rectangle (\XBus+\WBus,\YMid+\HMid); % annotate Bus \draw (\XBusText,\YMid) node[above] {Bus}; % connect Mem with BUS \draw [<->] (\XMem + \WMem/2, \YTop) -- (\XMem + \WMem/2 , \YMid+\HMid); % connect In with BUS \draw [->] (\XIn + \WIn/2, \YTop) -- (\XIn + \WIn/2 , \YMid+\HMid); % connect Out with BUS \draw [<-] (\XOut + \WOut/2, \YTop) -- (\XOut + \WOut/2 , \YMid+\HMid); %% At Bottom \draw [fill=gray!30] (\XCpu,\YBot) rectangle (\XCpu+\WCpu,\YBot+\HBot); \draw ({\XCpu+(\WCpu)/2},\YBot + \HBot) node[below] {CPU (central processing unit)}; % connect CPU with Bus \draw [<->] ({\XCpu+(\WCpu)/2}, \YBot+\HBot) -- ({\XCpu+(\WCpu)/2}, \YMid); % control unit \draw [fill=white] (\XCu,\YCu) rectangle (\XCu+\WCu,\YCu+\HCu); \draw (\XCu + \WCu/2,\YCu + \HCu) node[below] {\strut Steuerwerk}; \newcommand\XIp{\XCu+0.33} \newcommand\WIp{3.5} \newcommand\XIr{\XIp+\WIp+0.33} \newcommand\WIr{3.5} \draw [fill=white] (\XIp,\YCu+0.2) rectangle (\XIp + \WIp,\YCu+0.8); \draw ({\XIp+\WIp/2},\YCu+0.5) node {\tiny \strut Befehlszeiger (\%IP)}; \draw [fill=white] (\XIr,\YCu+0.2) rectangle (\XIr + \WIr,\YCu+0.8); \draw ({\XIr+\WIr/2},\YCu+0.5) node {\tiny \strut Befehlsregister (\%IR)}; % ALU \draw [fill=white] (\XAlu,\YAlu) rectangle (\XAlu+\WAlu,\YAlu+\HAlu); \draw ({\XAlu + (\WAlu)/2},\YAlu + \HAlu) node[below] {\strut ALU (arithmetical logical unit)}; \newcommand\XRzero{\XAlu+0.33} \newcommand\WR{2.4} \newcommand\XRdots{{(\XRzero+\WR+\XRone)/2}} \newcommand\XRone{\XRlast-\WR-0.33} \newcommand\XRlast{\XAlu+\WAlu-\WR-0.33} \draw [fill=white] (\XRzero,\YAlu+0.2) rectangle (\XRzero + \WR,\YAlu+0.8); \draw ({\XRzero+\WR/2},\YAlu+0.5) node {\tiny \strut Register $0$}; \draw [fill=white] (\XRone,\YAlu+0.2) rectangle (\XRone + \WR,\YAlu+0.8); \draw ({\XRone+\WR/2},\YAlu+0.5) node {\tiny \strut Register $255$}; \draw (\XRdots,\YAlu+0.5) node {\strut $\cdots$}; \draw [fill=white] (\XRlast,\YAlu+0.2) rectangle (\XRlast + \WR,\YAlu+0.8); \draw ({\XRlast+\WR/2},\YAlu+0.5) node {\tiny \strut Statusregister}; \end{tikzpicture} -------------------------------------------------------------------------------- Die Komponenten im Detail ========================= ALU --- Speicher -------- ---- TIKZ ---------------------------------------------------------------------- \begin{tikzpicture} \input{memory.tex} \renewcommand\MemCellWidth {2} \DrawMemArrayOpenRight{0}{12} \DrawMemAddress{0}{0x00} \DrawMemAddress{1}{0x01} \DrawMemAddress{2}{0x02} \DrawMemAddress{3}{0x03} \DrawMemAddress{4}{0x04} \DrawMemAddress{5}{0x05} \DrawMemAddress{6}{0x06} \DrawMemAddress{7}{0x07} \DrawMemAddress{8}{0x08} \DrawMemAddress{9}{0x09} \DrawMemAddress{10}{0x0A} \DrawMemAddress{11}{0x0B} \DrawMemAddress{12}{0x0C} \DrawMemAddress{13}{0x0D} \DrawAnnotateMemCellAbove{9}{Speicherzelle mit Addresse 0x09} \end{tikzpicture} -------------------------------------------------------------------------------- Steuerwerk ----------