Steven Pemberton's Blog.

.Net, F#, C#, Javascript

Let It Snow! - F# Advent 2015

A basic particle system in F# and WPF

This post is part of the fantastic F# advent event. Thanks to Sergey for organising it!

While my post my not be quite as advanced as the others so far, I hope you'll find it as interesting as I did writing it.

For the post, I wanted to do something a bit different and with a slightly more Christmassy (more wintery at least) theme then my usual posts.

What could be better than a snow simulation implemented using a basic particle system?
Well, probably quite a lot, but hey, it does look pretty cool - Especially with the F# logo in the background.

The engine is implemented entirely in F#, in a mostly functional manner, while the UI uses WPF.
WPF might not be a great choice for particle animation, but it is familiar to me and means I can utilise [FSXaml] and [Fsharp.ViewModule] to speed up development.

Here's a sneak peak of where we're heading.

Sequential Logic Emulation with F# - Part 2

This post concludes the work from chapter three of the book 'The Elements of Computing Systems'.
As with the other posts in the series, I have emulated the sequential logic chips defined in the book using F#.

In the previous post I sidetracked from the book in order to investigate what constituted a Data Flip Flop. The result, was a greater understanding of the sequential ordering of combinatorial chips in order to achieve state retention.

From the DFF, we can now look towards building the constructs that the book outlines.
These include:

  • Registers - Starting from simple 1 bit stores
  • RAM chips - In various sizes
  • Counters - Counts sequentially per execution and can be reset or loaded as required

As always, I will outline the representation of these chips using chips from previous stages of the book, but also define a more idiomatic F# approach as well.

Sequential Logic Emulation with F#

This post (and the next) relate to chapter three of the book 'The Elements of Computing Systems' and revolve around emulating sequential logic chips in F#.

Everything in this post can be taken separately from my previous post, however, I do make use of some code/concepts discussed there.

The main goal of chapter three of the book is to create some constructs that can store state.
Starting with registers and building up into RAM arrays.

There are various parts the book skips, relying on the hardware emulator to fill in the gaps.
This required me to do some research and teach myself the basics of the areas not discussed in the book.

This post is dedicated to those areas, my learning outside of the book and how we can emulate simple sequential logic constructs using F#.

Boolean Logic and Arithmetic with F#

So, I've had this book (The Elements of Computing Systems) on my shelf for a good few years and never got round to reading it, yet alone completing the exercises within.

Drawing

Therefore I thought I'd finally read it.
I also decided I would complete the exercises in a different way than suggested in the book. By using F#!

Rather than utilising the Hardware Definition Language and the given emulator as suggested. I will model all of the parts of the computer in F#.

Doing so, I hope to utilise various functional programming techniques, alongside F# specific features to keep the solutions as simple and easy too understand as possible.
Hopefully learning something new on the way.

As I work my way through the book I'll be adding to this series.
I aim to cover one collection of exercises (roughly a chapter) per post, however this initial post will cover two, just to get me going.

The book starts with the building blocks of the CPU, Boolean logic gates. Let's dive straight in.