I was more on the idea of redoing the 6502: reinventing it from a white page, step by step. And using basic logics (and adding a 1 pass flip-flop component) it could be optimized so it's stabilized in 14 pass (nicely fiting the 14 MHz clock). Of course I would be 99% inspired by the real thing, but more like the goal than the start of the project. In the end it would have the same exact working (same cycles, same signals & signals timings at 14 MHz precision).
If even optimized as hell it really can't fit the 14 iterations, then I'll see.
Or cheating with double speed blocks (like in Robot Odyssey: each block or 'chip' you burn can be accelerated by a factor). Or a more elegant way: doubling the whole frequency to 28 MHz, and allowing to slow down blocks (by a factor of 2/3/4/...) so that parts that are already fast enough can be slowed down in order to reduce the simulation workload. Would be like emulating different propagation speeds.
But I would be much happy if everything can run at the same speed, without any trick anywhere.
For the bidirectionnal buses (the special internal one, and the outside buses too) I was thinking about simulating it with the special bus component provided: you draw the big bus arrow to a block (which can be a register, or the 6502 itself, blocks are nested) ... and you assign it to the 8 or 16 (or any number) of pins of the block that will use that bus. Inside the block the pins don't show anymore like simple input or output, but allow two connections. One connection from a gate output, one connection to a gate input = 2 wires (one way each). And you connect a direction wire to the bus (the R/W). When drawing that bus, it has a direction: the block from which the bus arrow starts is the only data source when in READ mode (and all target block receive that data). When in READ mode all data sources (connected to the bus arrow ends) are ORed, except the source block (which will receive the data).
I need to find a simple & quick tool to draw those things before I get to program my editor.
I don't expect to have many buses in the schematic, so it could be emulated separately (without basic gates but still in CUDA code) in a quick manner. Each bus has a list of sources, and a list of targets + the R/W wire source.
If the R/W is on (write), load the source bits, and copy to all target bits.
If the R/W is off (read), load all targets bits / OR each values, and copy result to source bits.
The provided components would be:
- AND gate (2 inputs)
- NAND gate (2 inputs)
- OR gate (2 inputs)
- NOR gate (2 inputs)
- XOR gate (2 inputs)
- NOT gate
- simple FLIPFLOP (2 inputs 2 ouputs)
- wires of course (you can make junctions; you add a junction anywhere you want to an existing wire -- would put a nice dot --, going to an input of course, and for the sim the destination input pin will be mapped directly to the source of the wire on which you do the junction: it won't need more computations in the sim, and won't add a propagation delay: if you have a wire with many junction, all of it will turn red when current goes through, at the same time for all wires connected)
+ I'll probably add a slowing down component (looking like a diode symbol), for the cases we need to have signals arrive at the same time and one path is too fast (simple load/store in the cuda code)
+ the special bus, the big arrow, unidirectionnal, or bidirectionnal with a direction wire, so that you don't have 8 or 16 wires everywhere in the schematics, but just a nice looking big arrow
(I have been dreaming of this one since I played Robot Odyssey
30 years ago )
+ block (a square icon with dotted lines, like a selection box)
The most difficult part would be the editor itself. I want it ultra simple, ultra obvious, without icons everywhere or boxes showing bits or values like I see on existing editors. You would just see the gates, as basic as it should be (standard black drawing), when not connected you see a little empty circle for the inputs and a little arrow for the output (it goes back to a simple straight line when connected). You move the components directly. You put new ones by sliding them from the toolbox, or you can add one quickly by double-clicking / double-taping (iPad) an empty zone: the toolbox appears after the second click/tap, with the last added component just beneath. If you release without moving, it adds the same component you added before. Or you can slide to select an another one. Meaning if you want to add several AND gates (after you added one), you just double-click on an empty space, double-click double-click double-click, each time a new component is added.
For wiring you just click the input or output and draw the line.
(the pathing will be tough to program, to avoid collisions and keep it nice)
To do a block of components (grouping some components, or even grouping almost 'everything' to form the cpu), you arrange you components so that the one you want to group are in a rectangle. Then you select the block icon in the toolbox, and you draw a box around the components you want to group. And that's all. It will popup a block window showing your components with the same placement, but wires that are connected to things outside are now connected to pins in the box border. You can name the block, name the pins. Once you're happy you close that window pop-up, and you see the schematic you had but ... instead of the components you had in the selection box, you now have a little block with the wires still connected as it should. You can 'enter' it again anytime by double-clicking (or long click) on it. That block is added in the toolbox: you can duplicate it, like any other basic component. You can copy the block and edit it: that one will differ from the original. But you can too 'freeze' the original block so that the new ones are not just copies: there are clones. If you change the original, you change all the clones at the same time, avoiding to redo modifications 8 times if for example you are working on a 1 bit ALU part of the 8-bit ALU.
And like basic components, you can add several times the same block with the double-click on empty space. A complete 8 bit adder could be done from scratch in less than 1 minute (if you know how to do it).
(if you want a 3 input standard gate, you do it with 2 gates and form a block with it, it will be reduces to a small block with 3 inputs / 1 ouput, you can name the block and the input & ouput pins: then you have your own 3 inputs standard gate you can reuse, still working in 1 iteration since the two 2-inputs gate are parallel, it's just it takes twice the computation for the simulator, which is still realistic compared to the real thing transistors count)
The simulation (at slow pace, like 10 Hz) is working all the time, even while editing.
You can touch any wire to force it red (like if sending current there), and see the signal go through.
You can touch any red wire to force it black (like if cutting that wire), and see the signal go through.
And the iPad you can touch multiple wires that way, and play with the circuit without having to connect an emulated peripheral (I'll provide keys, keyboards, simple leds, numbers leds & lcd, etc...)
In that editing mode you don't see what's happening inside the blocks anymore, only the displayed wires are colored when signal is going through. But I could add a zoom out with the program exploding all the blocks to show all gates & wires in a single page (hiding the gates themselves, or with very tiny icons).
Once burned (compiled) for realtime CUDA simulation, we don't use the editor anymore.
We'll have realworld alike emulated hardware: you don't see any signal if there is no real (emulated) hardware connected to a wire. There will be keyboard, buttons, leds, screen of course, mouse, joysticks, etc ... I could even wire the apple slots, and allow pluging extension boards (what about a SCSI & 20MB hard disk? Or a Mockingboard?). That could be simulated in logic level like everything else (running on CUDA CORE), or emulated on the CPU at 1MHz (standard x86 code).
And of course there would be tools for helping make it work. Signal analyser (you connect to any wire) to check the signals timings, an hex editor or even a compiler? And a debugger, with bits or hex display of x-bits blocks outputs (to see registers or buses content) and memory chip dumps (that one would be emulated on CPU only I'm afraid, except if I manage to simulate a very small memory for the purpose of explaining how memory chip work, like I could emulate just the zero page, but 48k RAM wont fit for sure: when going for the full blown Apple ][ the memory would be emulated only).
Sounding good?
(sorry for the very long posts, I need to write down my thoughts; promised once I've started the web site I'll be more concise
)