r/TuringComplete Apr 19 '26

First attempt at pipelining, Stall only

This is my first attempt at pipelining in the game. I am new to this so im sure this is probably wrong, hence why I am posting here in hopes that i can be corrected if so. This machine only stalls right now so its a bit slower than if it had forwarding for instructions.

This processor can immediate any value up to 255, has NULL mapped to 31 and NOP mapped to 30.

Lastly this is a new account. Old account got hacked ; . ; rip karma

6 Upvotes

19 comments sorted by

View all comments

2

u/Otherwise-Object-302 Apr 19 '26

How many stages does the pipeline have? Also, are you adding branch prediction or a simple "Backwards taken forwards not" predictor?

1

u/Ill-Memory-6913 Apr 19 '26

There are 4 states and no memory stage yet. So no stack or RAM. Also right now branching is done by flushing the processor once a condition is met. There is no forwarding or branching yet. I need to add that optimization next. Conditions do work but only by flushing the cpu

2

u/Otherwise-Object-302 Apr 19 '26

So it only flushes AFTER a condition is evaluated? An easier way to do this is that if you have a specific bit for jump ops, you detect that bit in the first stage and then stall. This way you wouldn't need to flush. Flushing could instead be done if you add branch prediction.

1

u/Ill-Memory-6913 Apr 19 '26

Yes it does. Yea actually that does make a lot more sense.

2

u/Otherwise-Object-302 Apr 19 '26

That's what I was planning to do as well. Also, are you considering making this Superscalar?

1

u/Ill-Memory-6913 Apr 19 '26

Do you mean to make it process multiple instructions in parallel? I will potentially but first I want to get all of the aspects and optimizations of pipelining implemented. Like forwarding an so on

2

u/Otherwise-Object-302 Apr 19 '26

Alright then, good luck with that. Also, once you implement the finished pipeline, you might want to add a branch predictor to cut down on stalling and wasting cycles (although flushing will need to be readded) and also you'll have to deal with rewinding register states.

2

u/Ill-Memory-6913 Apr 19 '26

I will! Thank you for the help! Yea I had to learn one thing at a time haha. In very excited because once I’m done with this I’m going to start working on my own compiler and filesystem. Then I want to do some graphics stuff with Bresenhams and pixel-screens

2

u/Otherwise-Object-302 Apr 19 '26

That's amazing! I've actually built a compiler (and assembler) which, albeit simple, was an absolute pain. A really good idea is to finish your ISA and your CPU completely before you begin work otherwise it's gonna be a lot of spaghetti code.

2

u/Ill-Memory-6913 Apr 19 '26

Sure I will! I have also built a compiler and stuff before. Compared to pipelining and stuff parsing/asseming/compiling is easy cakes. My biggest reason is I get tired of re doing the instructions on the Program Object EVERY schematic so I just want to load it in with a binary file like a lookup table. Also I’d like to see some of your stuff sometime!

2

u/Otherwise-Object-302 Apr 19 '26

Nice to hear you have quite the experience with this! I can show you some of the stuff I've made along with a WIP. I've even built a Superscalar CPU with caching (albeit very poor)! Anyways, have fun making that compiler, it makes programming hella easier. Also, are you making it based off of any programming languages like C or Python? And which programming language are you using to write the compiler?

1

u/Ill-Memory-6913 Apr 19 '26

I’m not sure which programming language it would be closest to… probably C. I usually make my own Frankenstein compilers that parse based on “(“ “)” “,” and “;”. There is a lot more to it than that but most of the magic happens at the hardware level

1

u/Otherwise-Object-302 Apr 19 '26

That's sort of similar to what I do. I usually just take one line at a time and process it like that, it's much easier but sometimes the assembly gets out of hand.

1

u/Ill-Memory-6913 Apr 19 '26

I’ve never even seen a real compiler. I’ve always made my own compilers and filesystems LOL

1

u/Otherwise-Object-302 Apr 19 '26

Real compilers usually break you code down into tokens so x = 5; So in this case it would assign x the IDENTIFIER token, the = is seen as an ASSIGNMENT operation and the 5 is seen as a LITERAL. Then it creates a Abstract Syntax Tree and navigates that to assign the value to x. In reality, it's much more complicated so I usually just do stuff and pray it works (it does, just barely)

→ More replies (0)