report4.tex 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. \documentclass[a4paper,12pt]{article}
  2. \usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}
  3. \usepackage[T1]{fontenc}
  4. \usepackage[utf8]{inputenc}
  5. \usepackage{newunicodechar}
  6. \usepackage{lmodern}
  7. \usepackage{textgreek}
  8. \usepackage{amsmath}
  9. \usepackage{mathtools}
  10. \usepackage{graphicx}
  11. \usepackage{pdflscape}
  12. \usepackage{svg}
  13. \usepackage{tabularx}
  14. \usepackage{blindtext}
  15. \usepackage{hyperref}
  16. \usepackage{pgfgantt}
  17. \usepackage{colortbl}
  18. \usepackage{pdfpages}
  19. \usepackage{setspace}
  20. \usepackage{subcaption}
  21. \usepackage{tikz}
  22. \usepackage{chngcntr}
  23. \usepackage{longtable}
  24. \usepackage{xcolor,colortbl}
  25. \usepackage{pdfpages}
  26. %
  27. \counterwithin{figure}{subsection}
  28. \usepackage{multicol}
  29. \setcounter{tocdepth}{3}
  30. \begin{document}
  31. \begin{titlepage}
  32. \newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
  33. \begin{tikzpicture}[remember picture, overlay]
  34. \node [anchor=north east, inner sep=0pt] at (current page.north east)
  35. {\includegraphics[width=21cm]{graphics/ucl-banner-dl-port-outline.eps}};
  36. \end{tikzpicture}\\[3cm]
  37. \center
  38. \textsc{\Large University College London}\\[0.5cm]
  39. \textsc{\large Department of Electronic and Electrical Engineering}\\[0.5cm]
  40. \HRule \\[0.4cm]
  41. \setstretch{1.5}
  42. { \huge \bfseries Project Progress Report No. 4}\\[0.4cm]
  43. \setstretch{1.0}
  44. \HRule \\[1.0cm]
  45. \Large \emph{Author:}\\
  46. Minduagas \textsc{Jarmolovičius}\\
  47. \href{mailto:zceemja@ucl.ac.uk}{zceemja@ucl.ac.uk}\\[0.5cm]
  48. \Large \emph{Supervisor:}\\
  49. Prof. Robert \textsc{Killey}\\
  50. \href{mailto:r.killey@ucl.ac.uk}{r.killey@ucl.ac.uk}
  51. \vfill
  52. {\large February 16, 2020}\\[2cm]
  53. \end{titlepage}
  54. \pagebreak
  55. \section{Progress}
  56. \subsection{Completed OISC implementation}
  57. In this section brief OISC implementation will be described.
  58. OISC machine code is stored in 13bits instructions that compose 1 bit that indicates if source is immediate value, 4 bits for destination address, 8 bits for source address or immediate value. This been shown in diagram below:
  59. \definecolor{c1}{HTML}{ff7568}
  60. \definecolor{c2}{HTML}{8cbfff}
  61. \definecolor{c3}{HTML}{a6ddb7}
  62. \begin{gather*}
  63. \scalebox{0.8}{bit index:}
  64. \underbrace{\colorbox{c1}{0}}_\text{imm.}
  65. \underbrace{
  66. \colorbox{c2}{1}\,
  67. \colorbox{c2}{2}\,
  68. \colorbox{c2}{3}\,
  69. \colorbox{c2}{4}\,
  70. }_\text{destination}
  71. \underbrace{
  72. \colorbox{c3}{5}\,
  73. \colorbox{c3}{6}\,
  74. \colorbox{c3}{7}\,
  75. \colorbox{c3}{8}\,
  76. \colorbox{c3}{9}\,
  77. \colorbox{c3}{10}\,
  78. \colorbox{c3}{11}\,
  79. \colorbox{c3}{12}
  80. }_\text{source}
  81. \end{gather*}
  82. Such design been chosen to match RISC's small instructions design. Tables \ref{table:oisc_dst_instr} and \ref{table:oisc_src_instr} describes currently implemented OISC source and destination addresses.
  83. \arrayrulecolor{black}
  84. \begin{longtable}[h!]{| l | p{.85\textwidth} | }
  85. \hline
  86. \rowcolor[rgb]{0.82,0.82,0.82}
  87. Name & Description \\\hline
  88. \endhead
  89. \endfoot
  90. ALU0 & Store value in ALU input A register\\\hline
  91. ALU1 & Store value in ALU input B register\\\hline
  92. BRPT0 & Store value in branch pointer lower byte register\\\hline
  93. BRPT1 & Store value in branch pointer higher byte register\\\hline
  94. BRZ & Set program counter to branch pointer if value is 0x00\\\hline
  95. STACK & Push value to stack\\\hline
  96. MEMPT0 & Store value in memory pointer lower byte register\\\hline
  97. MEMPT1 & Store value in memory pointer middle byte register\\\hline
  98. MEMPT2 & Store value in memory pointer higher byte register\\\hline
  99. MEMHI & Store higher byte in memory at address stored in memory pointer\\\hline
  100. MEMLO & Store lower byte in memory at address stored in memory pointer\\\hline
  101. COMA & Store value to communication block address register\\\hline
  102. COMD & Send instruction to communication block with address specified in COMA and data as a source\\\hline
  103. REG0 & Store value in general purpose register 0\\\hline
  104. REG1 & Store value in general purpose register 1\\\hline
  105. \caption{Destination registers for OISC processor.}
  106. \label{table:oisc_dst_instr}
  107. \end{longtable}
  108. \arrayrulecolor{black}
  109. \begin{longtable}[h!]{| l | p{.90\textwidth} | }
  110. \hline
  111. \rowcolor[rgb]{0.82,0.82,0.82}
  112. Name & Description \\\hline
  113. \endhead
  114. \endfoot
  115. NULL & Always returns 0x00\\\hline
  116. ALU0 & Returns value stored in ALU input A register\\\hline
  117. ALU1 & Returns value stored in ALU input B register\\\hline
  118. ADD & Returns ALU input A added with input B\\\hline
  119. ADC & Returns ALU input A added with input B with carry from previous time ADD or ADC been used\\\hline
  120. ADDC & Returns carry bit from previous time ADD or ADC was used\\\hline
  121. SUB & Returns ALU input A subtracted input B\\\hline
  122. SBC & Returns ALU input A subtracted input B with carry from previous time SUB or SBC been used\\\hline
  123. SUBC & Returns carry bit from previous time SUB or SBC source was use\\\hline
  124. AND & Returns ALU input A AND gated with input B\\\hline
  125. OR & Returns ALU input A OR gated with input B\\\hline
  126. XOR & Returns ALU input A XOR gated with input B\\\hline
  127. SLL & Returns ALU input A shifted left by input B (only least significant 3bits)\\\hline
  128. SRL & Returns ALU input A shifted right by input B (only least significant 3bits)\\\hline
  129. ROL & Returns rolled off "reminder" from last time SLL was used\\\hline
  130. ROR & Returns rolled off "reminder" from last time SRL was used\\\hline
  131. EQ & Returns 0x01 if ALU input A is equals to input B, otherwise returns 0x00\\\hline
  132. NE & Returns 0x01 if ALU input A is not equals to input B, otherwise returns 0x00\\\hline
  133. LT & Returns 0x01 if ALU input A is less than input B, otherwise returns 0x00\\\hline
  134. GT & Returns 0x01 if ALU input A is greater than input B, otherwise returns 0x00\\\hline
  135. LE & Returns 0x01 if ALU input A is less or equal to input B, otherwise returns 0x00\\\hline
  136. GE & Returns 0x01 if ALU input A is greater or equal to input B, otherwise returns 0x00\\\hline
  137. MULLO& Returns ALU input A multiplied with input B, lower byte\\\hline
  138. MULHI& Returns ALU input A multiplied with input B, higher byte\\\hline
  139. DIV & Returns ALU input A divided by input B\\\hline
  140. MOD & Returns ALU input A modulus of input B\\\hline
  141. BRPT0& Returns value stored in branch pointer lower byte register\\\hline
  142. BRPT1& Returns value stored in branch pointer higher byte register\\\hline
  143. PC0 & Returns program counter + 1, lower byte\\\hline
  144. PC1 & Returns program counter + 1, higher byte\\\hline
  145. MEMPT0 & Returns value stored in memory pointer lower byte register \\\hline
  146. MEMPT1 & Returns value stored in memory pointer middle byte register \\\hline
  147. MEMPT2 & Returns value stored in memory pointer higher byte register \\\hline
  148. MEMLO & Returns lower byte from memory at memory pointer address \\\hline
  149. MEMHI & Returns higher byte from memory at memory pointer address \\\hline
  150. STACK & Pop value from stack\\\hline
  151. STPT0 & Returns stack pointer lower byte\\\hline
  152. STPT1 & Returns stack pointer higher byte\\\hline
  153. COMA & Returns value stored in communication block address register\\\hline
  154. COMD & Requests and returns value from communication block\\\hline
  155. REG0 & Returns value stored in general purpose register 0\\\hline
  156. REG1 & Returns value stored in general purpose register 1\\\hline
  157. \caption{Source registers for OISC processor.}
  158. \label{table:oisc_src_instr}
  159. \end{longtable}
  160. \subsection{OISC Benchmark}
  161. Following functions have written in assembly for OISC:
  162. \begin{description}
  163. \item[$\bullet$] \texttt{print\_char}: writes byte to terminal.
  164. \item[$\bullet$] \texttt{read\_char}: reads byte from terminal.
  165. \item[$\bullet$] \texttt{print\_bin}: prints 8bit value as binary to terminal.
  166. \item[$\bullet$] \texttt{print\_hex}: prints 8bit value as hexadecimal to terminal.
  167. \item[$\bullet$] \texttt{print\_u8}: prints unsigned 8bit value as digit to terminal.
  168. \item[$\bullet$] \texttt{print\_u16}: prints unsigned 16bit value as digit to terminal.
  169. \item[$\bullet$] \texttt{print\_string}: prints string (until 0x00 is reached)from memory to terminal.
  170. \item[$\bullet$] \texttt{mul\_u16}: Multiply 16bit numbers to produce 32bit result. Seems like easier to implement than in RISC due to possibility to use \texttt{MEMLO}/\texttt{MEMHI} instructions as general purpose registers.
  171. \item[$\bullet$] \texttt{mod\_u16}: Uses Russian Peasant multiplication to calculate 16bit modulus
  172. \item[$\bullet$] \texttt{calc\_sieve}: Uses Sieve of Atkin algorithm to populate memory and mark prime numbers from 5 to 255 (up to 8bits), 16bit calculation is already started. A more memory efficient code was written comparing to RISC, it packs every number as 1bit instead of 1 memory cell (16bits)
  173. \end{description}
  174. \subsection{Improved assembler}
  175. Two new features have been added to assembler (which applies for both RISC and OISC)
  176. \subsubsection{Macros}
  177. Operators \texttt{\%macro} and \texttt{\%endmacro} allows to define code that can be reused multiple times.
  178. \subsubsection{Definitions}
  179. Operator \texttt{\%def} allows to define a variable name under local scope (inside function) so assembly code would be easier to read. Example:
  180. \\\\
  181. \texttt{
  182. function\_label: \quad; function name\\
  183. \%def \$x,REG0 \qquad; define REG0 as \$x\\
  184. \$x 10 \qquad\qquad; set REG0 to decimal 10 \\
  185. }
  186. \section{Difficulties encountered}
  187. Multiple difficulties has been encountered:
  188. \subsection{Timing}
  189. There were multiple timing issues between source/destination latches/registers and common data bus. These issues were difficult to remove because initially ModelSim was running into cycling loop which did not allowed to proceed with simulation and locate issue.
  190. Secondly when this was resolved and simulation worked, synthesised code on FPGA did not work causing some issues when moving data from ALU calculated location back to ALU register. This been temporary resolved by adding negative edge sensitive flip-flop to ALU inputs which results is reducing time for combinational logic to settle by two.
  191. \subsection{Memory instructions}
  192. While writing benchmark programs another issue has been discovered - memory instructions (read to/write from memory and push to/pop from stack) cannot be used in single instruction e.g.: \\\\
  193. \texttt{
  194. MEMP 0x0000 \quad; macro to set memory pointer\\
  195. MEMHI 0xFF \quad; write immediate to memory high byte \\
  196. STACK MEMHI \quad; push memory high byte to stack \\
  197. }
  198. This will result in unexpected result as instruction tries to read and write from memory at the same time with two different addresses, therefore it can potentially store data to a unknown address. Current work-around is to avoid such instruction combination by storing value to a temporary register. This usually does not cause extra instructions as in most cases values from memory/stack are required and stored in temporary registers anyway.
  199. \subsection{ROM memory}
  200. Initial implementation of OISC stored instruction in 16bit, 2048 word configuration using M9K memory. As this was inefficient recently a decision was made to implement this using 3 M9K memory blocks with 2 instructions sliced into 3 - 9bits slices and stored in each memory block (extra bit is kept as parity check). This been successfully implemented in SystemVerilog and tested with ModelSim but still does not work with FPGA.
  201. One of the problems is representation of non-integer byte sizes and multiple file formats used for each case - ModelSim uses \texttt{\$readmemh} or \texttt{\$readmemb} functions that reads file with raw binary or hexadecimal numbers; Quartus uses "mif" format which is quite well documented and already implemented; writing into ROM without resynthesising HDL requires reversed hexadecimal format, however it is not documented how it has to be represented when memory width is not an integer byte.
  202. Furthermore probes might be implemented to record internal processor registers by using Quartus "In-System Sources and Probes" feature. This would allow quickly debug programs and find out any other problems related to processor.
  203. \section{Failure Risk Assessment}
  204. There are no updates on failure risk assessment.
  205. \section{Updated Safety Risk Assessment}
  206. There are no updates on safety risk assessment.
  207. \section{Help and Advice Needed}
  208. At this state no help is needed, and any issues and advices are sorted out and discussed in weekly supervisor meetings.
  209. \newpage
  210. \begin{landscape}
  211. \section{Updated Schedule}
  212. Table below includes project schedule. Note that a new objective has been added - \textbf{benchmarking}. This includes developing adequate methods to test and to performs these tests in order to evaluate performance of both processors on various tasks, such as time taking to execute a task, memory usage, power consumption etc.
  213. \begin{table}[h!]
  214. \centering
  215. \begin{ganttchart}[
  216. y unit title=0.4cm,
  217. y unit chart=0.5cm,
  218. x unit=1.1mm,
  219. hgrid,
  220. today=2020-02-16,
  221. today label node/.append style={below=12pt},
  222. today label font=\itshape\color{blue},
  223. today rule/.style={draw=blue, ultra thick},
  224. title height=1,
  225. bar/.append style={fill=blue!50},
  226. bar incomplete/.append style={fill=gray!50},
  227. progress label text={$\displaystyle{#1\%}$},
  228. time slot format=isodate
  229. ]{2019-10-01}{2020-03-31}
  230. \gantttitlecalendar{year, month=shortname} \\
  231. \gantttitle{40}{6}
  232. \gantttitlelist{41,...,52}{7}
  233. \gantttitlelist{1,...,13}{7}
  234. \gantttitle{}{2} \\
  235. \ganttbar[progress=100]{RISC implementation}{2019-10-01}{2019-10-27}\\
  236. \ganttbar[progress=95]{RISC Optimisations}{2019-10-27}{2019-11-25}\\
  237. \ganttbar[progress=100]{UART and I/O}{2019-10-21}{2019-10-27}
  238. \ganttbar[progress=100]{}{2019-11-25}{2019-12-08} \\
  239. \ganttbar[progress=100]{RISC Assembler}{2019-10-14}{2019-11-11}\\
  240. \ganttbar[progress=80]{Developing benchmark}{2019-11-11}{2019-12-13}
  241. \ganttbar[progress=50]{}{2020-02-23}{2020-03-07} \\
  242. \ganttbar[progress=100]{OISC Implementation}{2019-12-02}{2019-12-13}
  243. \ganttbar[progress=100]{}{2020-01-13}{2020-02-02}\\
  244. \ganttbar[progress=90]{OISC Optimisations}{2020-02-02}{2020-02-23}\\
  245. \ganttbar[progress=100]{OISC Assembler}{2020-01-20}{2020-02-09}\\
  246. \ganttbar[progress=0]{Benchmarking}{2020-02-17}{2020-03-22}\\
  247. \ganttmilestone{Project Proposal finalised}{2019-10-14}\\
  248. \ganttmilestone{Progress Report \#1}{2019-11-04}\\
  249. \ganttmilestone{Progress Report \#2}{2019-11-25}\\
  250. \ganttmilestone{December Interim Report}{2019-12-13}\\
  251. \ganttmilestone{Progress Report \#3}{2020-01-20}\\
  252. \ganttmilestone{Progress Report \#4}{2020-02-14}\\
  253. \ganttmilestone{Progress Report \#5}{2020-03-02}\\
  254. \ganttmilestone{Poster Presentation}{2020-03-18}\\
  255. \ganttmilestone{Final Report}{2020-03-30}
  256. \ganttvrule{Reading Week}{2019-11-03}
  257. \ganttvrule{}{2019-11-10}
  258. \ganttvrule[vrule label node/.append style={anchor=north west}]{Holidays}{2019-12-13}
  259. \ganttvrule{}{2020-01-12}
  260. \ganttvrule{Reading Week}{2020-02-17}
  261. \ganttvrule{}{2020-02-23}
  262. \end{ganttchart}
  263. \caption{Updated project schedule Grantt chart}
  264. \label{table:time}
  265. \end{table}
  266. \end{landscape}
  267. \end{document}