CPU Fetch Decode Execute simulator for OCR A Level

CPUs work by following the fetch decode execute cycle.

Von Neumann CPU Simulator showing the fetch decode execute cycle
Von Neumann CPU Simulator showing the fetch decode execute cycle

At Key Stage 3, students in the UK need to have a good idea of the process as a whole:

The fetch decode execute cycle is the loop that CPUs constantly follow in order to get, understand and do each instruction in a program.

At Key Stage 3, students need to understand the role of different parts of a CPU in the Von Neumann model.

A Von Neumann CPU has one memory store (RAM) which stores both data (variables) and instructions (program code).

Registers are fast but small memory locations that can store one item of data or one instruction.

The Little Man Computer model is popular at both Key Stage 3 and Key Stage 4 because it simplifies what happens inside a CPU down to just three registers: an instruction register, an accumulator and a program counter with a very limited instruction set.

For A Level, some additional components have to be understood which makes the Little Man Computer model appear too limited to be used to explain all of the necessary theory. Students also need to be able to explain the purpose and function of:

  • The Memory Address Register (MAR) and Memory Data Register (MDR)
  • The Address Bus, The Control Bus and the Data Bus.

To help fill those gaps, I’ve built a CPU simulator based on the diagram shown in the Craig’n’Dave video below:

The simulator lets you enter in any values into the memory store (as binary, denary or hex) and then either run the whole code or step through each stage in the fetch decode execute cycle.

You can try the simulator here or download the source here.

This tool is designed as a teaching aid to allow teachers and students to step through each line in a binary computer program with an explanation of what each register and bus is doing at every stage.

I hope it’s useful. Let me know if you spot any mistakes or ideas for improvement.

Continue ReadingCPU Fetch Decode Execute simulator for OCR A Level

Pseudocode, Python, VB.NET Quick Reference for GCSE Computer Science

Pseudocode, Python, VB.NET Quick Reference
Pseudocode, Python, VB.NET Quick Reference

To help staff and students quickly find useful code snippets in VB.NET, Python or pseudocode (for GCSE Computer Science with OCR, AQA, Edexcel or Eduqas) I’ve been putting together this website.

It aims to be a pseudocode, Python, VB.NET quick reference guide so you can quickly find definitions of key terms, a simple explanation of how key programming concepts work alongside code snippets that you can adapt and re-use as you learn.

VB.NET and Python are both programming languages designed to be understood and followed by computers. Pseudocode is not a programming language: it’s written to be understood by humans so that they can turn it into any programming language.

In the UK, each exam board has published a document saying how they’ll use pseudocode to describe algorithms in their exams. The whole idea of syntax (a set of rules) for pseudocode is silly – it’s not designed to be a programming language that is run by a computer. With this in mind, all exam boards state that you don’t have to follow the syntax for ‘their’ version of pseudocode when you write out your own algorithms, but you should be able to understand their version of pseudocode when reading an algorithm in an exam.

The idea is to give a really quick at-a-glance guide to explain some of the key concepts of programming that you need for GCSE Computer Science, alongside code snippets in Python and / or VB.NET as well as pseudocode for whichever exam board your school is using.

This searchable reference guide is designed for teachers and students preparing either for a Non-Examined-Assessment (NEA) or revising for a theory exam.

Please note:

Students are not allowed to access the Internet and are not allowed to have access to code snippets matched to pseudocode like this during their actual NEA sessions. This resource is designed for students to access for support outside of those NEA sessions.

Code snippets are split into 8 categories:

I hope they’re useful. Let me know if you spot a mistake or think of something that’s missing that you’d find useful.

Continue ReadingPseudocode, Python, VB.NET Quick Reference for GCSE Computer Science
Create.withcode.uk python wordpress plugin
Create.withcode.uk python wordpress plugin

Python wordpress plugin: easily embed and run python code in your website

Create.withcode.uk python wordpress plugin
Create.withcode.uk python wordpress plugin

Create.withcode.uk is designed to allow anyone to write, run, debug and share python code that runs in your browser. It’s designed primarily for use in schools to allow teachers to quickly share code with students that they can adapt, debug and use.

Here’s an example python program that asks you for your name then says hello. Press Ctrl + Enter (or click on the green plus at the bottom of the code screen) to run the code.

When you save some python code on create.withcode.uk (press Ctrl+S or click on the share button) you get an option to copy and paste some HTML code that can be embedded into any website. e.g:

<iframe frameborder="0" width="100%" height="400px" src="https://create.withcode.uk/embed/7A"><a target="_blank" href="https://create.withcode.uk/python/7A">create.withcode.uk</a></iframe>

To make it even easier to embed your python projects into your blog or website, I’ve shared a plugin for wordpress that lets you quickly add python code using a wordpress shortcode.

This makes sharing your python projects much simpler:

  1. Write your code on create.withcode.uk

    You don’t need an account – just type in your python code into the browser & test it with either Ctrl + Enter  to run the whole project or Ctrl + .  to run it one line at a time

  2. Save your code

    Press Ctrl + S  or click on the share button. This make your code available to anyone with the link.

    Share your code

    The URL will be something like https://create.withcode.uk/python/ra

    Note the letters and numbers at the end of the URL (ra  in the above example)

    Find the ID

  3. Add your code to any post or page in your wordpress blog using a shortcode:

    Use a shortcode that contains the letters and numbers from the previous step:

    Add a shortcode
    This will display the python source code in your blog page or post. People viewing your website will be able to view, run and debug your code.

  4. If you want your code to run by default rather than show the source code:

    Adapt the shortcode to change the mode to “run”:

    Shortcode to run

Wordpress python plugin
Python wordpress plugin

Click here to download the wordpress plugin or to find out more.

Like create.withcode.uk, the wordpress plugin is free and open source.


Continue ReadingPython wordpress plugin: easily embed and run python code in your website