\documentclass[10pt]{datasheet}
\usepackage{palatino}
\usepackage{textgreek}
\usepackage{minted}
\usepackage{tcolorbox}
\usepackage{etoolbox}

\usepackage[justification=centering]{caption}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[english]{isodate}

\usepackage{graphicx}
\usepackage{subfig}

\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{circuitikz}
\usetikzlibrary{calc}
\usetikzlibrary{fit,backgrounds} 

\title{2238 MCX-TTL}
\author{M-Labs Limited}
\date{January 2022}
\revision{Revision 2}
\companylogo{\includegraphics[height=0.73in]{artiq_sinara.pdf}}

\begin{document}
\maketitle

\section{Features}

\begin{itemize}
\item{16 channels.}
\item{Input and output capable.}
\item{No galvanic isolation.}
\item{High speed and low jitter.}
\item{MCX connectors.}
\end{itemize}

\section{Applications}

\begin{itemize}
\item{Photon counting.}
\item{External equipment trigger.}
\item{Optical shutter control.}
\end{itemize}

\section{General Description}
The 2238 MCX-TTL card is a 4hp EEM module.
It adds general-purpose digital I/O capabilities to carrier cards such as 1124 Kasli and 1125 Kasli-SoC.

Each card provides four banks of four digital channels each, with MCX connectors, controlled through 2 EEM connectors.
Each EEM connector controls two banks independently.
Single EEM operation is possible.
The direction (input or output) of each bank can be selected using DIP switches.
Each channel supports 50\textOmega~terminations individually controllable using DIP switches.
This card can achieve higher speed and lower jitter than the isolated 2118/2128 BNC/SMA-TTL cards.

% Switch to next column
\vfill\break

\newcommand*{\MyLabel}[3][2cm]{\parbox{#1}{\centering #2 \\ #3}}
\newcommand*{\MymyLabel}[3][4cm]{\parbox{#1}{\centering #2 \\ #3}}
\newcommand{\inputcolorboxminted}[2]{%
    \begin{tcolorbox}[colback=white]
    \inputminted[#1, gobble=4]{python}{#2}
    \end{tcolorbox}
}

\begin{figure}[h]
    \centering
    \scalebox{0.88}{
    \begin{circuitikz}[european, scale=0.95, every label/.append style={align=center}]
        % Node to pin-point the locations of MCX symbols
        \draw[color=white, text=black] (-0.1, 0.7) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx0) {};
        \draw[color=white, text=black] (-0.1, 0.35) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx1) {};
        \draw[color=white, text=black] (-0.1, 0) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx2) {};
        \draw[color=white, text=black] (-0.1, -0.35) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx3) {};
        \draw[color=white, text=black] (-0.1, -1.05) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx4) {};
        \draw[color=white, text=black] (-0.1, -1.4) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx5) {};
        \draw[color=white, text=black] (-0.1, -1.75) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx6) {};
        \draw[color=white, text=black] (-0.1, -2.1) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx7) {};
        \draw[color=white, text=black] (-0.1, -4.2) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx8) {};
        \draw[color=white, text=black] (-0.1, -4.55) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx9) {};
        \draw[color=white, text=black] (-0.1, -4.9) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx10) {};
        \draw[color=white, text=black] (-0.1, -5.25) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx11) {};
        \draw[color=white, text=black] (-0.1, -5.95) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx12) {};
        \draw[color=white, text=black] (-0.1, -6.3) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx13) {};
        \draw[color=white, text=black] (-0.1, -6.65) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx14) {};
        \draw[color=white, text=black] (-0.1, -7) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (mcx15) {};

        % Labels for IO 0-15
        \node [label=left:\tiny{IO 0}] at (0.35, 0.7) {};
        \node [label=left:\tiny{IO 1}] at (0.35, 0.35) {};
        \node [label=left:\tiny{IO 2}] at (0.35, 0) {};
        \node [label=left:\tiny{IO 3}] at (0.35, -0.35) {};
        \node [label=left:\tiny{IO 4}] at (0.35, -1.05) {};
        \node [label=left:\tiny{IO 5}] at (0.35, -1.4) {};
        \node [label=left:\tiny{IO 6}] at (0.35, -1.75) {};
        \node [label=left:\tiny{IO 7}] at (0.35, -2.1) {};
        \node [label=left:\tiny{IO 8}] at (0.35, -4.2) {};
        \node [label=left:\tiny{IO 9}] at (0.35, -4.55) {};
        \node [label=left:\tiny{IO 10}] at (0.35, -4.9) {};
        \node [label=left:\tiny{IO 11}] at (0.35, -5.25) {};
        \node [label=left:\tiny{IO 12}] at (0.35, -5.95) {};
        \node [label=left:\tiny{IO 13}] at (0.35, -6.3) {};
        \node [label=left:\tiny{IO 14}] at (0.35, -6.65) {};
        \node [label=left:\tiny{IO 15}] at (0.35, -7) {};

        % Draw all female MCX connectors
        % Bank 1
        \begin{scope}[scale=0.07 , rotate=-90, xshift=-10cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=-5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=0cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}

        % Bank 2
        \begin{scope}[scale=0.07 , rotate=-90, xshift=15cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=20cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=25cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=30cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}

        % Bank 3
        \begin{scope}[scale=0.07 , rotate=-90, xshift=60cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=65cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=70cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=75cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}

        % Bank 4
        \begin{scope}[scale=0.07 , rotate=-90, xshift=85cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=90cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=95cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=100cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}

        % Draw bank boundaries
        \node[draw, dotted, thick, rounded corners, inner xsep=0.7em, inner ysep=0.2em, fit=(mcx0)(mcx3)] (bank0) {};
        \node[fill=white, scale=0.7, rotate=-90] at (bank0.west) {Bank 0};
        \node[draw, dotted, thick, rounded corners, inner xsep=0.7em, inner ysep=0.2em, fit=(mcx4)(mcx7)] (bank1) {};
        \node[fill=white, scale=0.7, rotate=-90] at (bank1.west) {Bank 1};
        \node[draw, dotted, thick, rounded corners, inner xsep=0.7em, inner ysep=0.2em, fit=(mcx8)(mcx11)] (bank2) {};
        \node[fill=white, scale=0.7, rotate=-90] at (bank2.west) {Bank 2};
        \node[draw, dotted, thick, rounded corners, inner xsep=0.7em, inner ysep=0.2em, fit=(mcx12)(mcx15)] (bank3) {};
        \node[fill=white, scale=0.7, rotate=-90] at (bank3.west) {Bank 3};

        % Draw bus transceivers
        \draw (3.25, -0.7) node[twoportshape,t=\MymyLabel{IO Bus}{Transceivers}, circuitikz/bipoles/twoport/width=3.2, scale=0.7, rotate=-90 ] (bus0) {};
        \draw (3.25, -5.6) node[twoportshape,t=\MymyLabel{IO Bus}{Transceivers}, circuitikz/bipoles/twoport/width=3.2, scale=0.7, rotate=-90 ] (bus1) {};

        % Draw termination switches
        % Bus transceiver 0
        \draw (1.7, 1.2) node[twoportshape,t=\MymyLabel{High-Z/50\textOmega}{Switch \phantom{ssssss} }, circuitikz/bipoles/twoport/width=2, scale=0.4] (termswitch0) {};
        \begin{scope}[xshift=1.8cm, yshift=1.23cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=1.9cm, yshift=1.23cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=2.0cm, yshift=1.23cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=2.1cm, yshift=1.23cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}

        % Bus transceiver 1
        \draw (1.5, -2.6) node[twoportshape,t=\MymyLabel{High-Z/50\textOmega}{Switch \phantom{ssssss} }, circuitikz/bipoles/twoport/width=2, scale=0.4] (termswitch1) {};
        \begin{scope}[xshift=1.6cm, yshift=-2.57cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=1.7cm, yshift=-2.57cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=1.8cm, yshift=-2.57cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=1.9cm, yshift=-2.57cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}

        % Bus transceiver 2
        \draw (1.7, -3.7) node[twoportshape,t=\MymyLabel{High-Z/50\textOmega}{Switch \phantom{ssssss} }, circuitikz/bipoles/twoport/width=2, scale=0.4] (termswitch2) {};
        \begin{scope}[xshift=1.8cm, yshift=-3.67cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=1.9cm, yshift=-3.67cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=2cm, yshift=-3.67cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=2.1cm, yshift=-3.67cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}

        % Bus transceiver 3
        \draw (1.5, -7.5) node[twoportshape,t=\MymyLabel{High-Z/50\textOmega}{Switch \phantom{ssssss} }, circuitikz/bipoles/twoport/width=2, scale=0.4] (termswitch3) {};
        \begin{scope}[xshift=1.6cm, yshift=-7.47cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=1.7cm, yshift=-7.47cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=1.8cm, yshift=-7.47cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=1.9cm, yshift=-7.47cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}

        % Connection termination switches to each IO line 
        % IO 0, 2, 4, 6
        \draw [-] (1.4, 1) -- (1.4, 0.7);
        \draw [-] (1.6, 1) -- (1.6, 0);
        \draw [-] (1.8, 1) -- (1.8, -1.05);
        \draw [-] (2, 1) -- (2, -1.75);

        % IO 1, 3, 5, 7
        \draw [-] (1.2, -2.4) -- (1.2, 0.35);
        \draw [-] (1.4, -2.4) -- (1.4, -0.35);
        \draw [-] (1.6, -2.4) -- (1.6, -1.4);
        \draw [-] (1.8, -2.4) -- (1.8, -2.1);

        % IO 8, 10, 12, 14
        \draw [-] (1.4, -3.9) -- (1.4, -4.2);
        \draw [-] (1.6, -3.9) -- (1.6, -4.9);
        \draw [-] (1.8, -3.9) -- (1.8, -5.95);
        \draw [-] (2, -3.9) -- (2, -6.65);

        % IO 9, 11, 13, 15
        \draw [-] (1.2, -7.3) -- (1.2, -4.55);
        \draw [-] (1.4, -7.3) -- (1.4, -5.25);
        \draw [-] (1.6, -7.3) -- (1.6, -6.3);
        \draw [-] (1.8, -7.3) -- (1.8, -7);

        % Connect I/Os to corresponding tranceivers
        \draw [latexslim-latexslim] (mcx0) -- (2.9, 0.7);
        \draw [latexslim-latexslim] (mcx1) -- (2.9, 0.35);
        \draw [latexslim-latexslim] (mcx2) -- (2.9, 0);
        \draw [latexslim-latexslim] (mcx3) -- (2.9, -0.35);

        \draw [latexslim-latexslim] (mcx4) -- (2.9, -1.05);
        \draw [latexslim-latexslim] (mcx5) -- (2.9, -1.4);
        \draw [latexslim-latexslim] (mcx6) -- (2.9, -1.75);
        \draw [latexslim-latexslim] (mcx7) -- (2.9, -2.1);

        \draw [latexslim-latexslim] (mcx8) -- (2.9, -4.2);
        \draw [latexslim-latexslim] (mcx9) -- (2.9, -4.55);
        \draw [latexslim-latexslim] (mcx10) -- (2.9, -4.9);
        \draw [latexslim-latexslim] (mcx11) -- (2.9, -5.25);

        \draw [latexslim-latexslim] (mcx12) -- (2.9, -5.95);
        \draw [latexslim-latexslim] (mcx13) -- (2.9, -6.3);
        \draw [latexslim-latexslim] (mcx14) -- (2.9, -6.65);
        \draw [latexslim-latexslim] (mcx15) -- (2.9, -7);

        % Draw LVDS transceivers
        \draw (5.05, -0.025) node[twoportshape,t={\MymyLabel{LVDS}{Transceiver}}, circuitikz/bipoles/twoport/width=2, scale=0.5, rotate=-90 ] (lvds0) {};
        \draw (5.05, -1.675) node[twoportshape,t={\MymyLabel{LVDS}{Transceiver}}, circuitikz/bipoles/twoport/width=2, scale=0.5, rotate=-90 ] (lvds1) {};
        \draw (5.05, -4.625) node[twoportshape,t={\MymyLabel{LVDS}{Transceiver}}, circuitikz/bipoles/twoport/width=2, scale=0.5, rotate=-90 ] (lvds2) {};
        \draw (5.05, -6.275) node[twoportshape,t={\MymyLabel{LVDS}{Transceiver}}, circuitikz/bipoles/twoport/width=2, scale=0.5, rotate=-90 ] (lvds3) {};

        % Aesthetic EEPROM at each end of LVDS transceivers
        \draw (5.05, 1.1) node[twoportshape,t={EEPROM}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (eeprom0) {};
        \draw (5.05, -7.4) node[twoportshape,t={EEPROM}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (eeprom1) {};

        % I/O expander
        \draw (6.65, -3.5) node[twoportshape,t=\MymyLabel{IO Expander}{for I2C Bus}, circuitikz/bipoles/twoport/width=1.8, scale=0.5] (i2c) {};

        % I/O direction switches
        \draw (5.05, -2.8) node[twoportshape,t=\MymyLabel{Per-bank \phantom{space} }{Input/Output Switch}, circuitikz/bipoles/twoport/width=2.7, scale=0.44] (ioswitch) {};
        \begin{scope}[xshift=5.3cm, yshift=-2.57cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=5.4cm, yshift=-2.57cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=5.5cm, yshift=-2.57cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}
        \begin{scope}[xshift=5.6cm, yshift=-2.57cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}

        % EEM Ports
        \draw (6.65, -0.5) node[twoportshape, t={EEM Port 0}, circuitikz/bipoles/twoport/width=3.6, scale=0.7, rotate=-90] (eem0) {};
        \draw (6.65, -5.8) node[twoportshape, t={EEM Port 1}, circuitikz/bipoles/twoport/width=3.6, scale=0.7, rotate=-90] (eem1) {};

        % Connect I/O expander & direction switches to bus transceivers block
        % The transceivers had been grouped up, there is no need to label I/O direction indices anymore
        % It might still be useful to identify the direction line itself, though
        \draw [latexslim-] (i2c.west) -- (3.25, -3.5);
        \draw [-] (ioswitch.south) -- (5.05, -3.5);
        \draw [latexslim-latexslim] (bus0.east) -- (bus1.west);
        \node [label=center:\tiny{IO Direction}] at (4.1, -3.4) {};

        % Connect LVDS transceivers to bus transceivers, with labelling
        \draw [latexslim-latexslim] (lvds0.south) -- (3.6, -0.025);
        \node [label=center:\tiny{EEM}] at (4.2, 0.075) {};
        \node [label=center:\tiny{0..3}] at (4.2, -0.125) {};
        \draw [latexslim-latexslim] (lvds1.south) -- (3.6, -1.675);
        \node [label=center:\tiny{EEM}] at (4.2, -1.575) {};
        \node [label=center:\tiny{4..7}] at (4.2, -1.775) {};
        \draw [latexslim-latexslim] (lvds2.south) -- (3.6, -4.625);
        \node [label=center:\tiny{EEM}] at (4.2, -4.525) {};
        \node [label=center:\tiny{8..11}] at (4.2, -4.725) {};
        \draw [latexslim-latexslim] (lvds3.south) -- (3.6, -6.275);
        \node [label=center:\tiny{EEM}] at (4.2, -6.175) {};
        \node [label=center:\tiny{12..15}] at (4.2, -6.375) {};

        % Connect EEM0 & EEM1
        \draw [latexslim-latexslim] (lvds0.north) -- (6.3, -0.025);
        \draw [latexslim-latexslim] (lvds1.north) -- (6.3, -1.675);
        \draw [latexslim-latexslim] (lvds2.north) -- (6.3, -4.625);
        \draw [latexslim-latexslim] (lvds3.north) -- (6.3, -6.275);
        \draw [latexslim-latexslim] (eeprom0.east) -- (6.3, 1.1);
        \draw [latexslim-latexslim] (eeprom1.east) -- (6.3, -7.4);
        \draw [latexslim-latexslim] (eem0.east) -- (i2c.north);

        % Reminder: IO directions are only selectable by bank. Channels from the same bank must have the same IO direction.
        % Might be unnecessary as I/O directions signals are labelled with the "Bank" prefix.
        \node [label={center:\tiny{Channels from the same bank}}] at (1.4, -3.05) {};
        \node [label={center:\tiny{must have the same IO direction.}}] at (1.4, -3.25) {};

    \end{circuitikz}
    }

    \caption{Simplified Block Diagram}
\end{figure}

\begin{figure}[hbt!]
    \centering
    \includegraphics[width=3.6in]{photo2238.jpg}
    \caption{MCX-TTL Card photo}
\end{figure}

% For wide tables, a single column layout is better. It can be switched
% page-by-page.
\onecolumn

\section{Electrical Specifications}

Both recommended operating conditions and electrical characteristics are based on the datasheet of the bus transceivers IC (74LVT162245MTD\footnote{\label{transceiver}https://www.onsemi.com/pdf/datasheet/74lvt162245-d.pdf}).

\begin{table}[h]
\begin{threeparttable}
\caption{Recommended Operating Conditions}
\begin{tabularx}{\textwidth}{l | c | c c c | c | X}
    \thickhline
    \textbf{Parameter} & \textbf{Symbol} & \textbf{Min.} & \textbf{Typ.} & \textbf{Max.} &
    \textbf{Unit} & \textbf{Conditions} \\
    \hline
    Input voltage & $V_{I}$ & 0 & & 5.5 & V \\
    \hline
    High-level output current & $I_{OH}$ & & & -24 & mA \\
    \hline
    Low-level output current & $I_{OL}$ & & & 24 & mA \\
    \hline
    Input edge rate & $\frac{\Delta t}{\Delta V}$ & 0 & & 10 & ns/V & $0.8V \leq V_I \leq 2.0V$ \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}
The recommended operating temperature is $-40\degree C \leq T_A \leq 85\degree C$.
All specifications are in the recommended operating temperature range unless otherwise noted.

\begin{table}[h]
\begin{threeparttable}
\caption{Electrical Characteristics}
\begin{tabularx}{\textwidth}{l | c | c c c | c | X}
    \thickhline
    \textbf{Parameter} & \textbf{Symbol} & \textbf{Min.} & \textbf{Typ.} & \textbf{Max.} &
    \textbf{Unit} & \textbf{Conditions} \\
    \hline
    Input clamp diode voltage & $V_{IK}$ & & & -1.2 & V & $I_I =-36 mA$ \\
    \hline
    Input high voltage & $V_{IH}$ & 2.0 & & & V & \\
    \hline
    Input low voltage & $V_{IL}$ & & & 0.8 & V & \\
    \hline
    Output high voltage & $V_{OH}$ & 2.0 & & & V & $I_{OH}=-24mA$ \\
    & & 3.1 & & & V & $I_{OH}=-200\mu A$ \\
    \hline
    Output low voltage & $V_{OL}$ & & & 0.8 & V & $I_{OL}=-24mA$ \\
    & & & & 0.2 & V & $I_{OL}=-200\mu A$ \\
    \hline
    Input current & $I_I$ & & & 20 & \textmu A & $V_I=5.5V$ \\
    & & & & 2 & \textmu A & $V_I=3.3V$ \\
    & & & & -10 & \textmu A & $V_I=0V$ \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}

\newpage

\section{Configuring IO Direction \& Termination}
The termination and IO direction can be configured by switches.
The per-channel termination and per-bank IO direction switches are found at the top and middle of the card respectively.
\begin{multicols}{2}
Termination switches selects the termination of each channel, between high impedence (OFF) and 50\textOmega~(ON).

IO direction switches partly decides the IO direction of each bank.
\begin{itemize}
    \itemsep0em
    \item Closed switch (ON) \\
          Fix the corresponding bank to output. The direction cannot be changed by I\textsuperscript{2}C.
    \item Opened switch (OFF) \\
          Leave the direction configurable by I\textsuperscript{2}C.
\end{itemize}
\columnbreak
\begin{center}
    \centering
    \includegraphics[height=1.7in]{mcx_ttl_switches.jpg}
    \captionof{figure}{Position of switches}
\end{center}
\end{multicols}

\newpage
\section{Example ARTIQ code}
The sections below demonstrate simple usage scenarios of the 2245 LVDS-TTL card with the ARTIQ control system.
They do not exhaustively demonstrate all the features of the ARTIQ system.
The full documentation for the ARTIQ software and gateware is available at \url{https://m-labs.hk}.

Timing accuracy in the examples below is well under 1 nanosecond thanks to the ARTIQ RTIO system.

\subsection{One pulse per second}
The channel should be configured as output in both the gateware and hardware.
\inputcolorboxminted{firstline=9,lastline=15}{examples/ttl.py}

\subsection{Morse code}
This example demonstrates some basic algorithmic features of the ARTIQ-Python language.
\inputcolorboxminted{firstline=23,lastline=40}{examples/ttl.py}

\newpage
\subsection{Counting rising edges in a 1ms window}
The channel should be configured as input in both the gateware and hardware.
\inputcolorboxminted{firstline=48,lastline=53}{examples/ttl.py}

This example code uses the software counter, which has a maximum count rate of approximately 1 million events per second.
If the gateware counter is enabled on the TTL channel, it can typically count up to 125 million events per second:
\inputcolorboxminted{firstline=61,lastline=66}{examples/ttl.py}

\subsection{Responding to an external trigger}
One channel needs to be configured as input, and the other as output.
\inputcolorboxminted{firstline=75,lastline=81}{examples/ttl.py}

\section{Ordering Information}
To order, please visit \url{https://m-labs.hk} and select the 2238 MCX-TTL in the ARTIQ Sinara crate configuration tool. The card may also be ordered separately by writing to \url{mailto:sales@m-labs.hk}.

\section*{}
\vspace*{\fill}

\begin{footnotesize}
Information furnished by M-Labs Limited is provided in good faith in the hope that it will be useful. However, no responsibility is assumed by M-Labs Limited for its use. Specifications may be subject to change without notice.
\end{footnotesize}

\end{document}
