\documentclass{beamer}

\usetheme{Pittsburgh}
\usecolortheme{rose}

\usepackage{tabularx}
\usepackage{xcolor}

\addtobeamertemplate{navigation symbols}{}{%
    \usebeamerfont{footline}%
    \usebeamercolor[fg]{footline}%
    \hspace{1em}%
    \insertframenumber/\inserttotalframenumber
}

\newcommand*\ruleline[1]{\par\noindent\raisebox{.8ex}{\makebox[\linewidth]{\hrulefill\hspace{1ex}\raisebox{-.8ex}{#1}\hspace{1ex}\hrulefill}}}

% color macros
\definecolor{BrickRed}{HTML}{B6321C}
\definecolor{OliveGreen}{HTML}{3C8031}
\definecolor{RoyalBlue}{HTML}{0071BC}
\definecolor{MidnightBlue}{HTML}{006795}
\newcommand{\catSN}[0]{\textcolor{BrickRed}{SN} }
\newcommand{\catEX}[0]{\textcolor{OliveGreen}{E} }
\newcommand{\catPE}[0]{\textcolor{RoyalBlue}{PE} }
\newcommand{\catCO}[0]{\textcolor{MidnightBlue}{C} }

\title[fpgas] % (optional, only for long titles)
{Exploring extensions for a basic RISC-V pipeline implementation to support the execution of an operating system}
\subtitle{}
\author[N. Tremurici]
{N.~Tremurici}%\inst{1}}
\institute[Universities Here and There] % (optional)
{
  %\inst{1}%
  Institute of Computer Engineering\newline
  TU Wien
}
\date[BT 2023] % (optional)
{Bachelor Thesis, 2023}
\subject{Computer Engineering}

\begin{document}
    \begin{frame}\titlepage\end{frame}
    \begin{frame}
        \frametitle{Outline}
        \ruleline{1 | Premise of Bachelor Thesis}
        \newline
        \ruleline{2 | Methodology}
        \newline
        \ruleline{3 | Pre-Implementation Considerations}
        \newline
        \ruleline{4 | Implementation}
        \newline
        \ruleline{5 | Results and Demo Applications}
        \newline
    \end{frame}
    \begin{frame}
        \frametitle{Premise}
        Current state of affairs for students:
        \newline
        \ruleline{MiRiV}
        \begin{columns}[c]
            \begin{column}{0.5\textwidth}
                \begin{itemize}
                    \item{RV32I pipeline specified using VHDL}
                    \item{Two FPGA targets (Terasic DE2-115 and DE0-Nano)}
                    \item{Preconfigured environment and bootloader}
                    \begin{itemize}
                        \item{JTAG programming}
                        \item{I/O devices (UART ...)}
                    \end{itemize}
                \end{itemize}
            \end{column}
            \begin{column}{0.7\textwidth}
                \begin{figure}[ht]
                    \begin{center}
                        \includegraphics[width=\columnwidth]{../thesis/graphics/miriv-pipeline.png}
                    \end{center}
                \end{figure}
            \end{column}
        \end{columns}
        %\centering
    \end{frame}
    \begin{frame}
        \frametitle{Premise}
        MiRiV exists for students to learn the basics of pipelining
        \newline
        \begin{itemize}
            \item{Is there potential for committed students to learn more?}
            \item{What are good potential target applications?}
            \item{What can be executed on this platform?}
            \item{Is the platform limited?}
            \item{Can this platform be extended?}
            \item{Can a different platform be adapted instead?}
        \end{itemize}
        %\vspace{1em}
        %\begin{itemize}
            %\item{If limited, can this platform be extended?}
            %\begin{itemize}
                %\item{e.g. OS execution}
            %\end{itemize}
        %\end{itemize}
    \end{frame}
    \begin{frame}
        \frametitle{Premise}
        A good target: operating systems
        \newline
        \begin{columns}[c]
            \begin{column}{0.5\textwidth}
                \begin{itemize}
                    \item{Very flexible}
                    \item{Reveals many abstraction layers}
                \end{itemize}
            \end{column}
            \begin{column}{0.5\textwidth}
                \begin{itemize}
                    \item{Essential component of modern computer systems}
                    \item{\textbf{Offers deep insights and learning opportunities}}
                \end{itemize}
            \end{column}
        \end{columns}
        \begin{figure}[ht]
            \begin{center}
                \includegraphics[width=\columnwidth]{graphics/abstraction-layers.pdf}
            \end{center}
        \end{figure}
    \end{frame}
    \begin{frame}
        \frametitle{Methodology}
        \ruleline{Step Plan}
        \newline
        \begin{itemize}
            \item{Step 1 | Categorize Hardware Extensions}
            \begin{itemize}
                \item{RISC-V specifications extensions, but also others}
            \end{itemize}
        \end{itemize}
        \vspace{1em}
        \begin{itemize}
            \item{Step 2 | Categorize Operating Systems}
            \begin{itemize}
                \item{Degree of RISC-V support according to documentation}
                \item{Use hardware extension categorization to judge effort}
            \end{itemize}
        \end{itemize}
        \vspace{1em}
        \begin{itemize}
            \item{Step 3 | Preliminary Selection}
            \begin{itemize}
                \item{Gather reduced operating system selection for subsequent analysis}
            \end{itemize}
        \end{itemize}
        \vspace{1em}
        \begin{itemize}
            \item{Step 4 | Operating System Analysis}
            \begin{itemize}
                \item{Gather precise set of requirements by compiling}
            \end{itemize}
        \end{itemize}
    \end{frame}
    \begin{frame}
        \frametitle{HW Side | Step 1}
        \ruleline{Categorize Extensions}
        \newline
        \newline
        \begin{columns}[c]
            \begin{column}{0.5\textwidth}
                \begin{itemize}
                    \item{M Ext. (multiplication/division)}
                    \item{A Ext. (atomics)}
                    \item{Zifencei Ext. (fences)}
                    \item{Zicsr Ext. (control-status reg.)}
                    \item{Counters (time/perf.)}
                    \item{F/D/Q Ext. (floating-point)}
                    \item{C Ext. (compressed instr.)}
                \end{itemize}
            \end{column}
            \begin{column}{0.5\textwidth}
                \begin{itemize}
                    \item{M-Mode (machine mode)}
                    \item{S-Mode (supervisor mode)}
                    \item{H-Mode (hypervisor mode)}
                    \item{U-Mode (user mode)}
                    \item{MMU (mem. management unit)}
                \end{itemize}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \frametitle{OS Side | Step 2}
        \ruleline{Categorize Operating Systems}
        \newline
        \begin{columns}[t]
            \begin{column}{0.33\textwidth}
                \centering
                \textbf{Linux}
                \newline
                \begin{itemize}
                    \item{embedded (buildroot)}
                    \item{embedded (Yocto Project)}
                    \item{Debian}
                    \item{Ubuntu}
                    \item{Fedora}
                    \item{OpenSUSE}
                    \item{Alpine}
                \end{itemize}
            \end{column}
            \begin{column}{0.33\textwidth}
                \centering
                \textbf{RTOSs}
                \newline
                \begin{itemize}
                    \item{FreeRTOS}
                    \item{Zephyr RTOS}
                    \item{Huawei LiteOS}
                    \item{Apache Mynewt}
                \end{itemize}
            \end{column}
            \begin{column}{0.33\textwidth}
                \centering
                \textbf{Specialized}
                \newline
                \begin{itemize}
                    \item{seL4 microkernel}
                    \item{Harvey OS}
                    \item{HelenOS}
                \end{itemize}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \frametitle{OS Side | Step 2}
        \ruleline{Categorize Operating Systems}
        \newline
        \begin{columns}[t]
            \begin{column}{0.33\textwidth}
                \centering
                \textbf{Linux}
                \newline
                \begin{itemize}
                    \item{embedded (buildroot)}
                \end{itemize}
            \end{column}
            \begin{column}{0.33\textwidth}
                \centering
                \textbf{RTOSs}
                \newline
                \begin{itemize}
                    \item{FreeRTOS}
                    \item{Zephyr RTOS}
                \end{itemize}
            \end{column}
            \begin{column}{0.33\textwidth}
                \centering
                \textbf{Specialized}
                \newline
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \frametitle{Preliminary Selection | Step 3}
        %\ruleline{Preliminary Selection}
        \begin{table}[H]
            \centering
            \begin{tabularx}{\textwidth}{r|cccc}
                & & & buildroot & buildroot \\
                & & & 2022.08 & 2022.05 \\
                & & & Linux 5.17 & Linux 5.18 \\
                standard & & Zephyr & (glibc + & (uClibc + \\
                extensions & FreeRTOS & RTOS & busybox) & busybox) \\
                \hline
                M & \catPE & \catPE & \catPE & \catSN \\
                A & \catEX & \catEX & \catSN & \catSN \\
                Zifencei & \catEX & \catEX & \catSN & \catSN \\
                Zicsr & \catSN & \catSN & \catSN & \catSN \\
                Counters & \catEX & \catEX & \catSN & \catEX \\
                F, D, Q & \catEX & \catEX & \catSN & \catPE \\
                C & \catPE & \catPE & \catPE & \catPE \\
            \end{tabularx}
            \caption{\catSN = strictly necessary, \catPE = performance enhancing, \catEX = expendable}
        \end{table}
    \end{frame}
    \begin{frame}
        \frametitle{Preliminary Selection | Step 3}
        %\ruleline{Preliminary Selection}
        \begin{table}[h]
            \centering
            \begin{tabularx}{\textwidth}{r|cccc}
                & & & buildroot & buildroot \\
                & & & 2022.08 & 2022.05 \\
                & & & Linux 5.17 & Linux 5.18 \\
                privilege & & Zephyr & (glibc + & (uClibc + \\
                modes & FreeRTOS & RTOS & busybox) & busybox) \\
                \hline
                M-mode & \catSN & \catSN & \catSN & \catSN \\
                S-mode & \catEX & \catEX & \catSN & \catCO \\
                U-mode & \catEX & \catEX & \catEX & \catEX \\
                H-mode & \catEX & \catEX & \catEX & \catEX \\
                \hline
                MMU & \catEX & \catEX & \catSN & \catCO \\
            \end{tabularx}
            \caption{\catCO = convenient, \catSN = strictly necessary, \catEX = expendable}
        \end{table}
    \end{frame}
    \begin{frame}
        \frametitle{Requirements | Step 4}
        \ruleline{Operating System Analysis}
        \begin{columns}[c]
            \begin{column}{.35\textwidth}
                \begin{enumerate}
                    \item{Compile builds}
                    \item{Count instructions}
                    \item{Get requirements}
                    \item{Judge effort}
                \end{enumerate}
            \end{column}
            \begin{column}{.8\textwidth}
                \begin{figure}[ht]
                    \begin{center}
                        \includegraphics[width=0.9\columnwidth,keepaspectratio]{graphics/os-ext-histogram.png}
                    \end{center}
                \end{figure}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \frametitle{Analysis Results}
        Analysis has resulted in a clear preference for RTOSs.
        \newline
        \newline
        What changes does this entail for MiRiV?
        \newline
        \newline
        What kind of application can the extended MiRiV implementation run using an RTOS?
    \end{frame}
    \begin{frame}
        \frametitle{Overview of Changes}
        \begin{columns}[c]
            \begin{column}{1\textwidth}
                \begin{figure}[ht]
                    \begin{center}
                        \includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{graphics/miriv-change.pdf}
                    \end{center}
                \end{figure}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \frametitle{Extended MiRiV Pipeline}
        \begin{columns}[c]
            \begin{column}{1\textwidth}
                \begin{figure}[ht]
                    \begin{center}
                        \includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{../thesis/graphics/miriv-new-pipeline.pdf}
                    \end{center}
                \end{figure}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \frametitle{FreeRTOS Demo Applications}
        Target simple two task setup
        \newline
        \newline
        Two such demo applications implemented:
        \newline
        \newline
        \begin{columns}[b]
            \begin{column}{.5\textwidth}
                \centering
                \ruleline{Counter Demo}
                \newline
                \newline
                write task-internal, incrementing counter values to UART periodically at fixed rate
            \end{column}
            \begin{column}{.5\textwidth}
                \centering
                \ruleline{Scheduling Demo}
                \newline
                \newline
                run two previously used bare-metal tests as tasks to completion
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \begin{columns}[c]
            \begin{column}{\textwidth}
                \centering
                \ruleline{Counter Demo}
                \begin{figure}[ht]
                    \begin{center}
                        \includegraphics[height=0.84\textheight,keepaspectratio]{graphics/miriv-demo-counter.png}
                    \end{center}
                \end{figure}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \begin{columns}[c]
            \begin{column}{\textwidth}
                \centering
                \ruleline{Scheduling Demo}
                \begin{figure}[ht]
                    \begin{center}
                        \includegraphics[height=0.84\textheight,keepaspectratio]{graphics/miriv-demo-scheduling-1.png}
                    \end{center}
                \end{figure}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \begin{columns}[c]
            \begin{column}{\textwidth}
                \centering
                \ruleline{Scheduling Demo}
                \begin{figure}[ht]
                    \begin{center}
                        \includegraphics[height=0.84\textheight,keepaspectratio]{graphics/miriv-demo-scheduling-2.png}
                    \end{center}
                \end{figure}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \begin{columns}[c]
            \begin{column}{1\textwidth}
                \begin{figure}[ht]
                    \begin{center}
                        \includegraphics[width=\textwidth,height=0.95\textheight,keepaspectratio]{../thesis/graphics/de2-115-execution.jpg}
                    \end{center}
                \end{figure}
            \end{column}
        \end{columns}
    \end{frame}
    \begin{frame}
        \frametitle{Future Work}
        \begin{itemize}
            \item{Currently low instruction and data memory available}
            \begin{itemize}
                \item{Implement support for on-board resources such as SDRAM}
                \item{Update address spaces}
            \end{itemize}
            \item{Only static FreeRTOS tasks implemented}
            \begin{itemize}
                \item{Code size restrictions limit FreeRTOS features}
                \item{Related to low instruction memory limitation}
            \end{itemize}
            \item{Currently just simple demo applications implemented}
            \begin{itemize}
                \item{Idea: sophisticated demo using additional I/O}
                \begin{itemize}
                    \item{networking...}
                    \item{graphics...}
                    \item{buttons, keyboard, mouse...}
                \end{itemize}
                \item{Idea: simple shell implementing the \texttt{fork/exec -> exit} flow}
            \end{itemize}
            \item{Supporting other RTOSs}
            \item{Supporting (embedded) Linux}
            \begin{itemize}
                \item{Prohibitively time-consuming, big hardware changes still necessary}
            \end{itemize}
        \end{itemize}
    \end{frame}
    \begin{frame}
        \frametitle{Takeaways}
        \begin{itemize}
            \item{The current RISC-V ecosystem: rapidly evolving, not necessarily easy to survey landscape}
            \item{Structured approach is necessary to be unbiased in the decision process}
            \item{Dependencies are not easy to see, generating requirements was difficult}
            \item{Implementation and testing take a lot of time}
        \end{itemize}
    \end{frame}
    \begin{frame}
        \frametitle{Conclusion}
        We successfully...
        \newline
        \newline
        \begin{itemize}
            \item{... identified an appropriate operating system target}
            \item{... identified required hardware extensions}
            \item{... planned an implementation}
            \item{... implemented required hardware extensions}
            \item{... tested the implementation in simulations and on hardware}
            \item{... adapted FreeRTOS to run on the extended MiRiV implementation}
            \item{... realized two successful demos}
        \end{itemize}
    \end{frame}
    \begin{frame}
        \frametitle{Conclusion}
        %\centering
        An RTOS with RISC-V support is a realistic target within the scope of a bachelor thesis and the extensions can serve as continuative material.
        \newline
    \end{frame}
    \begin{frame}[c]
        \ruleline{\textbf{Thank you!}}
        \newline
        \ruleline{Further questions?}
    \end{frame}
% etc
\end{document}
