Live data from Hacker News

Simple CPU

simplecpu.com

51–60 of 65 posts

Re: Simple CPU

#51

I was attempting to create the most simple infinite loop that I could, and found that the instructions do not work in the way that I thought they would. Here are a couple programs I wrote. If someone could explain why they work the way they do..? 00000011 00000100 00000000 00000001 Looking at this, I expected that it would read line one, then move the value addressed by line two to the value addressed by line three.…

Your first program does as you expect, but then the instruction pointer gets incremented by 3, so it goes on.

If you modify the last line to "11111101" then when the instruction pointer is increased by 3 it will overflow back to 00000001 and you will get your infinite loop.

Re: Simple CPU

#52

I was attempting to create the most simple infinite loop that I could, and found that the instructions do not work in the way that I thought they would. Here are a couple programs I wrote. If someone could explain why they work the way they do..? 00000011 00000100 00000000 00000001 Looking at this, I expected that it would read line one, then move the value addressed by line two to the value addressed by line three.…

The CPU runs the opcode(instruction), then adds 3 to the IP. Therefore, your first program sets IP to 1, then it gets 3 added to it, setting IP to 4. Your second program is exactly the same, but setting IP to 4 means infinite loop.

Re: Simple CPU

#53
post #16

Earlier quoted context omitted.

I'll rant for a moment here, because I think this is something that the Simple CPU link has the potential to get right, and that I think is a common pitfall with digital design tutorials. I think one of the pain points that you commonly see with tutorials is the concept that the hard part is the language. As a digital designer, I think that's explicitly not the case: just like teaching functional programming, the syn…

Yes, the two key hurdles to HDL are (in my opinion): - Being able to think parallel. Software is sequential by default, HDL is parallel by default. - Understanding what you want to build. If you can't draw what you want, you probably can't write good HDL. There's a reason it's called Hardware Description Language , and not "JS2GATES". In a sense, HDL is really just text-based schematics. Case in point: http://www.all…

>Being able to think parallel. Software is sequential by default, HDL is parallel by default.

Totally. When working through the nand2tetris stuff, several of my designs fell on their face because I started thinking of multistep circuit logic as sequential, forgetting that junk results aren't discarded by the "flow" but that their values are always "evaluated" and fed into downstream logic.

Re: Simple CPU

#54

I was attempting to create the most simple infinite loop that I could, and found that the instructions do not work in the way that I thought they would. Here are a couple programs I wrote. If someone could explain why they work the way they do..? 00000011 00000100 00000000 00000001 Looking at this, I expected that it would read line one, then move the value addressed by line two to the value addressed by line three.…

As nothing is moving visually it seems to be doing nothing. 0001: 0000 0010: 0000 0011: 0000 0100: 0000 0101: 0000 0110: 0000 0111: 0011 1000: 1010 1001: 0000 1010: 0001

Re: Simple CPU

#55
post #50

I was attempting to create the most simple infinite loop that I could, and found that the instructions do not work in the way that I thought they would. Here are a couple programs I wrote. If someone could explain why they work the way they do..? 00000011 00000100 00000000 00000001 Looking at this, I expected that it would read line one, then move the value addressed by line two to the value addressed by line three.…

Hi, I made this site. The problem is that it moves that value into the instruction pointer, then the instruction pointer increments itself by 3. the instruction pointer always increments itself by 3 after every instruction.

Thanks all, for the explanations :)

Re: Simple CPU

#56
post #36

Earlier quoted context omitted.

I don't know. I heard about nibbles right at the beginning and then promptly forgot them. I even remember thinking that the word was silly. But it set me up for a very nice epiphany the first time I saw bytes written as hex and played a part in my instantly grasping that.

I'd be curious to poll people's experiences, but, I can say that I had never heard the term until today and I've known this stuff for a number of years. And it sounds silly and adds nothing. That too. (edit: my education on this stuff was in the 00's. Sounds like it was more common in the 80s. I'd definitely support obsoleting the term entirely now, though! It adds unnecessary complexity.)

0b11110000 == 0xF0 So two hexadecimal digits represent a byte. Likewise, one hex digit represents a nibble. I'm much more in favor of deprecating WORD as a synonym for byte

Re: Simple CPU

#57

I thought this was pretty clever: 00000001 A program that doesn't work if you move its location in memory is pretty hilarious.

Just goes to show how good my reading comprehension is. I completely failed to realize that the subtract operation was operand B from operand A, not the other way around.

Re: Simple CPU

#58
post #36

Earlier quoted context omitted.

I'd be curious to poll people's experiences, but, I can say that I had never heard the term until today and I've known this stuff for a number of years. And it sounds silly and adds nothing. That too. (edit: my education on this stuff was in the 00's. Sounds like it was more common in the 80s. I'd definitely support obsoleting the term entirely now, though! It adds unnecessary complexity.)

0b11110000 == 0xF0 So two hexadecimal digits represent a byte. Likewise, one hex digit represents a nibble. I'm much more in favor of deprecating WORD as a synonym for byte

> I'm much more in favor of deprecating WORD as a synonym for byte

Its not a synonym for byte. In modern systems, a word is typically 4 or 8 bytes.

Re: Simple CPU

#59
post #13

I wish they would give us such a summary at the college before talking about all those confusing stuff. Excellent work!

In the third semester at university in Germany there was a course "Introduction to technical computer science", where one would learn about things like Karnaugh Diagrams, compression algorithms, D-Latches and so on and built a 16bit optionally pipelined RISC CPU in lab assignments. The professor teaching the course had developed custom signal processors for the LHC, so that was pretty cool aswell.

Re: Simple CPU

#60
post #33

Earlier quoted context omitted.

This makes it into a bit of a game: https://microcorruption.com/

I tried to sign up, but I got a "Sorry, but this form is no longer accepting submissions." :(

The form comes up now (I had followed it after you replied and got your result, I guess somebody fixed something).
Post reply on HN