Report: Cache Simulation

The second assignment in my computer systems course was probably the one I most enjoyed this year. It was challenging but I learned a lot and had fun working with the large data trace. I scored 95%. Below are some excerpts from the handout and my solution.


“The aim of this assignment is to write a parameterized cache simulator that reads a memory address trace and provides statistics about cache accesses and hits. The simulator is to be written in C…

…Assume the following specifications in designing the cache simulator:

Fixed parameters:
The following parameters always stay the same:
(i) Memory addresses are 32 bits
(ii) Cache Organization: Unified (data and instruction cache blocks are kept in the same cache)

Variable parameters: The following parameters are passed as command-line arguments to the cache simulator:
(i) Cache Size: 256B to 8KB; powers of 2 only
(ii) Cache Block Size: 16, 32, 64, 128, or 256 bytes
(iii) Cache Mapping: Direct Mapped or Fully Associative
(iv) Cache Replacement Policy if Fully Associative Mapping: FIFO or LRU

For example, if the command-line parameters specify following options: Cache size: 2KB, Block Size: 64B, Cache Mapping: Direct Mapped then the cache will have the following properties:
Parameters                                      Values
Cache Mapping                         Direct Mapped
Replacement Policy                Not Applicable
Cache Size                                  2KB
Block Size                                    64B
Number of blocks                    32 (2KB/64B)
Num bits for block offset       6 (64B block)
Num bits for index                   5 (32 blocks)
Num bits for tag                        21 (32-6-5)

…The memory trace file consists of a sequence of memory accesses and it is an input to the cache simulator. For each memory access the trace file provides: a) whether it is an instruction or data access and b) 32-bit memory address in hex. The addresses in trace file are byte addresses and not the block addresses. An example of the trace file is as follows:

I 8cda3fa8
I 8158bf94
D 8cd94c50
I 8cd94d64
D 8cd94c54

For your convenience the output of the program is already provided in print_statistics(…) function. You need to populate the parameters of the function with appropriate values. Following is the full list of all variables you need to populate.
1. num_blocks: total number of blocks in a cache
2. num_bits_for_block_offset: number of bits required to access offset within a block
3. num_bits_for_index: number of bits required to represent an index
4. num_bits_for_tag: number of bits required for tag
5. result.instruction_accesses: total number of cache accesses made by instructions
6. result.instruction_hits: total number of hits incurred for instruction accesses
7. result.data_accesses: total number of cache accesses made by data
8. result.data_hits: total number of hits incurred for data accesses 

Summary: In this assignment, you are required to write a cache simulator which reads a trace of memory references and reports cache statistics. The cache configuration is determined by parameters that are passed as command line arguments. Following parameters may be changed via command line parameters. cache size, block size, cache mapping, replacement policy if fully associative cache.”


Due to University regulations code is only available on request, if you’re interested please contact me:


Report: A Natural Language Query System in Python/NLTK

In my second semester as part of my Processing Formal and Natural Languages course I had to complete two assignments. One realted to formal languages and one related to natural lanuages. This report covers the second, in which I scored 92%.


In this assignment, you will use Python and NLTK to construct a system that reads simple facts and then answers questions about them. You can think of it as a simple form of both machine reading and question answering.

Your completed system will enable dialogues such as the following:

$$ John is a duck.
$$ Mary is a duck.
$$ John is purple.
$$ Mary flies.
$$ John likes Mary.
$$ Who is a duck?
John  Mary
$$ Who likes a duck who flies?

$$ Which purple ducks fly?

Sentences submitted by the user are either statements or questions. Statements have a very simple form, but the system uses them to learn what words are in the language and what parts of speech they have. (For example, from the statements above, the system learns that duck is a noun, fly is an intransitive verb and so on.) Questions can have a much more complex form, but can only use words and names that the system has already learned from the statements it has seen.
In Part A, you will develop the machinery for processing statements. This will include a simple data structure for storing the words encountered (a lexicon), and another for storing the content of the statements (a fact base). You will also write some code to extract a verb stem from its 3rd person singular form (e.g. flies → fly).
Parts B to D develop the machinery for questions. Part B is concerned with part-of-speech tagging of questions, allowing for ambiguity and also taking account of singular and plural forms for nouns and verbs. In Part C you are given a context free grammar for the question language, along with a parser, courtesy of NLTK. Your task is to write some Python code that does agreement checking on the resulting parse trees, in order to recognize that e.g. Which ducks flies? is ungrammatical. Agreement checking is used in the system to eliminate certain impossible parse trees. In Part D, you will give a semantics for questions, in the form of a Python function that translates them into lambda expressions. These lambda expressions are then processed by NLTK to transform them into logical formulae; the answer to the question is then computed by a back-end model checker which is provided for you.
Finally, in Part E, you are invited to supply a short comment on ways in which the resulting system might be improved.



Due to University regulations my code is only available on request, so if you’re interested at all please contact me:

Scrape by

Scraped a few sites with python and successfully managed to get that information onto my map.

Heres Alfie himself, he went missing with two other female Yorkshire Terriers – who have since been found in the Radford area of Nottingham. Alfie is sadly still missing.

There is still some work to be done here on top of the lack of images, either Nimbus is very lost or my geocoding is off: