OpenCores
URL https://opencores.org/ocsvn/present/present/trunk

Subversion Repositories present

[/] [present/] [trunk/] [Decode/] [doc/] [src/] [present_decode.tex] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 gajos
\documentclass{gajewski}
2
 
3
\bibliographystyle{IEEEtran}
4
 
5
%%%%%%%%%%%%%%%%%
6
% Document variables
7
%%%%%%%%%%%%%%%%%
8
\docDate{ \today }
9
\docID{Present Decoder}
10 20 gajos
\docRevision{0.2}
11 16 gajos
\docStatus{Draft}
12
\docTitle{\mbox{Present Decoder}}
13
\authorName{\mbox{Krzysztof Gajewski} \\ and opencores.org}
14
\authorURL{www.opencores.org}
15
\authorAddress{\mbox{}}
16
\authorEmail{gajos@opencores.org}
17
 
18
\revisionList{
19
0.1 & all & 2014/05/25 & First draft & K. Gajewski \\
20 20 gajos
0.2 & all & 2014/09/16 & Some small corrections with the text, typos, etc. & K. Gajewski \\
21 16 gajos
}
22
 
23
\begin{document}
24
 
25
\maketitle
26
 
27
\newpage
28
 
29
\revisionTable
30
 
31
\newpage
32
 
33
\tableofcontents
34
\newpage
35
 
36
\section{Introduction}
37
 
38
Present is "ultra-lightweight" block cipher developed by A. Bogdanov et al. and proposed in 2007 \cite{PRESENT}. It uses 64 bit data block and 80 bit or 128 bit key.
39
This cipher consists of 32 rounds, during which:
40
\begin{itemize}
41
    \item round key is added to plaintext
42
    \item plaintext goes through sBoxes (substitution boxes)
43
    \item plaintext after sBoxes goes through pLayer (permutation layer)
44
    \item round key is updated
45
\end{itemize}
46
After that, ciphertext feeds out the output. Briefly algorithm was shown in Fig. \ref{pAlgorithm}.
47
\begin{figure}[!ht]%
48
    \begin{center}
49
    \includegraphics[width=0.66\textwidth]{img/presentAlgorithm.png}
50
    \caption{%
51
        Briefly block scheme of the PRESENT block cipher
52
     }%
53
    \label{pAlgorithm}
54
    \end{center}
55
 \end{figure}
56 20 gajos
In subprojects \texttt{Pure} and \texttt{PureTesting} Present encoder components was presented. In this subproject Present decoder was presented. Decoding key is firstly generated, basing on the key used for data coding. Next, input data are decoded (taking into account "inverse" direction to the presented in Fig. \ref{pAlgorithm}), and at last feeds the output. This core works with 80 bit key. Target was Xilinx\textsuperscript{\textregistered} Spartan 3E XC3S500E \cite{Spartan} on Spartan 3E  Starter Board \cite{Digilent} made by Digilent\textsuperscript{\textregistered}.
57 16 gajos
 
58
\newpage
59
 
60
\section{Interface}
61
 
62 20 gajos
Top level component of the Present decoder was shown in Fig. \ref{pfdec}. All inputs and outputs are synchronous except \texttt{reset} signal and sampled at rising edge of the clock. Type for all signals is \texttt{STD\_LOGIC} or \texttt{STD\_LOGIC\_VECTOR}.
63 16 gajos
\begin{figure}[!ht]%
64
    \begin{center}
65
    \includegraphics[width=0.5\textwidth]{img/PresentFullDecoder.png}
66
    \caption{%
67 20 gajos
        Top level component of the Present decoder
68 16 gajos
     }%
69
    \label{pfdec}
70
    \end{center}
71
 \end{figure}
72
 
73
\begin{tabularx}{\textwidth}{|p{30mm}|p{11mm}|p{11mm}|X|}
74
  \hline \bf{Signal name} & \bf{Width} & \bf{In/Out} & \bf{Description}\\
75
  \hline \texttt{ciphertext}    & 64  &  in  & input data which have to be decoded. \\
76
  \hline \texttt{key}   & 80  &  in  & secret key used for input data decoding (the same which was used for data encoding). \\
77
  \hline \texttt{clk}   & 1  &  in  &  clock signal for the component\\
78 20 gajos
  \hline \texttt{reset} & 1   &  in  & \emph{asynchronous} reset signal.        \\
79 16 gajos
  \hline \texttt{start} & 1   &  in  & signal which starts decoding process. \\
80
  \hline \texttt{plaintext} & 64   &  out  & decoded text output. \\
81
  \hline \texttt{ready} & 1   &  out  & signal informing about end of decoding process. \newline  "0" - wait until end of data decoding. \newline  "1" - data at the \texttt{ciphertext} output are valid, you can read them. \\
82
  \hline
83
\end{tabularx}
84 20 gajos
\captionof{table}{Input/Output signals of the Present Decoder component}
85 16 gajos
 
86
\newpage
87
 
88
\section{Internal structure and state machine workflow}
89
 
90
\begin{figure}[!ht]%
91
    \begin{center}
92
    \includegraphics[width=0.8\textwidth]{img/internalStructure.png}
93
    \caption{%
94 20 gajos
        Internal datapath between main components in the Present decoder.
95 16 gajos
     }%
96
    \label{internalStructure}
97
    \end{center}
98
 \end{figure}
99
 
100
Internal datapath between main components was shown in Fig. \ref{internalStructure}. They are responsible for:
101
 
102
\begin{itemize}
103
    \item \texttt{PresentEncKeyGen} - key generator for decoding process. Before decoding stage, key need to be prepared to the 'appropriate value'. This value is signalled by \texttt{ready = '1'}. It is almost the same core as in \texttt{Present} subproject, but truncated from text encoding part.
104
    \item \texttt{PresentDec} - subcomponent responsible for ciphertext decoding. It is working in similar way as Present cipher, but is working in inverse way.
105
    \item \texttt{FullDecoderSM} - State machine controlling overall decoding process.
106
\end{itemize}
107
 
108
More information about cipher core and key generation process can be found in \\ \texttt{./Present/doc/present\_pure.pdf} file ("Present" subproject documentation).
109
 
110
\begin{figure}[!ht]%
111
    \begin{center}
112
    \includegraphics[width=0.4\textwidth]{img/PresentDecStateMachine.jpg}
113
    \caption{%
114
        State machine of the Present component
115
     }%
116
    \label{presentDecSM}
117
    \end{center}
118
 \end{figure}
119
 
120 20 gajos
State machine of the \texttt{PresentDec} component was shown in Fig. \ref{presentDecSM}. It consists of three states \texttt{NOP}, \texttt{SM\_START} and \texttt{READY}. The way of work of this state machine is the same as in the \texttt{Present} subproject, but the counter is counting down instead of counting up.
121 16 gajos
 
122
\begin{figure}[!ht]%
123
    \begin{center}
124
    \includegraphics[width=0.5\textwidth]{img/FullDecoderSM.jpg}
125
    \caption{%
126
        State machine of the Present decoder in main component.
127
     }%
128
    \label{presentFullDecSM}
129
    \end{center}
130
 \end{figure}
131
 
132 20 gajos
State machine of the \texttt{FullDecoderSM} component was shown in Fig. \ref{presentFullDecSM}. It consists of four states \texttt{NOP}, \texttt{KG\_START}, \texttt{DEC\_START} and \texttt{READY}. \texttt{NOP} is the default state after resetting the core. This state is active as long as \texttt{full\_decoder\_start} = '0'.
133 16 gajos
 
134
When \texttt{full\_decoder\_start} = '1' key generation for the decoding process starts. Proper \texttt{key} and \texttt{ciphertext} must feed the input before. \texttt{KG\_START} state is active as long \texttt{PresentEncKeyGen} is generating the key. Key generation ends, when \texttt{PresentEncKeyGen} sets the \texttt{ready} signal to '1'. When the \texttt{ready} signal is set to '1', the state is changing.
135
 
136
During \texttt{DEC\_START} state decoding process appears. State machine is in this state until \texttt{PresentDec} ends its works. The end of decoding is signalled by setting the \texttt{ready} signal to '1' by the \texttt{PresentDec} component. Then, the state is changing.
137
 
138 20 gajos
\texttt{READY} state sets the \texttt{ready} signal of the \texttt{PresentFullDecoder} to '1'. It is idle-like state, when user can read the output of the Present decoder. The state machine is in this state until user sets the \texttt{full\_decoder\_start} to '0'.
139 16 gajos
 
140
\newpage
141
 
142
\section{FPGA implementations}
143
 
144
The  component  has  only  been  verified on a Xilinx\textsuperscript{\textregistered} Spartan 3E XC3S500E FPGA in FG320 package and synthesized  with  Xilinx  ISE  14.2.  Appropriate setup files was prepared with use of ISE Project Navigator, but Makefile scripts was also written. Suitable files was stored in \texttt{./Decode/syn/XC3ES500/}  directory.
145
Implementation in FPGA device was done in another subproject called \texttt{DecodeTesting}.
146
Makefile was tested in Windows 8 with use of Cygwin for 64-bit Windows.
147
 
148
Synthesis results was given in Fig. \ref{SynResults}
149
 
150
\begin{tabularx}{\textwidth}{|p{45mm}|p{30mm}|p{30mm}|X|}
151
  \hline \multicolumn{4}{|c|}{Xilinx \textregistered Spartan 3E XC3S500E FPGA in FG320 package} \\
152
  \hline \bf{Parameter} & \bf{Used} & \bf{Available} & \bf{Utilisation}\\
153
  \hline Number of Slices & 354 & 4656 & 7\% \\
154
  \hline Number of Slice Flip Flops & 240 & 9312 & 2\% \\
155
  \hline Number of 4 input LUTs & 402 & 9312 & 4\% \\
156
  \hline Number of bonded IOBs & 212 & 232 & 91\% \\
157
  \hline Number of GCLKs & 1 & 24 & 4\%\\
158
  \hline Minimum period & 5.023ns & - & - \\
159
  \hline Maximum Frequency & 199 MHz & - & - \\
160
  \hline
161
\end{tabularx}
162
\label{SynResults}
163
\captionof{table}{Synthesis results for Spartan 3E XC3S500E}
164
 
165
Possible change in used FPGA device may be possible in steps given below\footnotemark[1]:
166
\begin{enumerate}
167
    \item Copy \texttt{./Decode/syn/XC3ES500/} directory to another one like \texttt{./Decode/syn/YOUR\_FPGA\_SYMBOL/}
168 20 gajos
    \item Go to \texttt{./Decode/syn/YOUR\_FPGA\_SYMBOL/}  directory.
169
    \item In \texttt{PresentFullDecoder.xst} file modify the line \texttt{-p xc3s500e-5-fg320} to \texttt{-p YOUR\_FPGA\_CODE}
170
    \item In \texttt{Makefile} file modify the line \texttt{PLATFORM=xc3s500e-fg320-5} to \texttt{PLATFORM=YOUR\_FPGA\_CODE}
171 16 gajos
\end{enumerate}
172
 
173 20 gajos
\footnotetext[1]{This solution was not tested and is based on my own observations.}
174 16 gajos
 
175
 
176
\newpage
177
 
178
\section{Simulation}
179
 
180 20 gajos
Self-checking test bench were provided to the components used for the Present encoder. They are stored in \texttt{./Decode/bench/vhdl} directory. Suitable configuration files and Makefile used for running test bench was stored in
181 16 gajos
\texttt{./Decode/sim/rtl\_sim/bin} directory. Appropriate test vectors was taken from \cite{PRESENT}.
182
 
183
Makefile was prepared to make "manual run" of tests. If You want to perform it without gui, remove \texttt{-gui} option in Makefaile.
184
 
185
\newpage
186
 
187
\section{Troubleshooting}
188
 
189
During work with Windows 8 64-bit and and Xilinx\textsuperscript{\textregistered} ISE 64-bit some problems may occur:
190
 
191
\begin{enumerate}
192
    \item Xilinx may be unable to open projects in Project Navigator.
193
    \item When you run \texttt{make} in Cygwin and perform testbench it would be unable to open ISIM gui.
194
    \item When you run ISIM gui  (*.exe test bench file) it hangs out or anti virus protection opens.
195
\end{enumerate}
196
 
197
To solve problems listed above you have to perform steps listed below:
198
\begin{enumerate}
199
    \item You have to rename libraries \texttt{libPortabilityNOSH.dll} to \texttt{libPortability.dll} from \texttt{nt64} directories (\href{http://www.gadgetfactory.net/2013/09/having-problems-installing-xilinx-ise-on-windows-8-64bit-here-is-a-fix-video-included/}{http://www.gadgetfactory.net/2013/09/having-problems-installing-xilinx-ise-on-windows-8-64bit-here-is-a-fix-video-included/})
200
    \item Firstly, install Cygwin X11 (\href{http://stackoverflow.com/questions/9393462/cannot-launch-git-gui-using-cygwin-on-windows}{http://stackoverflow.com/questions/9393462/cannot-launch-git-gui-using-cygwin-on-windows})
201
    \item Temporary switch off anti virus protection.
202
\end{enumerate}
203
 
204
\newpage
205
 
206
\section{License and Liability}
207
 
208
Copyright \textcopyright  2013 Authors and OPENCORES.ORG
209
 
210
This source file may be used and distributed without
211
restriction provided that this copyright statement is not
212
removed from the file and that any derivative work contains
213
the original copyright notice and the associated disclaimer.
214
 
215
This source file is free software; you can redistribute it
216
and-or modify it under the terms of the GNU Lesser General
217
Public License as published by the Free Software Foundation;
218
either version 2.1 of the License, or (at your option) any
219
later version.
220
 
221
This source is distributed in the hope that it will be
222
useful, but WITHOUT ANY WARRANTY; without even the implied
223
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
224
PURPOSE. See the GNU Lesser General Public License for more
225
details.
226
 
227
You should have received a copy of the GNU Lesser General
228
Public License along with this source; if not, download it
229
from \href{http://www.opencores.org/lgpl.shtml}{http://www.opencores.org/lgpl.shtml}
230
 
231
Xilinx, Spartan3E is registered trademark of Xilinx Inc. 2100 Logic Drive, San Jose CA USA
232
 
233
\newpage
234
 
235
\bibliography{bibliography}
236
 
237
\end{document}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.