combinator computer MK2

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: combinator computer MK2

Post by piriform »

It's probably a godsend for somebody making a full-blown CPU.
Or a train scheduler :) Thanks for the tip
User avatar
Gertibrumm
Fast Inserter
Fast Inserter
Posts: 162
Joined: Fri Jun 03, 2016 6:54 pm
Contact:

Re: combinator computer MK2

Post by Gertibrumm »

piriform wrote: Not sure I understand, do you store more than one signal per memory cell?
well I store all of them that way I can store huge lists and even instructions! I was using each>0 deciders until now, that way I can filter unwanted signals and remove the need for one extra decider
well I probably havnt thought about this problem well enough to give any meaningfull opinions.
though you have a point with the clear=0 memory as it might be good for storing negative values.
also I was just thinking about double bus, well instructor is fast enough, memory cant keep up.
but until I havnt drawn a out all the signals on paper, no more views from my side, my cpu is lacking good timing :)
until then
piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

What else? MK4 with NIST and cough..pipes?

Post by piriform »

For the past couple of months, I've been working on/off on a new version of CPU (i.e. MK4). Even though it's not ready for general release as it needs more testing, I'd thought to show what I have for comments (good or bad).
MK4markup.GIF
MK4markup.GIF (370.58 KiB) Viewed 8038 times

Description
Boxes outline different functional areas
white- PC (ish)
brown- X,S,Y,Z registers (X on a top)
blue – read/write assists
green –pipeline ahem. spine
red - arithmetic unit (i.e. +,-,*,/)
teal - accumulator and buffer
yellow- branch logic
the two stacks peeking from the bottom are ROM and RAM

more description and discussion

EDIT
----------------------------------------------------------------------------------------

A video going over MK4 architecture and showing MK4 it in action is available on youtube
https://youtu.be/X2DETxFWTMc

A google sheet containing more detailed description (signals, architecture etc) and a program listing can be found here. I realize that I'm not the nearly the best programmer, so any 'constructive' comments would be more than welcome.
https://docs.google.com/spreadsheets/d/ ... sp=sharing
------------------------------------------------------------------------------------------------------
EDIT 2

Here's the blueprint string (thanks to Foreman)
mk4.txt
(13.78 KiB) Downloaded 225 times


And here's a close up of the start/stop controls
mk4controls.gif
mk4controls.gif (262.57 KiB) Viewed 7908 times
To start the program (re)activate the Start constant combinator. Normally it contains I1 which will start at address 1. If you reaaaally want to single step you can also start at some other address. (Just change the I value).
To stop the program activate the Stop constant combinator, this will place a negative address on the instruction bus and stop the execution. Before restarting, you must deactivate Stop combinator.
Have fun and if you have any questions please ask.
Last edited by piriform on Tue Sep 06, 2016 4:03 pm, edited 2 times in total.
XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: What else? MK4 with NIST and cough..pipes?

Post by XKnight »

piriform wrote:For the past couple of months, I've been working on/off on a new version of CPU (i.e. MK4). Even though it's not ready for general release as it needs more testing, I'd thought to show what I have for comments (good or bad).
MK4markup.GIF

Description
Boxes outline different functional areas
white- PC (ish)
brown- X,S,Y,Z registers (X on a top)
blue – read/write assists
green –pipeline ahem. spine
red - arithmetic unit (i.e. +,-,*,/)
teal - accumulator and buffer
yellow- branch logic
the two stacks peeking from the bottom are ROM and RAM

more description and discussion
Branch in 7 ticks? do you eat those ticks on the breakfast or you are using them to mine bitcoins?
But seriously, branch instruction should be 2 or 3 (in the worst case) ticks long, and the second tick you can use for unconditional instruction.
Instruction merging = good to know that you are using this.
Main execution cycle should be 1 tick long = this is must have.
As for me, futher improvements is extending alu to be able process up to 150 different instructions per tick, and adding special commands that may be unrolled in several simpler commands (example: array processing by 10 cells per tick). But these new instructions won't be able to fully load new alu, so you should go into paralelization direction (here you may lost several ticks in main execution cycle).
piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: combinator computer MK2

Post by piriform »

do you eat those ticks on the breakfast
Gaah! I would not eat them even on top of the steak. (well maybe..on a bet..if I was really drunk) :lol:
Seriously though, the issue is this
read memory from register takes 2 ticks
AU takes 2 ticks to compute the new result
Branch logic another 2 ticks to compute branch address
and on the 7th tick the new instruction is addressed
In the meantime instructions are marching forth 1x1 every 2 ticks, but if branching the successors must be halted until branch figures out the result
extending alu to be able process up to 150 different instructions per tick,
Sounds pretty awesome. Can't wait to see it cook. Are you planning an action video.
Main execution cycle should be 1 tick long = this is must have.
But I'm afraid of breaking my (beloved) registers :roll: I guess you were not impressed by my CISC/RISC example :(
example: array processing by 10 cells per tick
That seems like a popular theme. I've seen at least one example of that.
I've been noodling something related, only more of a peripheral (or pre=processor)
Consider:
F=(S ? N) where S is a set of input signals and N a set of control values associated with each signal
An arbitrary expression could be constructed from several of these, e.g. F1 & F2 ! F3 or (F1!F2)&(F3!F4) (currently not sure what form would be most optimal).
A Moore-Mealy type of machine might even be possible, in which case you'd end up with a generic sequencer that could deal with hundreds of signals very very quickly.
Perfect for factory control. (except programming would be a real PITA).
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: What else? MK4 with NIST and cough..pipes?

Post by siggboy »

XKnight wrote:Branch in 7 ticks? do you eat those ticks on the breakfast
Main execution cycle should be 1 tick long = this is must have.
Normally this would be the point where you accept a self posed "challenge" and publish your own CPU that fixes all those issues.

Too much work? Too difficult? 8-)

Regarding the CPU: I love it, don't let XKnight spoil the fun. Personally I'd prefer to have a good general purpose setup, that is not too difficult to program. Even if you can make some specialized functions, like having extreme paralellism for certain instructions, that is only interesting if those are useful in the general case.

E.g. encryption primitives would be impressive and also utterly useless. Something that allows efficient polling of data points, or replacing the polling with something better would be great (that's something that you need if you control a factory or trains).

Interrupts (and a sane way to use them) are still a must have, it's difficult to make anything useful without them unless you resort to excessive polling or custom hardware. Polling is way too expensive with only 20 IPS.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: combinator computer MK2

Post by piriform »

Regarding the CPU: I love it, don't let XKnight spoil the fun
Thanks for the kind words and no worries. I don't consider XKnight's comments discouraging. If anything, I think he is trying to encourage others, as am I. We just have a different approach.

Re Interrupts, but of course. IRQ will be part of MK4! Right after the demo.

Re generality vs special instructions. I think you've put the finger on the exact issue I've been struggling with for some time now.
It's fairly easy to design a "Sweet-16" style of CPU that is complete and fast. Where I struggle (not being an expert ) is deciding what to add to it. The problem is that anything you add has a cost and improves only a certain part of the whole (none of this sculptor metaphor for me :lol: ). For example, I decided that efficient array handling is a must. To that end I've added addressing modes and even instructions (REPEAT) that enable this aspect of computation. Every once in a while I get a nagging suspicion that this is not the only, nor necessarily the best method to handle anticipated problems.

A big part of the problem is not fully understanding the problem :roll: Case in point, I've intended for this CPU series to become capable of controlling a factory, only t o realize that I have no idea what that means. Sure, you could point out bits and pieces and say: "Well, this could be controlled ... and this".

The problem is that this addresses only a tiny part of a very big problem space. Non inclusive list of categories would include:resource needs, BOM, material routing,production facility setup/take down, refactoring,prioritization, damage control .....

Hmm.., I wonder whether it would be a good idea to open a new forum topic on "Factory control- what does it mean?".
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: combinator computer MK2

Post by siggboy »

piriform wrote:A big part of the problem is not fully understanding the problem :roll: Case in point, I've intended for this CPU series to become capable of controlling a factory, only t o realize that I have no idea what that means. Sure, you could point out bits and pieces and say: "Well, this could be controlled ... and this".
If you can make a logistic train network and a kanban factory it's fine, I guess.

I don't really see at the moment what else you might want to make that really serves the ultimate goal (which is minmaxing rocket production, let's be honest). Combat is not interesting and not circuit controllable.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: combinator computer MK2

Post by matjojo »

Holy shit, I just saw this on the subreddit in a comment somewhere, and I must say, this looks amazingly comlicated, I myself do not have any idea what you are doing here, but I see what it does in the end, keep it up!
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: combinator computer MK2

Post by siggboy »

matjojo wrote:Holy shit, I just saw this on the subreddit in a comment somewhere, and I must say, this looks amazingly comlicated, I myself do not have any idea what you are doing here, but I see what it does in the end, keep it up!
It's a CPU, it's what inside your mobile phone and your PC (and your microwave oven). Only smaller.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: combinator computer MK2

Post by matjojo »

siggboy wrote:
matjojo wrote:Holy shit, I just saw this on the subreddit in a comment somewhere, and I must say, this looks amazingly comlicated, I myself do not have any idea what you are doing here, but I see what it does in the end, keep it up!
It's a CPU, it's what inside your mobile phone and your PC (and your microwave oven). Only smaller.
Yeah, I got that, but HOW it works I don't know:)
piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: combinator computer MK2

Post by piriform »

this looks amazingly comlicated
Actually, if you drill down, and look at all the bits and pieces separately, they are simple and easy to understand. (i.e. this bit does this, that bit this etc.)
In fact you can think of them (sorta) as lines of code (i.e. X=Y+1,;Z=X*(Y>), etc..). The trick ,if any, is getting them to work together.
I see you made a mod or two. This is not any more complicated than that (you just have to wrap your head around the combinators :D ).
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: combinator computer MK2

Post by siggboy »

I think what makes combinators a lot harder than programming is that you cannot see the code. Even conventional digital circuits (as in conventional EE) are easier to "read" from a circuit diagram than combinators.

Add to that the lack of debugging and visualization tools and you have a challenge.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
Gertibrumm
Fast Inserter
Fast Inserter
Posts: 162
Joined: Fri Jun 03, 2016 6:54 pm
Contact:

Re: combinator computer MK2

Post by Gertibrumm »

XKnight wrote:Main execution cycle should be 1 tick long = this is must have.
Couldn't agree more!
matjojo wrote:Holy shit, this looks amazingly comlicated, keep it up!
sorry for faking :D
Thats where my approach to the issue comes in:
- Sadly I have no clue what branching means -> made me think of multicore
- I have no idea what kind of syntax assembler or archetecture you guys are deriving your fancy words from :( (all I kown is how the stuff works)
- No clue why one would need a stack and
- I have no idea why we need array processing in factorio. Seems to me we have it because we can! And that brings me to my next point

-> The usage of a factorio CPU:
Personally I think the usage of a CPU kind of falls short for the average factioran. Reminder: we are talking about a simplified CPU, not a simple buffer circuit for my chests ;) . Maybe you "Gurus" as they call you can take some time off from your worrying that "the usual player" doesn't understand logic and focus on your own higher level problems:

Lets challenge ourselfs a little bit for the coming 0.14 update!
Chances are high we are getting "set assembler recipe via circuit network"

Code: Select all

Challenge:
build a factorio where you can enter your desired endproduct and all outposts or lab arrays and rockets are always getting filled while you stand nearby the complex mess, proud, watching your digital clockwork.
Rules:
- Factory must produce your demand (count accurate)
- All being controlled by a CPU of your choice
- You are not allowed to set recipes (this is 0.14)
- Unlimited Coal, Oil, Ore for making things easier
(+ is optional)
+ Controlled train network with only 1 locomotive for factory-supply (to satisfy  siggboy)
+ 1 Rocket silo, 10 labs, must be getting their stuff unless demand is prioritized
How does that sound for a challenge?
If some of you agree, Ill start a thread or ask a moderator if he starts a thread for this specific challenge as I think this can get pretty interesting.
(I consider it the ultimate goal; hardest but best possible way)
Please add further ideas and criticize
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: combinator computer MK2

Post by siggboy »

@Gertiprumm

This is a GENERAL PURPOSE CPU, the scope and functionality of which is very clearly defined: a universal computer that you feed with programs and input and that generates an output.

What you propose is custom hardware, which is not the point when you're trying to design a general purpose CPU. That is I have nothing against custom hardware, my train controller is nothing else (and it does use as many combinators as the CPU by now, modulo RAM/ROM).

Branching means "If X then jump to Y". A conditional "goto" statement. Remember this is an actual computer, not some special purpose contraption.

A stack is useful in computer programming (to make function calls and returns), that's why you need one.

Array processing is another staple of computer programming, that's why it's in the CPU.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
piriform
Fast Inserter
Fast Inserter
Posts: 117
Joined: Mon Jan 25, 2016 10:02 pm
Contact:

Re: combinator computer MK2

Post by piriform »

sorry for faking
You do know that faking will get you only so far. Sooner or later you run out.
Couldn't agree more!
Do you also agree that doing three times the work in two ticks is worse then twice in two?
No clue why one would need a stack
I'm currently writing a program that uses stack extensively. A demo will be posted on YouTube,within a week (time depending). If you study the program (which I will also provide) you will learn how to (ab)use the stack.
Lets challenge ourselfs a little bit for the coming 0.14 update!
I agree with siggboy on you proposed 'challenge'. Having said that, if a 'valid' benchmark can be devised, I would not be opposed to having a go.

@siggboy
what's your take on computing with Sets (eg set of stations, set of trains, conditions, some magical operators and poof dispatch list)?
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: combinator computer MK2

Post by siggboy »

piriform wrote:what's your take on computing with Sets (eg set of stations, set of trains, conditions, some magical operators and poof dispatch list)?
That's basically what the scheduler does:

Phase 1: Set of requesters R (each requesting a set of resources), set of providers P (each providing a set of resources), output the set of resources that are in both sets. Then take one arbitrary resource from that set (we have to decide on one and we need to know which one it is). That's the resource to be delivered.
Phase 2: Take one requester 'r' from R and one provider 'p' from P associated with the resource from phase 1. Here we also want to know from 'p' how much it can provide.
Phase 3: Pick a lane from the set of lanes with waiting trains. Dispatch train.

Right now the one thing that would make a lot of things easier is an operator that gives me "Anything" from a set of signals (not "each", not "everything", just one single signal out of a set of many). XKnight has already proposed to add something like that for a better interaction with the filter inserters.
But it's also great if you need to pick single values from a set.

So, yeah, some operations on sets of signals, that preserve both the value and the type of the signal are definitely very useful.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
Gertibrumm
Fast Inserter
Fast Inserter
Posts: 162
Joined: Fri Jun 03, 2016 6:54 pm
Contact:

Re: combinator computer MK2

Post by Gertibrumm »

Maybe I was a little too cheeky last post :) I should keep in mind that
siggboy wrote:This is a GENERAL PURPOSE CPU
and my approach always was to aid the game, not build a CPU which like all the minecraft computers to name an example dont really do, they just are, they dont do :) .
siggboy wrote:Branching means "If X then jump to Y".
thanks! I was probably thinking about subroutine or multithread which are usually OS based.
siggboy wrote:Stack...(to make function calls and returns)
thanks for clearing up.
piriform wrote:Do you also agree that doing three times the work in two ticks is worse then twice in two?

I would agree to "Doing as much work in less time"
Even though it doesn't imrove speed alot (maybe 20% in my builds) it is a good starting point to keep things fast and as simple as possible.

Looking forward to your stack session piriform!

To your need for a standardized benchmark:
The challenge would kind of be a benchmark on its own! For this autonomous factory to work you have to make a good use for your CPU. Your CPU is as I think of it just as good as your application can benefit from it.
If you just want to crunch bare numbers then calculate how long your program performs or measure PC CPU temperature and see if it melts when playing factorio :).

What you need is not a benchmark but a debugging device, or an assembler editor which visualizes and simulates your CPU.

Back to the challenge: Which I see as a competitive game to improve our selfs and aid the game to integrate this stuff more!
I dont like to see things getting extremly advanced and focused while the progress keeps others off because they dont want to bother with things they cannot get involved into.
Maybe challenges only rule should be: "Build a factory which produces count accurate demand and supplies eg a rocket while you are not allowed to set recipes"

A challenge is what we need to actually improve progress in factorio and to make good use of the features we are getting!!
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: combinator computer MK2

Post by siggboy »

Gertibrumm wrote:
siggboy wrote:Branching means "If X then jump to Y".
thanks! I was probably thinking about subroutine or multithread which are usually OS based.
Nothing of that is OS based. The operating system is concerned with distributing resources among the programs that are running. So if you need disk space or RAM, then you go through the OS.

Multithreading is simply a programming paradigm, you do not need the OS to do multithreading.

"Branching" and "subroutines" are not even paradigms, they're just very simple operations without which you couldn't write a structured program. Well, a "subroutine" is a piece of code that is called in a specific way, it's not an "operation" in the actual sense.

What you need to do is to write a program or two, and learn about these things and then it will be much clearer what most of this means.
Gertibrumm wrote:A challenge is what we need to actually improve progress in factorio and to make good use of the features we are getting!!
Yes, but this thread is showcasing a general purpose CPU. Your challenge has basically nothing to do with that.

If you have a better CPU, maybe one with 60 IPS performance and some amazing features, then you can come back and pose a "challenge". But first you need to learn what a CPU actually IS. So there is some road ahead :).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
Gertibrumm
Fast Inserter
Fast Inserter
Posts: 162
Joined: Fri Jun 03, 2016 6:54 pm
Contact:

Re: combinator computer MK2

Post by Gertibrumm »

Even though you are challenging me all you say is discouraging.
If you have a better CPU, maybe one with 60 IPS performance and some amazing features, then you can come back and pose a "challenge". But first you need to learn what a CPU actually IS. So there is some road ahead :).
It is a little discouraging because when you are challenging me this way, Ill probably never come back due to lack of possibility.
I hope you ever tried to make read and write in 60 IPS! Because at the moment I can not (I can do it in 20 IPS). And I assume you cant either ;)

I hope discouragement is not intended because I do know a thing or two about what you are talking about, I just happend to be interested in actual use of the things we are doing, not just some proof of concept.

And I know this challenge has nothing to do with piriforms fantastic concepts 1-4, I am just trying to ask some people if they are interested in such a challenge.

And if my initial question hasn't yet seeped through: "Does anyone of you so called "Gurus" want to participate in such a challenge" :D
Post Reply

Return to “Combinator Creations”