Changeset 556 for Deliverables
- Timestamp:
- Feb 17, 2011, 2:31:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D4.1/ITP-Paper/itp-2011.tex
r555 r556 306 306 \label{subsect.representing.memory} 307 307 308 The MCS-51 has numerous di fferent types of memory.309 In our prototype implementation, we simply used a map datastructure from the O'Caml standard library.310 Matita's standard library is relatively small, and does not contain a generic map datastructure.311 Therefore, we had the opportunity of crafting a special-purpose datastructure for the job.312 313 We worked under the assumption that large swathes of memory would often be uninitialized. 314 Na\"ively, using a complete binary tree, for instance, would be extremely memory inefficient. 315 Instead, we chose to use a modified form of trie, where paths are represented by bitvectors. 316 As bitvectors were widely used in our implementation already for representing integers, this worked well:308 The MCS-51 has numerous disjoint memory segments addressed by pointers of 309 different sizes. 310 In our prototype implementation, we simply used a map datastructure (from the O'Caml standard library) for each segment. 311 Matita's standard library is relatively small, and does not contain a generic map datastructure. Therefore, we had the opportunity of crafting a dependently typed special-purpose datastructure for the job to enforce the correspondence between the size of pointers and the size of the segment . 312 We also worked under the assumption that large swathes of memory would often be uninitialized, trying to represent them concisely using stubs. 313 314 We picked a modified form of trie of fixed height $h$ where paths are 315 represented by bitvectors of length $h$, that are already used in our 316 implementation for addresses and registers: 317 317 \begin{lstlisting} 318 318 inductive BitVectorTrie (A: Type[0]): nat $\rightarrow$ Type[0] ≝ … … 325 325 Performing a lookup in memory is now straight-forward. 326 326 We merely traverse a path, and if at any point we encounter a \texttt{Stub}, we return a default value\footnote{All manufacturer data sheets that we consulted were silent on the subject of what should be returned if we attempt to access uninitialized memory. We defaulted to simply returning zero, though our \texttt{lookup} function is parametric in this choice. We do not believe that this is an outrageous decision, as SDCC for instance generates code which first `zeroes out' all memory in a preamble before executing the program proper. This is in line with the C standard, which guarantees that all global variables will be zero initialized piecewise.}. 327 As we are using bitvectors, we may make full use of dependent types and ensure that our bitvector paths are of the same length as the height of the tree.328 327 329 328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset
for help on using the changeset viewer.