Skip to main content

Projects I Wish I Had Mental Space For: nand2tetris in an FPGA

I've been working my way through the nand2tetris book, and am at the point where you pull everything together into a working computer. I got distracted and haven't had the chance to come back to it. But I had plans…

Once I'd finished the CPU design I was going to implement it in Verilog for the DE10 nano. The idea was to output the design's screen to a texture that Linux running on the ARM SoC could put into a window. I'd actually started on the Verilog for different components of the system, although that was just to complete the lessons, using someone else's Verilog of the different chips as a base, and improved on their designs. They were using too many gates for their adder, I believe, among other inefficiencies.

I'm a neophyte at FPGA design, but I realized that implementing all the multiplexers and RAM using NAND gates directly was going to under-perform. Not that the design needs the full 50 MHz offered by the board, but it's the principle of the thing. The emulator included with the course materials doesn't even go much faster than single-stepping through the instructions. But the design software for the DE10 nano has building blocks for the lower level components so they're implemented as efficiently as possible for the hardware.

Despite not having completed the project to the point where I'd have it on FPGA, I did learn a lot from what I had been through. There's the basics of designing a CPU and computer, through Verilog, onto learning how to build a Linux system image from scratch. Made me much more comfortable switching my PC to Linux, since it doesn't run Windows 11. Linux is a whole other topic that I can get into, but it's not really relevant here.

Ultimately, the book has you writing a VM that supports a language a bit like Java, since the processor doesn't have a very robust instruction set and needs more support for higher level languages. It's almost purely combinational logic and barely needs a clock for its main operation. Some of the assembly language examples are for things like multiplication by addition. I'm not sure how you'd do bit shifting with the instructions provided. I'll have to look that up. (I looked it up - it's sufficiently complicated that I won't explain it here - assuming I understood it entirely)

So that's where I am with this. Project half-finished, but new things learned. Perfect for the Idea Oubliette! 

Comments

Popular posts from this blog

Losing a loved one, as an atheist

When I was around 11 or 12, I started to question the received wisdom that there was a deity. I came to the conclusion that all signs pointed to no. Do I outright, unequivocally and without reservation deny the existence of such an entity? No. However, I don’t see it as a likely scenario, and until I’m presented with hard evidence, I have enough reason to say that there isn’t. Some people take comfort in their religious beliefs, especially their belief in an afterlife. I have no interest in an afterlife, either for myself of my loved ones. In the past five years I’ve lost both my grandmother and mother, both of whom I loved dearly. No amount of belief in an afterlife would soothe my pain. I mourn at the fact that they are lost from my life, right here, right now. I imagine it’s the same even for those who believe that the dead pass on to somewhere else. You can’t escape the fact that their tangible presence is forever gone from your life. Unless you believe in ghosts, but that’s a ...

Living with Bipolar Disorder

Feeling down when something bad happens is normal. Feeling elated when something good happens is great. Bipolar disorder is neither. Previously referred to as manic depressive disorder, bipolar disorder consists of mood episodes ranging from deep, dark depression to the sense of invincibility and superiority that is characteristic of a manic phase. It disrupts the lives of those who suffer from it and all those around them. Luckily, however, with the right course of treatment it can be kept under control. Bipolar disorder has been found to be linked genetically and physiologically to schizophrenia. A person suffering from bipolar disorder can experience the same sort of hallucinations and delusions as someone with schizophrenia. Both have a genetic component, with a number of genes interacting to create a pre-disposition to these disorders. The families of those afflicted often include others with one of these disorders, mood disorders or alcoholism. Depression is a common symptom ...

Another post

It's been over a week since I've posted here, and I apologize to my loyal readers who have probably all headed to the hills. Twitter has been keeping me distracted, while my bipolar disorder and newly-diagnosed ADHD have left me feeling less than effective. It's hard to push yourself to try to succeed when you feel you've been so far from stellar that bothering with anything is a waste of time. But things are picking up. I'm on new medication, I have great friends, an incredibly supportive wife and a window into new techniques to help keep my problems in check. There's definitely a gleam of hope where a short while ago there was none. I'd love to find employment, but my chosen field of expertise, software development, seems to be yielding little, if any, job prospects in the area. I can always cast out a wider net in my search, since so far I've only looked at Nova Scotia. However New Brunswick and PEI are both a stone's throw away. PEI is apparently...