text:
%%
%% Copyright 2019-2021 Elsevier Ltd
%%
%% This file is part of the 'CAS Bundle'.
%% --------------------------------------
%%
%% It may be distributed under the conditions of the LaTeX Project Public
%% License, either version 1.2 of this license or (at your option) any
%% later version.  The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%%
%% The list of all files belonging to the 'CAS Bundle' is
%% given in the file `manifest.txt'.
%%
%% Template article for cas-sc documentclass for
%% single column output.

\documentclass[a4paper,fleqn]{cas-sc}

% If the frontmatter runs over more than one page
% use the longmktitle option.

%\documentclass[a4paper,fleqn,longmktitle]{cas-sc}

\usepackage[numbers]{natbib}
%\usepackage[authoryear]{natbib}
%\usepackage[authoryear,longnamesfirst]{natbib}

%%%Author macros
\def\tsc#1{\csdef{#1}{\textsc{\lowercase{#1}}\xspace}}
\tsc{WGM}
\tsc{QE}
%%%

% Uncomment and use as if needed
%\newtheorem{theorem}{Theorem}
%\newtheorem{lemma}[theorem]{Lemma}
%\newdefinition{rmk}{Remark}
%\newproof{pf}{Proof}
%\newproof{pot}{Proof of Theorem \ref{thm}}

\begin{document}
\let\WriteBookmarks\relax
\def\floatpagepagefraction{1}
\def\textpagefraction{.001}

% Short title
\shorttitle{Model-assisted guided-wave based approach for debonding assessment in honeycomb sandwich structures}

% Short author
\shortauthors{P. Fiborek, P. Kudela}

% Main title of the paper
\title [mode = title]{Model-assisted guided-wave based approach for debonding assessment in honeycomb sandwich structures}

% Title footnote mark
% eg: \tnotemark[1]
%\tnotemark[1]

% Title footnote 1.
% eg: \tnotetext[1]{Title footnote text}
%\tnotetext[1]{<footnote text>}

% First author
%
% Options: Use if required
% eg: \author[1,3]{Author Name}[type=editor,
%       style=chinese,
%       auid=000,
%       bioid=1,
%       prefix=Sir,
%       orcid=0000-0000-0000-0000,
%       facebook=<facebook id>,
%       twitter=<twitter id>,
%       linkedin=<linkedin id>,
%       gplus=<gplus id>]

\author[1]{Piotr Fiborek}[type=editor,
orcid=0000-0002-5030-3312]

% Corresponding author indication
\cormark[1]

% Footnote of the first author
%\fnmark[1]

% Email id of the first author
\ead{pfiborek@imp.gda.pl}

% URL of the first author
\ead[url]{www.imp.gda.pl}

% Credit authorship
% eg: \credit{Conceptualization of this study, Methodology, Software}
%\credit{<Credit authorship details>}

% Address/affiliation
\affiliation[1]{organization={Institute of Fluid Flow Machinery, Polish Academy of Sciences},
            addressline={Fishera 14 st.},
            city={Gdańsk},
%          citysep={}, % Uncomment if no comma needed between city and postcode
            postcode={80-231},
            country={Poland}}

\author[1]{Pawel Kudela}[orcid=0000-0002-5130-6443]

% For a title note without a number/mark
%\nonumnote{}

\begin{abstract}[S U M M A R Y]
	This study aims to assess the debonding of the carbon skin from the honeycomb core in the sandwich panel based on guided wave propagation.
	The effect of damage on wave propagation in the slab was determined using numerical simulations.
	The two most common honeycomb core models found in the literature are a homogenized, orthogonal continuous medium and a real geometry core modelled by finite elements, usually using commercial software.
	In a simplified model, the results are in good agreement only for low frequencies.
	In this paper, the panel has been modelled by the time-domain spectral element method taking into account the real geometry of the honeycomb core.

	The presented model was compared with the homogenized model of the
	The result of the parametric study is a function of damage influence on the amplitude of propagating waves.
\end{abstract}
\begin{keywords}
Honeycomb, Debonding, Computational modelling, Spectral element methods,
\end{keywords}

\maketitle

\section{Introduction}
\label{sec:intro}
Honeycomb Sandwich Composite~(HSC) is a multi-layered structure composed of the mid-core with the geometry of honeycomb sandwiched between thin skins.
They are widely used in the aerospace, marine and automotive industries due to their high strength-to-weight ratio, high energy absorption capability and effective acoustic insulation.
However, these complex structures are exposed to various types of damage that are not found in metal alloy materials, e.g. hidden disbonds between the skin and the core, delamination of the skin plates, or the core impact damage.
The damage can occur during a manufacturing process, storage or in-service life; thus, advanced methods for online damage detection are required.

The Guided Wave (GW) based method is one of the structural health monitoring (SHM) techniques with very high potential for damage detection and localization in HSC. \cite{mustapha2011assessment, sikdar2016guided, sikdar2016ultrasonic,radzienski2016assessment, yu2019core}.
Among numerous techniques developed for damage detection and localization, the most popular are pitch-catch \cite{sikdar2017structural}, pulse-echo \cite{}, phase array \cite{lu2006crack, ostachowicz2008elastic}, and time-reversal mirror \cite{fink1992time, eremin2016analytically}.

mustapha2006debonding
mustapha2011assessment,
mustapha2014leaky,
baid2008detection
baid2015dispersion,
sikdar2016guided,
sikdar2016ultrasonic,
radzienski2016assessment,
sikdar2017structural,
yu2019core,
wang2020improved

qi2008ultrasonic,
hosseini2013numerical

The most common numerical modeling of the phenomenon of GW in HSC found in the literature is a calculation of the effective material properties of the honeycomb structure by the homogenization process~\cite{shi1995derivation, qi2008ultrasonic, mustapha2014leaky, baid2015dispersion, sikdar2016guided}.
The homogenized model significantly simplifies the grid formulation and time consuming but does not accurately represent the wave propagation phenomenon in such material.
A model with a real geometry of the hexagonal cell was presented by Ruzzenne et al. \cite{ruzzene2003wave}.
The finite element model and the theory of periodic structures was used to evaluate the dynamic behaviour of the honeycomb and cellular structures.
Recently, the simulations of the wave propagation in the HSC have been conducted with the commercially available finite element code~\cite{song2009guided, hosseini2013numerical, tian2015wavenumber, zhao2018wave}.
However, using the finite element method (FEM) to model GW is inefficient as it requires a significant amount of memory and is time-consuming.

The computational efficiency of the FEM in case of GW modelling in the HSC can be improved by using the time-domain spectral element method (SEM).
The SEM was originally used for the numerical solution of the fluid--flow in a channel by Patera \cite{patera1984spectral} but has also been successfully developed for elastic wave propagation~\cite{ostachowicz2011guided}.
Kudela proposed a model of the GW in HSC by the parallel implementation of the SEM \cite{kudela2016parallel}.
However, this model had a large number (1.5 million) of degrees-of-freedom (DOF), because cells of the core and skin plate were modelled by the three-dimensional (3D) spectral elements.
Although, the simulation was limited to only one skin plate and a small dimension of the HSC (\(179 \times 159 \) mm).

Above mentioned drawbacks were motivation to propose a new model of the HSC. In the present paper, the skin plates, adhesive layers and each wall of the hexagonal core were modelled by two-dimensional (2D) spectral elements.
However, 2D elements have nodes only in a mid-plane, therefore, there is no direct connection between the two adjacent structures.
This connection was implemented by interface elements based on Lagrange multipliers \cite{ashwin2014formulation, fiborek20192d}.
Additionally, the signal was generated and recorded with piezoelectric transducers (PZT), while Kudela excited the waves with an external force applied at the point of the panel \cite{kudela2016parallel}.
A non-matching interface between the transducers and the skin was used to avoid too complex mesh, likewise to the interfaces developed for the FEM \cite{flemisch2000elasto, flemisch2012non}. To the best of authors’
knowledge, it has not been implemented for the SEM.

The parametric study conducted in the paper leads to the determination of a model-assisted damage identification function (MADIF), which determines the influence of the size of the composite defect on wave propagation.
In this case, the defect is assumed to be a disbond between the skin and the core.

\section{The time-domain spectral element method formulation}
\label{sec:time_SEM}
\subsection{The spectral element method}
\label{sec:sem}
The general concept of the SEM is based on the idea of the FEM.
The similarity of both methods lies in the fact that the modelled domain is divided into non-overlapping finite elements, and external forces and arbitrary boundary conditions are imposed in the particular nodes.
The main difference between those methods is a choice of the shape function \( N=N(\xi )\), which is interpolated by Lagrange polynomial that passes through the element nodes. The nodes are localized on the endpoint of an interval, \(\xi\in[-1,1]\) and the roots of the first derivative of Legendre polynomial of degree \(p-1\):

\begin{eqnarray}
	(1-\xi^2)P'_{p-1}(\xi)=0
	\label{eq:nodes}
\end{eqnarray}

The approximation of an integral over the elements is achieved according to Gauss-Lobatto-Legendre (GLL) rule at points coinciding with the element nodes,
and the weights \(w=w(\xi)\) calculated as:
\begin{eqnarray}
	{w(\xi)} = \frac{2}{p(p-1)(P_{p-1}(\xi))^2}
	\label{eq:weights}
\end{eqnarray}
This approach guarantees a diagonal mass matrix.
The shape functions and the weights for 2D or 3D elements are obtained by the Kronecker product of vectors of individual axes, denoted by \(\otimes\) as follows:
\begin{eqnarray}
	N(\xi,\eta) = N(\xi)\otimes N(\eta), & N(\xi,\eta,\zeta) = N(\xi)\otimes N(\eta)\otimes N(\zeta) \nonumber\\
	w(\xi,\eta) = w(\xi)\otimes w(\eta), & w(\xi,\eta,\zeta) = w(\xi)\otimes w(\eta)\otimes w(\zeta)
	\label{eq:3Dshape_weights}
\end{eqnarray}
\subsection{2D spectral element}
\label{sec:2D_SEM}

According to the first-order shear deformation theory~\cite{reissner1945effect, mindlin1951influence} the vector of displacements is expressed as:
\begin{eqnarray}
	\left \{ \begin{array}{c}
		\textbf{u}^e(\xi,\eta,\zeta) \\
		\textbf{v}^e(\xi,\eta,\zeta) \\
		\textbf{w}^e(\xi,\eta,\zeta)
	\end{array} \right\} =
	\left \{ \begin{array}{c}
		\textbf{u}_0^e(\xi,\eta) + z\boldsymbol{\varphi}_x^e(\xi,\eta)\\
		\textbf{v}_0^e(\xi,\eta) + z\boldsymbol{\varphi}_y^e(\xi,\eta)\\
		\textbf{w}_0^e(\xi,\eta) \\
	\end{array} \right\}
\end{eqnarray}
where \(\textbf{u}_0^e\), \(\textbf{v}_0^e\) and \(\textbf{w}_0^e\) are nodal displacements, \(\boldsymbol{\varphi}_x^e\), \(\boldsymbol{\varphi}_y^e\) are the rotations of the normal to the mid-plane with respect to axes \textit{x} and \textit{y}, respectively.
\begin{eqnarray}
	\left \{\begin{array}{c}
		\textbf{u}_0^e(\xi,\eta) \\
		\textbf{v}_0^e(\xi,\eta) \\
		\textbf{w}_0^e(\xi,\eta) \\
		\boldsymbol{\varphi}_x^e(\xi,\eta) \\
		\boldsymbol{\varphi}_y^e(\xi,\eta)
	\end{array} \right\}
	 = \textbf{N}^e(\xi,\eta)\widehat{\textbf{d}}^e
	 = \sum_{n=1}^q\sum_{m=1}^p\textbf{N}_m^e(\xi)\textbf{N}_n^e(\eta)
	\left [ \begin{array}{c}
		\widehat{\textbf{u}}_0^e \\
		\widehat{\textbf{v}}_0^e \\
		\widehat{\textbf{w}}_0^e \\
		\widehat{\boldsymbol{\varphi}}_x^e \\
		\widehat{\boldsymbol{\varphi}}_y^e
	\end{array} \right]
\end{eqnarray}
The nodal bending strain-displacement relations are given in the form:
\begin{eqnarray}
	\boldsymbol{\epsilon}_b^e =
	\textbf{B}_b^e\widehat{\textbf{d}}^e =
	\left [
	\begin{array}{ccccc}
		\frac{\partial N^e}{\partial x} & 0 & 0 & 0 & 0\\
		0 & \frac{\partial N^e}{\partial y} & 0 & 0 & 0\\
		\frac{\partial N^e}{\partial y} & \frac{\partial N^e}{\partial x} & 0 & 0 & 0\\
		0 & 0 & 0 & -\frac{\partial N^e}{\partial x} & 0\\
		0 & 0 & 0 & 0 & -\frac{\partial N^e}{\partial y}\\
		0 & 0 & 0 & -\frac{\partial N^e}{\partial y} & -\frac{\partial N^e}{\partial x}
	\end{array} \right]
	\left \{ \begin{array}{c}
		\textbf{u}_0^e \\
		\textbf{v}_0^e \\
		\textbf{w}_0^e \\
		\boldsymbol{\varphi}_x^e \\
		\boldsymbol{\varphi}_y^e
	\end{array} \right\}
\end{eqnarray}
The nodal shear strain-displacement relations are given in the form:
\begin{eqnarray}
	\boldsymbol{\epsilon}_s^e =
	\textbf{B}_s^e\widehat{\textbf{d}}^e =
	\left [
	\begin{array}{ccccc}
		0 & 0 & \frac{\partial N^e}{\partial y} & -1 & 0\\
		0 & 0 & \frac{\partial N^e}{\partial y} & 0 & -1
	\end{array} \right]
	\left \{ \begin{array}{c}
		\textbf{u}_0^e \\
		\textbf{v}_0^e \\
		\textbf{w}_0^e \\
		\boldsymbol{\varphi}_x^e \\
		\boldsymbol{\varphi}_y^e
	\end{array} \right\}
\end{eqnarray}
\subsection{3D model of the PZT transducer}
\label{sec:3D_SEM}
The displacements vector of the PZT transducer is composed of three translational displacements, and it is defined as:
\begin{eqnarray}
	\left \{ \begin{array}{c}
		\textbf{u}^e(\xi,\eta,\zeta) \\
		\textbf{v}^e(\xi,\eta,\zeta) \\
		\textbf{w}^e(\xi,\eta,\zeta)
	\end{array} \right\}
	= \textbf{N}^e(\xi,\eta, \zeta)\widehat{\textbf{d}}^e\nonumber\\
	= \sum_{l=1}^r\sum_{n=1}^q\sum_{m=1}^p\textbf{N}_m^e(\xi)\textbf{N}_n^e(\eta)\textbf{N}_l^e(\zeta)
	\left \{ \begin{array}{c}
		\widehat{\textbf{u}}^e(\xi_m,\eta_n,\zeta_l) \\
		\widehat{\textbf{v}}^e(\xi_m,\eta_n,\zeta_l) \\
		\widehat{\textbf{w}}^e(\xi_m,\eta_n,\zeta_l)
	\end{array} \right\}
	\label{eq:3D_displ}
\end{eqnarray}
where \(\widehat{\textbf{u}}^e\), \(\widehat{\textbf{v}}^e\) and
\(\widehat{\textbf{w}}^e\) are displacements of the element nodes in \(\xi,\eta\) and \(\zeta\) direction.

The nodal strain-displacement relations are given as \cite{kudela20093d}:
\begin{eqnarray}
	\boldsymbol{\epsilon}^e=\textbf{B}_{d}^e\widehat{\textbf{d}}^e=
	\left [
	\begin{array}{ccc}
		\frac{\partial N^e}{\partial x} & 0 & 0\\
		0 & \frac{\partial N^e}{\partial y} & 0\\
		0 & 0 & \frac{\partial N^e}{\partial z}\\
		0 & \frac{\partial N^e}{\partial z} & \frac{\partial N^e}{\partial y}\\
		\frac{\partial N^e}{\partial z} & 0 & \frac{\partial N^e}{\partial x}\\
		\frac{\partial N^e}{\partial y} & \frac{\partial N^e}{\partial x} & 0
	\end{array} \right]
	\left \{ \begin{array}{c}
		\textbf{u}^e \\
		\textbf{v}^e \\
		\textbf{w}^e
	\end{array} \right\}
\end{eqnarray}

The electromechanical coupling is governed by the linear constitutive equation of piezoelectric material according to~\cite{giurgiutiumicromechatronics, rekatsinas2017cubic}, and it is defined as:
\begin{eqnarray}
	\left [
	\begin {array}{c}
	\boldsymbol{\sigma}\\
	\textbf{D}
\end{array}\right ]=
\left [
\begin{array}{cc}
	\textbf{c}^E & -\textbf{e}^T \\
	\textbf{e} & \epsilon^S
\end{array} \right ]
\left[
\begin{array}{c}
	\textbf{S}\\
	\textbf{E}
\end{array} \right ]
\end{eqnarray}
where \(\textbf{c}^E\) is the stiffness coefficients measured at zero electric field, \textbf{e} is the piezoelectric coupling tensor and \(\boldsymbol{\epsilon}^S\) electric permittivity, \textbf{E} and \textbf{D} are the electric field and electric displacement measured at zero strain.
The superscript T denotes transpose matrix.
The eElectric field is defined as:
\begin{eqnarray}
\textbf{E}^e=-\textbf{B}_\phi^e \widehat{\phi}^e = \left[ \begin{array}{c}
	\frac{\partial N^e}{\partial \xi}\\
	\frac{\partial N^e}{\partial \eta}\\
	\frac{\partial N^e}{\partial \zeta}
\end{array} \right] \widehat{\phi}^e
\end{eqnarray}
\subsection{Elementary governing equations of motion}
\label{sec:motion}
The classical equations of motion \(\textbf{M}\ddot{\textbf{d}} + \textbf{C}\dot{\textbf{d}} + \textbf{K}\textbf{d} = \textbf{F}\) known from FEM are complemented by piezoelectric and interface coupling. Thus, the governing equations are defined as:
\begin{eqnarray}
	\textbf{M}_{dd} \widehat{\ddot{\textbf{d}}} + \textbf{C}_{dd} \widehat{\dot{\textbf{d}}} + \textbf{K}_{dd} \widehat{\textbf{d}} + \textbf{K}_{d\phi} \widehat{\boldsymbol{\phi}} = \textbf{F} - \textbf{G}^T \boldsymbol{\lambda},
	\label{eq:motion}
\end{eqnarray}
\begin{eqnarray}
	\textbf{K}_{\phi d}\widehat{\textbf{d}} + \textbf{K}_{\phi \phi} \widehat{\boldsymbol{\phi}} = \textbf{Q}
	\label{eq:piezocoupling}
\end{eqnarray}

where \(\textbf{M}_{dd}\), \(\textbf{C}_{dd}\), \(\textbf{K}_{dd}\) are structural mass, damping and stiffness matrices, respectively; \(\textbf{K}_{\phi d}={\textbf{K}_{d\phi}}^T\) are piezoelectric coupling matrices; \(\textbf{K}_{\phi \phi}\) is the dielectric permittivity matrix, \(\widehat{\textbf{d}}\) is the vector of unknown nodal displacements, and \(\widehat{\boldsymbol{\phi}}\) is the electric potential vector; \(\textbf{F}\) the nodal external force vector, \(\textbf{Q}\) is the nodal charge vector, \(\boldsymbol{\lambda}\) is the Lagrange multipliers vector, and \(\textbf{G}\) is the interface coupling matrix; \((\dot{\ })=\frac{\partial}{\partial t}\).
The formulae of the matrices are provided in App.~\ref{app:matrices}.
The coupling is realised by imposing the traction forces, represented by a vector of Lagrange multipliers.
\subsection{Transformation of the core elements}
\label{sec:transformation}
All core elements are rotated relative to both skins, so it is necessary to transform degrees of freedom from the local core's coordinate system to the global system.
For this purpose, an additional sixth global dof has been incorporated, i.e. $\boldsymbol{\varphi}_z^e$ rotation with respect to the z-axis .
Firstly, a part of the mass matrix accounted for rotary inertia (see App. \ref{app:matrices}) is globalised as follows:
\begin{eqnarray}
	\textbf{M}_R^g=\textbf{a}\,\textbf{M}_R^l\,\textbf{a}^{-1}
	\label{eq:inertia}
\end{eqnarray}
where \(\textbf{a}\) is general rotation matrix obtained from the multiplication of basic rotation matrices, and for the regular hexagonal core a is equal to:
\begin{eqnarray}
	\textbf{a}=\left [
	\begin{array}{ccc}
		m & -n & 0\\
		0 & 0 & -1\\
		n & m & 0\\
	\end{array}
	\right ]
	\label{eq:rotation}
\end{eqnarray}
where \(m=\cos(\alpha),\:n=\sin(\alpha)\), for \(\alpha\in{[0^\circ,\,60^\circ,\,120^\circ,180^\circ,\,240^\circ,\,300^\circ]}\) depending on which wall of the cell it is applied to.

The stiffness--strain relationship in local and global coordinate systems is given by:
\begin{eqnarray}
	\begin{array}{ccc}
		\left [
		\begin{array}{c}
			\sigma^l_{11}\\
			\sigma^l_{22}\\
			\sigma^l_{33}\\
			\sigma^l_{23}\\
			\sigma^l_{13}\\
			\sigma^l_{12}\\
		\end{array}
		\right ]=
		\textbf{c}\,\left [
		\begin{array}{c}
			\epsilon^l_{11}\\
			\epsilon^l_{22}\\
			\epsilon^l_{33}\\
			\gamma^l_{23}\\
			\gamma^l_{13}\\
			\gamma^l_{12}\\
		\end{array}
		\right ], & and &
		\left [
		\begin{array}{c}
			\sigma^g_{11}\\
			\sigma^g_{22}\\
			\sigma^g_{33}\\
			\sigma^g_{23}\\
			\sigma^g_{13}\\
			\sigma^g_{12}\\
		\end{array}
		\right ]=
		\bar{\textbf{c}}\,\left [
		\begin{array}{c}
			\epsilon^g_{11}\\
			\epsilon^g_{22}\\
			\epsilon^g_{33}\\
			\gamma^g_{23}\\
			\gamma^g_{13}\\
			\gamma^g_{12}\\
		\end{array}
		\right ]
	\end{array}
	\label{eq:stress_global}
\end{eqnarray}
The global form of the stiffness matrix \(K\), involves the determination of stiffness tensor \(\bar{c}\) from Eq.~\ref{eq:stress_global}.
The transformation of the stress tensor is expressed as:
\begin{eqnarray}
	\left [
	\begin{array}{ccc}
		\sigma^g_{11} & \sigma^g_{12} & \sigma^g_{13}\\
		\sigma^g_{21} & \sigma^g_{22} & \sigma^g_{23}\\
		\sigma^g_{31} & \sigma^g_{32} & \sigma^g_{33}\\
	\end{array}
	\right ]
	=
	\textbf{a}\,
	\left [
	\begin{array}{ccc}
		\sigma^l_{11} & \sigma^l_{12} & \sigma^l_{13}\\
		\sigma^l_{21} & \sigma^l_{22} & \sigma^l_{23}\\
		\sigma^l_{31} & \sigma^l_{32} & \sigma^l_{33}\\
	\end{array}
	\right ]
	\,\textbf{a}^T
	\label{eq:sigma_tensor}
\end{eqnarray}
After the multiplication of matrices and using the symmetry of the stress tensor Eq.~\ref{eq:sigma_tensor} can be rewritten in a simplified form:

\begin{eqnarray}
	\left [
	\begin{array}{c}
		\sigma^g_{11}\\
		\sigma^g_{22}\\
		\sigma^g_{33}\\
		\sigma^g_{23}\\
		\sigma^g_{13}\\
		\sigma^g_{12}\\
	\end{array}
	\right ]=
	\textbf{T}\,\left [
	\begin{array}{c}
		\sigma^l_{11}\\
		\sigma^l_{22}\\
		\sigma^l_{33}\\
		\sigma^l_{23}\\
		\sigma^l_{13}\\
		\sigma^l_{12}\\
	\end{array}
	\right ]
	\label{eq:stress}
\end{eqnarray}

Analogously, a strain relationship also is given in the form:
\begin{eqnarray}
	\begin{array}{ccc}
		\left [
		\begin{array}{c}
			\epsilon^g_{11}\\
			\epsilon^g_{22}\\
			\epsilon^g_{33}\\
			\epsilon^g_{23}\\
			\epsilon^g_{13}\\
			\epsilon^g_{12}\\
		\end{array}
		\right ]=
		\textbf{T}\,\left [
		\begin{array}{c}
			\epsilon^l_{11}\\
			\epsilon^l_{22}\\
			\epsilon^l_{33}\\
			\epsilon^l_{23}\\
			\epsilon^l_{13}\\
			\epsilon^l_{12}\\
		\end{array}
		\right ], & and & \left [
		\begin{array}{c}
			\epsilon_{11}\\
			\epsilon_{22}\\
			\epsilon_{33}\\
			\gamma_{23}\\
			\gamma_{13}\\
			\gamma_{12}\\
		\end{array}
		\right ]=
		\textbf{R}\,\left [
		\begin{array}{c}
			\epsilon_{11}\\
			\epsilon_{22}\\
			\epsilon_{33}\\
			\epsilon_{23}\\
			\epsilon_{13}\\
			\epsilon_{12}\\
		\end{array}
		\right ]
	\end{array}
	\label{eq:strain}
\end{eqnarray}
where \(\textbf{R}\) is the Reuter's matrix, defined as:
\begin{eqnarray}
	\textbf{R} = \left [
	\begin{array}{cccccc}
		1 & 0 & 0 & 0 & 0 & 0\\
		0 & 1 & 0 & 0 & 0 & 0\\
		0 & 0  & 1 & 0 & 0 & 0\\
		0 & 0 & 0 & 2 & 0 & 0\\
		0 & 0 & 0 & 0 & 2 & 0\\
		0 & 0 & 0 & 0 & 0 & 2
	\end{array}
	\right ]
	\label{eq:reuters}
\end{eqnarray}
Using the Eqs.~\ref{eq:rotation} through \ref{eq:reuters}, the relationship of stress--strain in the global frame can be expressed as:
\begin{eqnarray}
	\left [
	\begin{array}{c}
		\sigma^g_{11}\\
		\sigma^g_{22}\\
		\sigma^g_{33}\\
		\sigma^g_{23}\\
		\sigma^g_{13}\\
		\sigma^g_{12}\\
	\end{array}
	\right ]=
	\textbf{T}\,\textbf{c}\,\textbf{R}\,\textbf{T}^{-1}\,\textbf{R}^{-1}\,
	\left [
	\begin{array}{c}
		\epsilon^g_{11}\\
		\epsilon^g_{22}\\
		\epsilon^g_{33}\\
		\gamma^g_{23}\\
		\gamma^g_{13}\\
		\gamma^g_{12}\\
	\end{array}
	\right ]
	\label{eq:stress-strain}
\end{eqnarray}
Therefore, transformed stiffness tensor for the core's elements is equal:
\begin{eqnarray}
	\bar{\textbf{c}}=\textbf{T}\,\textbf{c}\,\textbf{R}\,\textbf{T}^{-1}\,\textbf{R}^{-1}
	\label{eq:c_global}
\end{eqnarray}

%% Loading bibliography style file
%\bibliographystyle{model1-num-names}
\bibliographystyle{model1-num-names}

% Loading bibliography database
\bibliography{model_hc}

\end{document}

ext: tex

max_stars_repo_name: pfiborek/model-hc

max_issues_repo_name: pfiborek/model-hc

max_forks_repo_name: pfiborek/model-hc


text:
\documentclass[epsfig,10pt,fullpage]{article}

\newcommand{\LabNum}{10}
\newcommand{\CommonDocsPath}{../../../common/docs}
\input{\CommonDocsPath/preamble.tex}

\setcounter{table}{2}
\setcounter{figure}{11}

\begin{document}

\centerline{\huge Digital Logic}
~\\
\centerline{\huge Laboratory Exercise \LabNum}
~\\
\centerline{\large An Enhanced Processor}
~\\

In Laboratory Exercise 9 we described a simple processor. In
Part I of that exercise the processor itself was designed, and in Part II the processor was
connected to an external counter and a memory unit. This exercise describes subsequent
parts of the processor design. The numbering of figures and tables in this exercise
are continued from those in Parts I and II of the preceding lab exercise.

~\\
\noindent
In this exercise we will extend the capability of the processor so that the external counter
is no longer needed, and so that the processor can perform read and
write operations using memory or other devices.
A schematic of the enhanced processor is given in Figure~\ref{fig:fig12}. In the figure
registers $r0$ to $r6$ are the same as in Figure~1 of Lab~1, but register $r7$ has
been changed to a counter. This counter is used to provide the addresses in the memory from
which the processor's instructions are read; in the preceding
lab exercise, a counter external to the processor was used for this purpose.
We will refer to $r7$ as the processor's {\it program counter} ({\it pc}), because this
terminology is common for real processors available in the industry. When the processor is
reset, {\it pc} is set to address 0. At the start of each instruction (in time step $T_0$) the
value of {\it pc} is used as an address to read an instruction from the memory. The instruction
returned from the memory is stored into the {\it IR} register and the {\it pc} is automatically
incremented to point to the next instruction.

~\\
\noindent
The processor's control unit increments {\it pc} by using the {\it incr\_pc} signal, which is
just an enable on this counter. It is also possible to load an arbitrary address into
{\it pc} by having the processor execute an instruction in which the destination register is
specified as {\it pc}. In this case the control unit uses {\it r7}$_{in}$ to perform
a {\it load} of the counter. Thus, the processor can execute instructions at any address
in the memory, as opposed to only being able to execute instructions that are stored at
successive addresses. The current content of {\it pc}, which always has the address of
the {\it next} instruction to be executed, can be copied into another register if needed
by using a {\it mv} instruction.

~\\
\noindent
The enhanced processor will have four new instructions, which are listed
in Table~\ref{tab:new_instr}.  The {\it ld} (load) instruction {\it reads} data into
register {\it rX} from the external memory address specified in register {\it rY}. Thus,
the syntax [{\it rY}] means that the content of register {\it rY} is used as an
{\it external address}. The {\it st} (store) instruction {\it writes} the data contained
in register {\it rX} into the memory address found in {\it rY}. The {\it and} instruction
is similar to the {\it add} and {\it sub} instructions that were introduced in Lab 1.
This instruction extends the adder/subtracter unit in the processor into an
{\it arithmetic logic unit}. Besides performing addition and subtraction, it
has the ability to generate a bit-wise logical AND (\&) of the destination register
{\it rX} with the second operand {\it Op2}. As discussed
in Lab 1, the operand {\it Op2} can be either another register {\it rY}, or immediate
data {\it \#D}.

~\\
\noindent
The {\it b\{cond\}} instruction is used to cause a processor {\it branch}, which means to
change the program counter ({\it pc}) to the address of a specific instruction. The {\it cond}
part of the branch instruction is optional and represents a {\it condition}. The instruction
loads the constant \#{\it Label} into {\it pc} only if the specified condition evaluates to true.
An example of a condition is {\it eq}, which stands for {\it equal} (to zero).
The instruction \texttt{beq \#Label} will load the constant {\it Label} into {\it pc} if the
last result produced by the arithmetic logic unit, which is stored in register $G$, was 0.
The {\it b\{cond\}} instruction is discussed in more detail in Part V of this exercise.

\begin{table}[H]
\begin{center}
\begin{tabular}{l|c}
\rule[-0.075in]{0in}{0.25in}Operation & Function performed \\ \hline
\rule[-0.075in]{0in}{0.25in}{\it ld}~~~{\it rX}, [{\it rY}] & {\it rX} $\leftarrow$ [{\it rY}] \\
\rule[-0.075in]{0in}{0.25in}{\it st}~~~{\it rX}, [{\it rY}] & [{\it rY}] $\leftarrow$ {\it rX} \\
\rule[-0.075in]{0in}{0.25in}{\it and}~~~{\it rX}, {\it Op2} & {\it rX} $\leftarrow$ {\it rX} \& {\it Op2} \\
\rule[-0.075in]{0in}{0.25in}{\it b\{cond\}}~~~\#{\it Label} & if ({\it cond}), {\it pc} $\leftarrow$ \#{\it Label} \\
\end{tabular}
\caption{New instructions in the enhanced processor.}
\label{tab:new_instr}
\end{center}
\end{table}

\begin{figure}[H]
\begin{center}
\includegraphics[scale = 0.8]{figures/figure12.pdf}
\end{center}
\caption{An enhanced version of the processor.}
\label{fig:fig12}
\end{figure}

~\\
\noindent
Recall from Lab 1 that instructions are encoded using a 16-bit format. For instructions
that specify {\it Op2} as a register the encoding is \texttt{III0XXX000000YYY}, and if {\it Op2}
is an immediate constant the format is \texttt{III1XXXDDDDDDDDD}. You should use these
same encodings for this exercise. Assume that \texttt{III} $= 100$ for the {\it ld} instruction,
$101$ for {\it st}, $110$ for {\it and}, and $111$ for {\it b\{cond\}}.

~\\
Figure~\ref{fig:fig12} shows two registers in the processor that are used for data transfers. The
{\it ADDR} register is used to send addresses to an external device, such as a memory module,
and the {\it DOUT} register is used by the processor to provide data that is to be stored outside
of the processor. One use of the {\it ADDR} register is for reading, or {\it fetching},
instructions from memory; when the processor wants to fetch an instruction, the content
of {\it pc} is transferred across the bus and loaded into {\it ADDR}. This address is
provided to the memory.

~\\
In addition to fetching instructions, the processor can read data
at any address by using the {\it ADDR} register. Both data and instructions are read into
the processor on the {\it DIN} input port.  The processor can write data for storage at
an external address by placing this address into the {\it ADDR} register, placing the data
to be stored into its {\it DOUT} register, and asserting the output of the {\it W}
({\it Write}) flip-flop to 1.

\section*{Connecting the Processor to External Devices}

Figure~\ref{fig:fig13} illustrates how the enhanced processor can be connected to memory and
other devices. The memory unit in the figure is 16-bits wide and 256-words deep.  A diagram
of this memory is given in Figure~\ref{fig:fig14}.
It supports both read and write operations and therefore has both address and
data inputs, as well as a write-enable input. As depicted in Figure~\ref{fig:fig14},
the memory has a clock input that is used to store the address, data, and write enable
inputs into registers.  This type of memory unit is called a {\it synchronous}
static random access memory (SSRAM).

~\\
Figure~\ref{fig:fig13} also includes a 9-bit output port (register) that can be used to store
data from the processor. In the figure this output port is connected to a set of LEDs, like
the ones available on the DE1-SoC board. To allow the processor to select either the memory
unit or output port when performing a write operation, the circuit includes {\it address decoding},
which is done using NOR gates and AND gates.
If the processor's upper address lines $A_{15} A_{14} A_{13} A_{12} = 0000$, then the memory unit
can be written. Figure~\ref{fig:fig13} shows $n$ {\it lower} address lines connected from the
processor to the memory; since the memory has 256 words, then $n = 8$ and the memory's
{\it address} port is driven by the processor address lines $A_7 \ldots A_0$. For
addresses in which $A_{15} A_{14} A_{13} A_{12} = 0001$, the data written by the processor
is loaded into the output port connected to {\it LEDs} in Figure~\ref{fig:fig13}.
~\\
\begin{figure}[H]
\begin{center}
\includegraphics{figures/figure13.pdf}
\end{center}
\vspace{-0.5cm}
\caption{Connecting the enhanced processor to a memory unit and output register.}
\label{fig:fig13}
\end{figure}

\begin{figure}[b]
\begin{center}
\includegraphics{figures/figure14.pdf}
\end{center}
\vspace{-0.5cm}
\caption{The synchronous SRAM unit.}
\label{fig:fig14}
\end{figure}

\section*{Part III}

Figure~\ref{fig:top} gives Verilog code for a top-level file that you can use for this
part of the exercise. The input and output ports for this module are chosen so that it can
be implemented on a DE1-SoC board. The Verilog code corresponds to the circuit
in Figure~\ref{fig:fig13},
plus an additional input port that is connected to switches {\it SW}$_8$ $\ldots$ {\it SW}$_0$.
This input port can be read by the processor at addresses in which $A_{15} \ldots A_{12} = 0011$.
(Switch {\it SW}$_9$ is not a part of the input port, because it is dedicated for use as the
processor's {\it Run} input.) To support reading from both the SW input port and the memory
unit, the top-level circuit includes a multiplexer that feeds the processor's {\it DIN}
input. This multiplexer is described by using an \texttt{if-else} statement inside
the \texttt{always} block in Figure~\ref{fig:top}.

~\\
\noindent
The code in Figure~\ref{fig:top} is provided with this exercise, along with a few
other source-code files: {\it flipflop.v}, {\it inst\_mem.v}, {\it inst\_mem.mif}, and
(part of) {\it proc.v}. The {\it inst\_mem.v} source-code file was created by using the Quartus IP
Catalog to instantiate a \texttt{RAM:1-PORT} memory module. It has a 16-bit wide read/write
data port and is 256-words deep, corresponding to Figure~\ref{fig:fig14}.

~\\
\noindent
The Verilog code in the {\it proc.v} file implements register {\it r7} as a program counter,
as discussed above, and includes a number of changes that are needed to support the
new {\it ld}, {\it st}, {\it and}, and {\it b\{cond\}} instructions. In this part you are to
augment this Verilog code to complete the implementation of the {\it ld} and
{\it st} instructions, as well as the {\it and} instruction. You do not
need to work on the {\it b\{cond\}} instruction for this part.

\lstset{language=Verilog,numbers=none,escapechar=|}
\begin{figure}[h]
\begin{center}
\begin{minipage}[h]{15 cm}
\begin{lstlisting}[name=proc]
|\label{line:module}|module part3 (KEY, SW, CLOCK_50, LEDR);
	input [0:0] KEY;
	input [9:0] SW;
	input CLOCK_50;
	output [9:0] LEDR;

	wire [15:0] DOUT, ADDR;
	wire Done, W;
	reg [15:0] DIN;
	wire inst_mem_cs, SW_cs, LED_reg_cs;
	wire [15:0] inst_mem_q;
	wire [8:0] LED_reg, SW_reg;      // LED[9] and SW[9] are used for Run

   proc U3 (DIN, KEY[0], CLOCK_50, SW[9], DOUT, ADDR, W, Done);

	assign inst_mem_cs = (ADDR[15:12] == 4'h0);
	assign LED_reg_cs = (ADDR[15:12] == 4'h1);
	assign SW_cs = (ADDR[15:12] == 4'h3);
	inst_mem U4 (ADDR[7:0], CLOCK_50, DOUT, inst_mem_cs & W, inst_mem_q);

	always @ (*)                     // input multiplexer
	   if (inst_mem_cs == 1'b1)
		   DIN = inst_mem_q;
	   else if (SW_cs == 1'b1)
		   DIN = {7'b0000000, SW_reg};
	   else
		   DIN = 16'bxxxxxxxxxxxxxxxx;

	regn #(.n(9)) U5 (DOUT[8:0], LED_reg_cs & W, CLOCK_50, LED_reg);
	assign LEDR[8:0] = LED_reg;
   assign LEDR[9] = SW[9];

	regn #(.n(9)) U7 (SW[8:0], 1'b1, CLOCK_50, SW_reg); // SW[9] is used for Run
endmodule
\end{lstlisting}
\end{minipage}
\caption{Verilog code for the top-level file.}
\label{fig:top}
\end{center}
\end{figure}

\newpage
\noindent
Perform the following:
\begin{enumerate}
\item Extend the code in {\it proc.v} so that the enhanced processor fully implements the
{\it ld}, {\it st}, and {\it and} instructions. Test your Verilog code by using the ModelSim
simulator. Sample setup files for ModelSim, including a testbench, are provided along with
the other files for this exercise.  The sample testbench first resets the processor system
and then asserts the {\it Run} switch, {\it SW}$_9$, to 1. A sample program to test your
processor is also provided, in a file called {\it inst\_mem.mif}. This file represents the
assembly-language program shown in Figure~\ref{fig:assembly}, which tests
the {\it ld} and {\it st} instructions by reading the values of the SW switches and writing
these values to the LEDs, in an endless loop. At the beginning of a simulation, ModelSim loads
the contents of the file {\it inst\_mem.mif} into the {\it inst\_mem} memory module, so
that the program can be executed by the processor.  Examine the signals inside
your processor, as well as the external LEDR values, as the program executes within the
ModelSim simulation.

An {\it assembler} software tool, called {\it sbasm.py}, can be used with your processor.
The Assembler is written in Python and is available at
\texttt{https://github.com/profbrown/sbasm.git}. To use this
Assembler you have to first install Python (version 3) on your computer. The Assembler includes
a README file that explains how to install and use it. The {\it sbasm.py} Assembler can
generate machine code for all of the processor's instructions. The provided file
{\it inst\_mem.mif} was created by using {\it sbasm.py} to {\it assemble} the program in
Figure~\ref{fig:assembly}. As the figure indicates, you can define symbolic
constants in your code by using the .\blue{define} {\it directive}, and you can use
labels to refers to lines of code, such as \texttt{MAIN}.
Comments are specified in the code by using \texttt{//}. The assembler ignores anything
on a line following \texttt{//}.

\lstset{language=ASM,numbers=none,escapechar=|}
\begin{figure}[H]
\begin{center}
\begin{minipage}[h]{12.5 cm}
\begin{lstlisting}[name=proc]
|\label{line:module}|.define LED_ADDRESS 0x1000
.define SW_ADDRESS 0x3000

// Read SW switches and display on LEDs
			mvt	r3, #LED_ADDRESS	// point to LED port
			mvt	r4, #SW_ADDRESS	// point to SW port
MAIN:		ld		r0, [r4]				// read SW values
			st		r0, [r3]				// light up LEDs
			mv 	pc, #MAIN
\end{lstlisting}
\end{minipage}
\caption{Assembly-language program that uses {\it ld} and {\it st} instructions.}
\label{fig:assembly}
\end{center}
\end{figure}

An example result produced by using {\it ModelSim} for a correctly-designed circuit
is given in Figure~\ref{fig:part3}. It shows the execution of the first four instructions
in Figure~\ref{fig:assembly}.

\item Once your simulation results are correct, use the Quartus Prime software to implement your
Verilog code on a DE1-SoC board. A sample Quartus project file, {\it part3.qpf}, and Quartus
settings file, {\it part3.qsf}, are provided with the exercise. Compile your code using the
Quartus software, and download the resulting circuit
into the DE1-SoC board. Toggle the SW switches and observe the LEDs to test your circuit.
\end{enumerate}

\begin{figure}[H]
	\begin{center}
		\includegraphics[width=\textwidth]{figures/part3.png}
	\end{center}
	\caption{Simulation results for the processor.}
	\label{fig:part3}
\end{figure}

\section*{Part IV}
In this part you are to create a new Verilog module that represents an output port called
{\it seg7}. It will allow your processor to write data to each of the six 7-segment displays on a
DE1-SoC board. The {\it seg7} module will include six write-only seven-bit registers,
one for each display. Each register should directly drive the segment lights for one
seven-segment display, so that the processor can write characters onto the displays.

~\\
\noindent
Perform the following:

\begin{enumerate}
\item A top-level file is provided for this part
called {\it part4.v}. The top-level module has output ports for connecting
to each of the 7-segment displays.
Pin assignments for these ports, which are called {\it HEX0}[6:0], {\it HEX1}[6:0],
$\ldots$, {\it HEX6}[6:0], are included in the Quartus settings file {\it part4.qsf}.
For each display, segment 0 is on the top of the display, and then segments 1 to 5 are assigned
in a clockwise fashion, with segment 6 being in the middle of the display.

The {\it part4.v} Verilog code includes address decoding for the new {\it seg7} module,
so that processor addresses in which $A_{15} A_{14} A_{13} A_{12} = 0010$ select this module.
The intent is that address \texttt{0x2000} should write to the register that controls
display {\it HEX0}, \texttt{0x2001} should select the register for {\it HEX1}, and
so on. For example, if your processor
writes \texttt{0} to address \texttt{0x2000}, then the {\it seg7} module
should turn off all of the segment-lights in the {\it HEX0} display; writing \texttt{0x7f}
should turn on all of the lights in this display.

\item
You are to complete the partially-written Verilog code in the file {\it seg7.v}, so that
it contains the required six registers---one for each 7-segment display.

\item You can compile and test your Verilog code by using the ModelSim setup files that
are provided for this part of the exercise. An {\it inst\_mem.mif} file is also provided
that corresponds to the assembly-language program shown in
Figure~\ref{fig:7segs}. This program works as follows: it reads the {\it SW} switch port and
lights up a seven-segment display corresponding to the value read on {\it SW}$_{2-0}$. For
example, if {\it SW}$_{2-0} = 000$, then the digit~\texttt{\red{0}} is shown on {\it HEX0}.
If {\it SW}$_{2-0} = 001$, then the digit~\texttt{\red{1}} is displayed on {\it HEX1},
and so on, up to the digit~\texttt{\red{5}} which would be shown on {\it HEX5} if
{\it SW}$_{2-0} = 101$.

\item Once your simulation results look correct, you should compile the provided Quartus
project, and then download and test the circuit on a DE1-SoC board.
\end{enumerate}

\lstset{language=ASM,numbers=none,escapechar=|}
\begin{figure}[H]
\begin{center}
\begin{minipage}[h]{15 cm}
\begin{lstlisting}[name=proc]
|\label{line:module}|
.define HEX_ADDRESS 0x2000
.define SW_ADDRESS 0x3000

// This program shows the digits 543210 on the HEX displays. Each digit has to
// be selected by using the SW switches.
			mv		r5, pc				// return address for subroutine
			mv 	pc, #BLANK			// call subroutine to blank the HEX displays
MAIN:		mvt	r2, #HEX_ADDRESS	// point to HEX port
			mv 	r3, #DATA			// used to get 7-segment display pattern

			mvt	r4, #SW_ADDRESS	// point to SW port
			ld		r0, [r4]				// read switches
			and   r0, #0x7          // use only SW2-0
			add	r2, r0				// point to correct HEX display
			add	r3, r0				// point to correct 7-segment pattern

			ld		r0, [r3]				// load the 7-segment pattern
			st		r0, [r2]				// light up HEX display

			mv 	pc, #MAIN

// subroutine BLANK
// 	This subroutine clears all of the HEX displays
//	input: none
//	returns: nothing
// changes: r0 and r1. Register r5 provides the return address
BLANK:   mv 	r0, #0				// used for clearing
			mvt	r1, #HEX_ADDRESS	// point to HEX displays
			st		r0, [r1]				// clear HEX0
			add	r1, #1
			st		r0, [r1]				// clear HEX1
			add	r1, #1
			st		r0, [r1]				// clear HEX2
			add	r1, #1
			st		r0, [r1]				// clear HEX3
			add	r1, #1
			st		r0, [r1]				// clear HEX4
			add	r1, #1
			st		r0, [r1]				// clear HEX5

			add	r5, #1
			mv		pc, r5				// return from subroutine

DATA:		.word 0b00111111			// '0'
			.word 0b00000110			// '1'
			.word 0b01011011			// '2'
			.word 0b01001111			// '3'
			.word 0b01100110			// '4'
			.word 0b01101101			// '5'
\end{lstlisting}
\end{minipage}
\caption{Assembly-language program that tests the seven-segment displays.}
\label{fig:7segs}
\end{center}
\end{figure}

\section*{Part V}
In this part you are to enhance your processor so that it implements the {\it b\{cond\}}
instruction.  The {\it conditions} supported by the processor are called
{\it eq}, {\it ne}, {\it cc}, and {\it cs}, which means that the variations of the branch
instruction are {\it b}, {\it beq}, {\it bne}, {\it bcc}, and {\it bcs}. The {\it b}
instruction {\it always} branches. For example, \texttt{b \#MAIN} loads the address
\texttt{MAIN} into the program counter. The meanings of the conditional versions are
explained below.

~\\
\noindent
The instruction {\it beq} means {\it branch if equal} (to zero). This instruction performs
a branch operation (i.e., loads the provided \texttt{\#LABEL} into the program counter) if the
most recent result of an instruction executed using the
arithmetic logic unit (ALU), which is stored in register $G$, was~0.
Similarly, {\it bne} means {\it branch if not
equal} (to zero).  It performs a branch only if the contents of $G$ are not equal to 0.
The instruction {\it bcc} stands for {\it branch if carry clear}. It branches if the last
add/subtract operation did {\it not} produce a carry-out. The opposite branch condition,
{\it bcs}, {\it branch if carry set}, performs a branch if the most recent add/sub
generated a carry-out. To support the conditional branch instructions, you should
create two {\it condition-code flags} in your processor. One flag, {\it z}, should have
the value 1 when the ALU generates a result of zero; otherwise {\it z} should be 0. The other
flag, {\it c}, should be 1 when the adder/subtracter in the ALU produces a carry-out;
otherwise {\it c} should be 0. Thus, {\it c} should be 1 when an {\it add}
instruction generates a carry-out,
or when a {\it sub} operation requires a borrow for the most-significant bit. Your FSM
controller should examine these flags in the appropriate clock cycles when executing the
{\it b\{cond\}} instructions.

~\\
\noindent
The branch instructions are encoded using the format \texttt{III1XXXDDDDDDDDD}, where
\texttt{DDDDDDDDD} is the branch address and \texttt{XXX} is the branch condition. Assume
that conditions are encoded as {\it none} (always branch) $= 000$, {\it eq}~$= 001$,
{\it ne} $= 010$, {\it cc} $= 011$, and {\it cs} $= 100$.

~\\
\noindent
Perform the following:

\begin{enumerate}
\item
Enhance your processor so that it implements the condition-code flags {\it z} and {\it c},
and supports the {\it b\{cond\}} instruction.
To help with testing and debugging of your processor, setup files for ModelSim are provided,
including a testbench. It simulates your processor instantiated in the top-level file
{\it part5.v}, which is the same as the one from Part IV.
An example {\it inst\_mem.mif} file is also provided, which corresponds
to the program in Figure~\ref{fig:branches}. This program is quite short,
which makes it suitable for visual inspection of the waveforms produced by a ModelSim simulation.
The program uses a sequence of instructions that test the various conditional branches.
If the program reaches the line of code labelled \texttt{DEAD}, then at least one
instruction has not worked properly. An example of ModelSim output for a correctly-working
processor is given in Figure~\ref{fig:part4}. It shows the processor executing instructions
near the end of the code in Figure~\ref{fig:branches}. The instruction that is completed
at simulation time 1030 ns is \texttt{add r0, \#1} (\texttt{0x5001}). As shown in the figure,
this instruction causes the carry flag, {\it c}, to become 1. The next instruction loaded
into {\it IR}, at time 1090 ns, is \texttt{bcs \#0xC} (\texttt{0xF80C}). Finally, the
instruction loaded at 1170~ns is \texttt{b~\#0} (\texttt{0xF000}).

\lstset{language=ASM,numbers=none,escapechar=|}
\begin{figure}[H]
\begin{center}
\begin{minipage}[h]{13.5 cm}
\begin{lstlisting}[name=proc]
MAIN:    mv    r0, #2
LOOP: 	sub   r0, #1        // subtract to test bne
			bne   #LOOP
			beq   #T1           // r0 == 0, test beq
			mv    pc, #DEAD
T1:      mvt   r0, #0xFF00
         add   r0, #0xFF     // r0 = 0xFFFF
			bcc   #T2           // carry = 0, test bcc
			mv    pc, #DEAD
T2:      add   r0, #1
			bcs   #T3           // carry = 1, test bcs
			mv    pc, #DEAD
T3:	   b     #MAIN
DEAD:    mv    pc, #DEAD
\end{lstlisting}
\end{minipage}
\caption{Assembly-language program that uses various branches.}
\label{fig:branches}
\end{center}
\end{figure}

\begin{figure}[H]
	\begin{center}
		\includegraphics[width=\textwidth]{figures/part5.png}
	\end{center}
	\caption{Simulation results for the processor.}
	\label{fig:part4}
\end{figure}

\item Once your ModelSim simulation indicates a correctly-functioning processor you should
implement it on a DE1-SoC board.  A Quartus project file {\it part5.qpf} and settings file
{\it part5.qsf} are provided for this purpose. To test your processor, you can use the
assembly-language program displayed in Figure~\ref{fig:sitbooboosit}. It provides code that
tests for the correct operation of instructions supported by the enhanced processor.
If all of the tests pass, then
the program shows the word \texttt{\red{PASSEd}} on the seven-segment displays. It also shows
a binary value on the LEDs that represents the number of successful tests performed. If any test
fails, then the program shows the word \texttt{\red{FAILEd}} on the seven-segment displays and
places on the LEDs the address in the memory of the instruction that caused the failure.
Assemble the program, which is provided in a file called {\it sitbooboosit.s}, by using
the {\it sbasm.py} assembler.

Use the output produced by {\it sbasm.py} to {\it overwrite} the file {\it inst\_mem.mif}
that you used in the beginning of this part of the exercise to simulate your processor
system with ModelSim. Open the Quartus software, compile the {\it part5} project,
and download it onto
your DE1-SoC board.  If the {\it Run} signal is asserted, then your processor should execute the
{\it sitbooboosit} program. If a failure is encountered, then the
offending instruction can be identified by cross-referencing the LED pattern with the addresses
in the file {\it inst\_mem.mif}.
\end{enumerate}

\vspace{-0.5cm}
\lstset{language=ASM,numbers=none,escapechar=|}
\begin{figure}[H]
\begin{center}
\begin{minipage}[h]{14 cm}
\begin{lstlisting}[name=proc]
.define LED_ADDRESS 0x1000
.define HEX_ADDRESS 0x2000
			mv 	r2, #0		// used to count number of successful tests
			mv 	r6, #T1		// save address of next test
			sub	r0, r0		// set the z flag
T1:		bne	#FAIL    	// test bne; should not take the branch!
			mv 	r6, #C1		// save address of next test
C1:      beq   #C2         // test beq; should take the branch
    		b	   #FAIL    	// Argh!
C2:		add	r2, #2		// count the last two successful tests
\end{lstlisting}
\end{minipage}
\caption{Assembly-language program that tests various instructions. (Part $a$)}
\label{fig:sitbooboosit}
\end{center}
\end{figure}

\begin{center}
\begin{minipage}[t]{14 cm}
\begin{lstlisting}[name=proc]
			mv		r6, #T2			// save address of next test
T2:		bne	#S1    			// test bne; should take the branch!
			mv		pc, #FAIL
S1:		mv 	r6, #C3			// save address of next test
C3:      beq   #FAIL          // test beq; should not take the branch
			add	r2, #2			// count the last two successful tests

			mv		r6, #T3			// save address of next test
			mv		r3, #ALLONES
			ld		r3, [r3]
			add	r3, #1			// set the c flag

T3:		bcc	#FAIL    		// test bcc; should not take the branch!
			mv 	r6, #C4			// save address of next test
C4:      bcs   #C5            // test bcs; should take the branch
    		b	   #FAIL    		// Argh!
C5:		add	r2, #2			// count the last two successful tests

			mv		r6, #T4
			mv		r3, #0
			add	r3, r3			// clear carry flag

T4:		bcc	#S2   			// test bcc; should take the branch!
			mv		pc, #FAIL
S2:		mv 	r6, #C6			// save address of next test
C6:      bcs   #FAIL          // test bcs; should bot take the branch!
         add	r2, #2			// count the last two successes

// finally, test ld and st from/to memory
			mv		r6, #T5			// save address of next test
			mv		r4, #_LDTEST
			ld		r4, [r4]
			mv		r3, #0x1A5
			sub	r3, r4
T5:		bne	#FAIL	      	// should not take the branch!
			add	r2, #1			// increment success count

			mv		r6, #T6			// save address of next test
			mv		r3, #0x1A5
			mv		r4, #_STTEST
			st		r3, [r4]
			ld		r4, [r4]
			sub	r3, r4
T6:		bne	#FAIL    		// should not take the branch!
			add	r2, #1			// increment success count

			mv		pc, #PASS
			// Loop over the six HEX displays
FAIL:		mvt	r3, #LED_ADDRESS
			st		r6, [r3]			// show address of failed test on LEDs
			mv		r5, #_FAIL
			mv		pc, #PRINT
PASS:		mvt	r3, #LED_ADDRESS
			st		r2, [r3]			// show success count on LEDs
			mv		r5, #_PASS
\end{lstlisting}
\end{minipage}
\end{center}

\begin{center}
Figure \ref{fig:sitbooboosit}: Assembly-language program that tests various instructions. (Part $b$)
\end{center}

\begin{center}
\begin{minipage}[t]{12.5 cm}
\begin{lstlisting}[name=proc]
PRINT:	mvt	r4, #HEX_ADDRESS		// address of HEX0
			// We would normally use a loop counting down from 6
			// with bne to display the six letters. But in this
			// testing code we can't assume that bne even works!

			ld		r3, [r5]			// get letter
 			st		r3, [r4]			// send to HEX display
 			add	r5, #1			// ++increment character pointer
 			add	r4, #1			// point to next HEX display
			ld		r3, [r5]			// get letter
 			st		r3, [r4]			// send to HEX display
 			add	r5, #1			// ++increment character pointer
 			add	r4, #1			// point to next HEX display
			ld		r3, [r5]			// get letter
 			st		r3, [r4]			// send to HEX display
 			add	r5, #1			// ++increment character pointer
 			add	r4, #1			// point to next HEX display
			ld		r3, [r5]			// get letter
 			st		r3, [r4]			// send to HEX display
 			add	r5, #1			// ++increment character pointer
 			add	r4, #1			// point to next HEX display
			ld		r3, [r5]			// get letter
 			st		r3, [r4]			// send to HEX display
 			add	r5, #1			// ++increment character pointer
 			add	r4, #1			// point to next HEX display
			ld		r3, [r5]			// get letter
 			st		r3, [r4]			// send to HEX display
 			add	r5, #1			// ++increment character pointer
 			add	r4, #1			// point to next HEX display

HERE:		mv		pc, #HERE

_PASS:	.word	0b0000000001011110	// d
			.word	0b0000000001111001	// E
			.word	0b0000000001101101	// S
			.word	0b0000000001101101	// S
			.word	0b0000000001110111	// A
			.word 0b0000000001110011	// P

_FAIL:	.word	0b0000000001011110	// d
			.word	0b0000000001111001	// E
			.word	0b0000000000111000	// L
			.word	0b0000000000110000	// I
			.word	0b0000000001110111	// A
			.word 0b0000000001110001	// F

ALLONES:	.word 0xFFFF
_LDTEST:	.word 0x1A5
_STTEST:	.word 0x15A
\end{lstlisting}
\end{minipage}
\end{center}

\begin{center}
Figure \ref{fig:sitbooboosit}: Assembly-language program that tests various instructions. (Part $c$)
\end{center}

\section*{Part VI}
Write an assembly-language program that displays a binary counter on the LED port. Initialize
the counter to 0, and then increment the counter by one in an endless loop. You should be
able to control the speed at which the counter is incremented by using nested delay loops,
along with the SW switches. If the SW switches are set to their maximum value,
\texttt{0b111111111}, then the delay loops should cause the counter to increment slowly enough
so that each change in the counter can be visually observed on the LEDs. Lowering the value
of the SW switches should make the counter increment more quickly up to some maximum speed.

~\\
\noindent
You can assemble your program by using the {\it sbasm.py} assembler, and then run it on
your processor system from Part V. To do this, use the output produced by {\it sbasm.py} to
{\it overwrite} the file {\it inst\_mem.mif} in the folder that holds your Quartus project for
Part V. To make use of the new {\it inst\_mem.mif} file you do not need to completely
recompile your Verilog code from Part V. Instead, execute the Quartus command
\texttt{Processing} $>$ \texttt{Update Memory Initialization File}, to include the
new {\it inst\_mem.mif} file in your Quartus project. Next, select the Quartus
command \texttt{Processing} $>$ \texttt{Start} $>$ \texttt{Start Assembler} to produce a new
programming {\it bitstream} for your DE1-SoC board. Finally, use the Quartus Programmer to
download the new bitstream onto your board. If the {\it Run} signal is asserted, your
processor should execute the new program.

\section*{Part VII}
Augment your assembly-language program from Part VI so that counter values are displayed
on the seven-segment display port rather than on the LED port. You should display the
counter values as decimal numbers from \texttt{\red{0}} to \texttt{\red{65535}}.
The speed of counting should be controllable using the SW switches in the same way as for
Part VI. As part of your solution you may want to make use of the code shown in
Figure~\ref{fig:div10}. This code provides a subroutine that divides the number in
register $r0$ by 10, returning the quotient in $r1$ and the remainder in $r0$. Dividing by 10 is a
useful operation when performing binary-to-decimal conversion. The \texttt{DIV10} subroutine
assumes that $r6$ is set up to be used as a {\it stack pointer}. Register $r2$ is saved on the
stack at the beginning of the subroutine, and then restored before returning. This is done so
that $r2$ is not unnecessarily changed by the subroutine. A skeleton of the required code
for this part is shown in Figure~\ref{fig:part7}.

\lstset{language=ASM,numbers=none,escapechar=|}
\begin{figure}[H]
\begin{center}
\begin{minipage}[h]{15 cm}
\begin{lstlisting}[name=proc]
// subroutine DIV10
//	  This subroutine divides the number in r0 by 10
//	  The algorithm subtracts 10 from r0 until r0 < 10, and keeps count in r1
//	  This subroutine assumes that r6 can be used as a stack pointer
//	  input: r0
//	  returns: quotient Q in r1, remainder R in r0
DIV10:
			sub	r6, #1				// save registers that are modified
			st		r2, [r6]				// save on the stack

			mv 	r1, #0				// init Q
DLOOP:	mv 	r2, #9				// check if r0 is < 10  yet
			sub	r2, r0
			bcc	#RETDIV				// if so, then return

INC:		add	r1, #1				// but if not, then increment Q
			sub	r0, #10				// r0 -= 10
			b 		#DLOOP				// continue loop
RETDIV:
			ld		r2, [r6]				// restore from the stack
			add	r6, #1
			add	r5, #1				// adjust the return address
			mv		pc, r5				// return results
\end{lstlisting}
\end{minipage}
\caption{A subroutine that divides by 10}
\label{fig:div10}
\end{center}
\end{figure}

\noindent
As described previously, assemble your program with {\it sbasm.py}, update your {\it MIF} file
in the Quartus software, generate a new bitstream file by using the Quartus Assembler, and
then download the new bitstream onto your DE1-SoC board to run your new program.

\lstset{language=ASM,numbers=none,escapechar=|}
\begin{figure}[H]
\begin{center}
\begin{minipage}[h]{15 cm}
\begin{lstlisting}[name=proc]
.define HEX_ADDRESS 0x2000
.define SW_ADDRESS 0x3000
.define STACK 256						// bottom of memory

// This program shows a decimal counter on the HEX displays
			mv 	r6, #STACK			// stack pointer
			mv		r5, pc				// return address for subroutine
			mv 	pc, #BLANK			// call subroutine to blank the HEX displays
MAIN:		mv 	r0, #0				// initialize counter
LOOP:		mvt	r1, #HEX_ADDRESS	// point to HEX port
			...
         ... use a loop to extract and display each digit
         ...

// Delay loop for controlling the rate at which the HEX displays are updated
         ...
         ... read from SW switches, and use a nested delay loop
         ...

			add	r0, #1				// counter += 1
			bcc	#LOOP					// continue until counter overflows

			mv		r5, pc				// return address for subroutine
			mv 	pc, #BLANK			// call subroutine to blank the HEX displays
			b 	   #MAIN

// subroutine DIV
         ...
         ... code not shown here
         ...
			add	r5, #1				// adjust the return address
			mv		pc, r5				// return results

// subroutine BLANK
         ...
         ... code not shown here
         ...
			add	r5, #1
			mv		pc, r5				// return from subroutine

DATA:		.word 0b00111111			// '0'
			....
\end{lstlisting}
\end{minipage}
\caption{Skeleton code for displaying decimal digits.}
\label{fig:part7}
\end{center}
\end{figure}

\end{document}


text:
\documentclass[11pt,letterpaper]{article}

\usepackage[letterpaper,margin=1in]{geometry}

\usepackage[backend=biber,style=numeric,sorting=none]{biblatex}
\addbibresource{main.bib}

\usepackage[]{authblk}
\renewcommand\Affilfont{\itshape\small}

\usepackage{caption}
\usepackage{enumitem}
\usepackage{float}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{textcomp}

% No indentation
\setlength\parindent{0pt}

\pagenumbering{arabic}

% Title, authors and affiliations
\title{The latest shit}
\author[1]{Me}

\affil[1]{My Institute}

\begin{document}

\maketitle
% \thispagestyle{empty}

\begin{abstract}
  \input{./sections/abstract}
\end{abstract}

% \newpage
% \clearpage
% \setcounter{page}{1}

% \raggedright

\section{Introduction}
\input{./sections/introduction}

\section{Materials and Methods}
\input{./sections/materials_and_methods}

\section{Results}
\input{./sections/results}

\section{Conclusions}
\input{./sections/conclusions}

\section{References}
\printbibliography[heading=none]

\end{document}

max_stars_repo_name: hackermd/article-template

max_issues_repo_name: hackermd/article-template

max_forks_repo_name: hackermd/article-template


text:
\documentclass[main.tex]{subfiles}
\begin{document}

\marginpar{Friday\\ 2020-3-27, \\ compiled \\ \today}

In the perturbed Einstein Equations we will need the stress-energy tensor: it does not require the full phase space distribution, but only certain kinds of integrated information.

With our approach, we did not assume that DE, DM and such are fluids: instead, we have shown it.

We can combine the equations for electrons and protons into a unique equation for the baryons:
%
\begin{align}
m_p \pdv{}{t} \qty(n_b v_b^{j}) + 4H m_p n_b v_b^{j} \dots
\,.
\end{align}
%

The quantity \(- \expval{c_{e \gamma } p \mu } / \rho_{b}\) is similar to what we had for photons: a monopole term, the temperature anisotropy, and the Doppler term, which is called that since it involves a velocity. Then we get
%
\begin{subequations}
\begin{align}
- \expval{c_{e \gamma } p \mu } / \rho_{b}
&= \frac{n_e \sigma_{T}}{\rho_{b}}
\int \frac{ \dd[3]{p}}{(2 \pi )^3} p^2 \pdv{f^{(0)}}{p} \mu \qty[ \widetilde{\theta}_{0} - \widetilde{\theta} (\mu ) + \widetilde{v}_{b} \mu ]  \\
&= \frac{n_e \sigma_{T}}{\rho_{b}}
\int_{0}^{ \infty } \frac{ \dd{p}}{2 \pi^2} p^{4} \pdv{f^{(0)}}{p} \int_{-1}^{1} \frac{ \dd{\mu }}{2} \mu \qty[\widetilde{\theta}_{0} - \widetilde{\theta} (\mu ) + \widetilde{v}_{b} \mu ]
\,,
\end{align}
\end{subequations}
%
notice that the terms inside the bracket are independent of the modulus of \(p\).
Now we define the \emph{dipole}:
%
\begin{align}
\theta_{1} = i \int_{-1}^{1} \frac{ \dd{\mu }}{2 } \mu \theta(\mu )
\,,
\end{align}
%
so we finally get
%
\begin{align}
\widetilde{\dot{v}}_{b} + \frac{\dot{a}}{a} \widetilde{v}_{b}
+ i k \widetilde{\Phi} =
\dot{\tau} R \qty(3 i \widetilde{\theta}_{1} + \widetilde{v}_{b})
\,,
\end{align}
%
where we defined
%
\begin{align}
R = \frac{3 \rho_b^{(0)}}{4 \rho_{\gamma }^{(0)}}
\,.
\end{align}

In general we define the multipole moments as
%
\begin{align}
\theta_{\ell} = \frac{1}{(-i)^{\ell}} \int_{-1}^{1} \frac{ \dd{\mu }}{2} P_\ell (\mu ) \theta(\mu )
\,,
\end{align}
%
where \(P_e (\mu )\) are the Legendre polynomials.

Then we get
%
\begin{align}
\widetilde{\dot{\theta}} + ik \mu \widetilde{\theta} - \widetilde{\dot{\Psi}}
+ ik \mu \widetilde{\Phi} =
-\dot{\tau} \qty[\widetilde{\theta}_{0} - \widetilde{\theta}
+ \mu v_b - \frac{1}{2} P_2 (\mu ) \widetilde{\theta}_{2}]
\,,
\end{align}
%
where the addition of the quadrupole term accounts for (???), see the notes by Natale \cite[]{nataleNoteCorsoDi2017}.

Dropping the tildes, we get
%
\begin{subequations}
\begin{align}
\dot{\theta} + ik \mu \theta &= \dot{\Psi} - ik \mu \Phi - \dot{\tau} \qty[\theta_0 - \theta + \mu v_b - \frac{1}{2} P_2 (\mu ) \Pi ]  \\
\Pi &= \theta_2 - \theta_{P_2 } + \theta_{P_0 }  \\
\dot{\theta}_{p} + i k \mu \theta_{p} &= - \dot{\tau} \qty[- \theta_{p} + \frac{1}{2} \qty(1 - P_2 (\mu ) \Pi )] \dots
\,,
\end{align}
\end{subequations}
%
anisotropy creates polarization, polarization does not affect polarization much.

Why do we not have a quadrupole term? Its integral is zero since it is multiplied by \(\mu \).

What about neutrinos?
We can model the anisotropies in the cosmic neutrino background using Fermi-Dirac statistics, with
%
\begin{align}
f = \frac{1}{\exp(d)} \dots
\,,
\end{align}
%
so now repeating the considerations we made for the photons, we get
%
\begin{align}
\dot{w} \dots
\,.
\end{align}

\section{Perturbing the Einstein Equations}

Why do we consider only the scalar perturbations? Vectors do not obey dynamical equation but only conservation equations, and they die away quickly in the expansion.
The Lense-Thirring effect is about the \(g_{0i}\) terms, and it is not governed by the (???) theorem, but we neglect it as well.

Tensor perturbations are gravitational waves.
They evolve separately from the scalar perturbations: we decompose the anisotropy into
%
\begin{align}
\theta^{T} (k, \mu, \phi ) = \theta^{T}_{+} (k, \mu ) \qty(1 - \mu^2) \cos( 2 \phi ) + \theta^{t}_{ \times } (k, \mu ) (1-\mu^2)
\,,
\end{align}
%
and both of the polarizations (\(\epsilon = +, \times \)) satisfy
%
\begin{align}
\dot{\theta}^{T}_{\epsilon } + ik \mu \theta^{T}_{\epsilon } + \frac{1}{2} \dot{h}_{\epsilon } = \dot{\tau} \qty[
\theta^{T}_{\epsilon } - \frac{1}{10} \theta^{T}_{\epsilon, 0} - \frac{1}{7} \theta^{T}_{ \epsilon , 2} - \frac{3}{7} \theta^{T}_{\epsilon , 4}]
\,.
\end{align}

Let us then perturb Einstein's equations: we use conformal time, so the metric (in Euclidean flat 3-space) is
%
\begin{align}
\dd{s^2} = a^2 \qty[- (1 + 2 \Phi ) \dd{\eta^2} + (1- 2 \Psi ) \dd{\ell^2}]
\,.
\end{align}

We compute the Christoffel symbols, and from these we get the Ricci tensor, the Ricci scalar and the Einstein tensor.
It is generally much more convenient to write the equations with mixed indices
%
\begin{align}
G^{\mu }_{\nu } = 8 \pi G T^{\mu }_{\nu }
\,.
\end{align}

To first order we get
%
\begin{subequations}
\begin{align}
\Gamma^{0}_{00} &= \frac{ \dot{a} }{a } + \dot{\Phi}  \\
\Gamma^{i}_{0j }&= \qty(\frac{\dot{a}}{a} - \dot{\Psi}) \delta^{i}_{j}  \\
\Gamma^{0}_{ij} &= \qty[\frac{\dot{a}}{a } \qty(1 - 2 \Phi - 2 \Psi ) - \dot{\Psi}] \delta_{ij}  \\
\Gamma^{0}_{0i} &= \partial_{i} \Phi   \\
\Gamma^{i}_{00} &= \partial^{i} \Phi   \\
\Gamma^{i}_{jk} &= - \partial_{j} \Psi \delta^{i}_{k} - \partial_{k} \Psi \delta^{i}_{j} + \partial^{i} \Psi
\delta_{jk}
\,,
\end{align}
\end{subequations}
%
so the Einstein tensor reads:
%
\begin{align}
G^{0}_{0} = \frac{1}{a^2} \qty[\dots]
\,,
\end{align}
%

Often people make the quasi-static approximation, in which we neglect the time-derivatives of the potentials. We do not do that here.
The stress-energy tensor has the following 00 component:
%
\begin{align}
T^{0}_{0} = - \sum _{i} g_i \int  \frac{ \dd[3]{p}}{(2 \pi )^3} E_i (p) f_i (\vec{x}, \vec{p} ,t)
\,.
\end{align}

For nonrelativistic matter, \(E_i \sim m_i\): then we get
%
\begin{align}
T^{0, \text{dm}}_{0} = - \rho_{\text{dm}} (1 + \delta )
\,.
\end{align}

For the photons we have
%
\begin{align}
T^{0,(\gamma )}_{0} =
-2 \int \frac{\dd[3]{p}}{(2 \pi )^3} p \qty[f^{(0)} - p \pdv{f^{(0)}}{p} \theta ]
= - \rho_{\gamma } \qty[ 1 + 4 \Theta_0 ]
\,,
\end{align}
%
and for the neutrinos we get the exact same result, substituting the variables:
%
\begin{align}
T_{0}^{0, (\nu )} = - \rho_{\nu } \qty[1 + 4 w_0 ]
\,.
\end{align}

Dark Energy is usually considered to be smooth. Then we have, for the 00 EFE:
%
\begin{align} \label{eq:einstein-00-perturbed-equation}
\nabla^2 \Psi - 3 \frac{\dot{a}}{a} \qty(\dot{\Psi} + \Phi \frac{\dot{a}}{a }) = 4 \pi G a^2 \qty(
\rho_{\text{dm}} \delta + \rho_{b} \delta_{b} + 4 \rho_{\gamma } \Theta_0 + 4 \rho_{\nu } w_0
)
\,.
\end{align}

Recall that we want to solve for \(\Psi \) and \(\Phi \): we have a lot of redundancy in the EFE.
Another convenient independent equation is the traceless part of the \(ij\) components.
The simplest way to do these calculations is to use projectors in Fourier space.

On the left hand side we get
%
\begin{subequations}
\begin{align}
\qty(\hat{k}_{i} \hat{k}^{j} - \frac{1}{3} \delta^{i}_{j}) \hat{G}^{i}_{j} &= \qty(\hat{k}_{i} \hat{k}^{j} - \frac{1}{3} \delta_{i}^{j})
\frac{k^{i}k_{j}}{a^2} \qty(\Phi - \Psi )  \\
&= \frac{2}{3} \frac{k^2}{a^2} \qty(\Phi- \Psi )
\,.
\end{align}
\end{subequations}

\end{document}

max_stars_repo_name: jacopok/notes

max_issues_repo_name: jacopok/notes

max_forks_repo_name: jacopok/notes