28

It strikes me that, in theory, it would be possible to skip the classic approach of emulation and instead literally build a NES, SNES, Nintendo 64 or any console with digital "components", which are wired together just like the original machines, on a digital "PCB" and even with the chassis around it so that it can be placed in a virtual 3D room and not just be a solid 3D object "prop".

If such a software existed, it would basically let "anyone" build machines by picking out digital versions of components which exist in real life from a huge list, and soldering would be instant and perfect every time, etc.

I'm not talking about an "assembly simulator", like a game, but simply some kind of "actual" representation of every single little component inside those consoles.

You would feed them virtual power in the power socket, and the virtual output from them, the video and audio signal, would be hooked up to a virtual CRT TV which displays the game just like the original consoles.

Obviously, this is easier said than done, but what exactly is it that prevents this approach at this point? Are computers just not fast enough yet? They still have to use all these "shortcuts and tricks"?

Note also that, using this method, there would be no actual "emulation coding". All the work would be all about connecting these components together exactly like they are on a real machine, and of course to create this advanced software in the first place. But once that's done, any system could be emulated perfectly and there would no longer be any need for all the existing emulator softwares, with all their flaws and shortcomings.

I'd like to hear why exactly this is not feasible.

9
  • 4
    The N64 has two main chips: a CPU chip, and a graphics chip. There's only one way you can wire them together and make them work, and that's the way the N64 is wired. What would be the advantage of letting you make different combinations that don't work? Commented Sep 14, 2020 at 9:26
  • 11
    It took until 2015 before the SID chip in the C64 machine popular in the 80'es could be accurately emulated in software. native-instruments.com/en/reaktor-community/… Commented Sep 14, 2020 at 10:15
  • 12
    Shouldn't underestimate the extent to which we don't know completely how these work - component internals will be trade secrets that have to be laboriously reverse-engineered.
    – pjc50
    Commented Sep 14, 2020 at 14:24
  • 12
    You are building an emulator. It just changes the level of emulation.
    – NomadMaker
    Commented Sep 14, 2020 at 15:03
  • 1
    Besides the technical problems of full simulation (which @RETRAC's answer nicely addresses), there would seem to be a very practical one, which is that there probably aren't enough engineers and programmers willing to devote time to such a (pointless, IMHO) project, and no billionaires willing to pay them to do it.
    – jamesqf
    Commented Sep 14, 2020 at 16:45

6 Answers 6

68

Taken most literally, what you are proposing is complete analog simulation of the entire electronic circuit. Analog circuit analysis is not cheap. Generally, every point in the circuit has to be calculated against every other point, at a time resolution fine enough for the smallest relevant signalling details to be preserved. The problem scales non-linearly with the more components there are.

Spice is a simulator that is widely used for this kind of work, and a 20 component circuit handling audio frequencies will run many times slower than real-time on my fairly powerful modern desktop. Even a simple pocket calculator has thousands, if not tens of thousands, of components.

So some "shortcuts and tricks" must be done. for example, with fully digital circuits, you can simulate them with the assumption that they are, in fact, digital. This can be done at the transistor or logic level. It's still very computationally expensive, requiring every node to every node be computed. This is almost feasible today with simple machines. See the Visual6502 Project for an example where this has been done with the entire 6502 processor.

There is a transistor-level simulation of the TIA chip used in the Atari 2600, which is infamously hard to emulate. There is a complete transistor simulation of the Atari 2600, based on that and Visual6502. It is very slow. The reverse-engineered layout was, however, used to inform the current TIA emulation module in the Stella emulator. It uses a mixed level of abstraction, and runs quickly on modern machines.

Finally, there is the most common kind of emulation, behavioural, where the internal implementation does not match the real device. If completely accurate, this is potentially interchangeable with a full digital simulation. But for any complex component, making such an emulator fully accurate without fully reverse-engineering the electronics is often impossible. Something like a CPU emulator may not emulate esoteric behaviour that occurs due to an unusual circuit layout, for example.

Your general simulator would have to be general enough, and accurate enough, for all the components to work in whatever configuration you might put them in. That brings me to a point raised by @TrevorBoydSmith in the comments. We do not have such information for many designs. They are generally proprietary, and potentially copyrighted. The above transistor-level simulators of the components in the Atari 2600, for example, were created by literally breaking open chips, photographing them, and semi-automatically translating this into connection maps. It is demanding, complicated work that gets harder the more complex and miniaturized the components are. Only a few ICs have been mapped like this.

In practice, mixing these approaches is often what is done in emulators aiming for very high accuracy. A sound chip might be partially simulated as an analog circuit, for example. As one commenter notes, some emulators including the Commodore 64's SID chip take this approach for the SID chip. There is the DICE emulator for very early video games such as Pong. A mixed approach is necessary here, as these games rely on analog components, but could not be simulated as an entire analog circuit including every transistor. DICE runs just about fast enough to play some of the implemented games at full speed on modern computers.

There are various emulation suites, of which DICE is an example, which do take a broadly component-level approach, mixing levels of simulation abstraction as necessary. MAME/MESS takes a primarily behavioural approach, but does break the designs down into components for easy reuse. It can be almost trivial to implement a new platform with MAME, if all of the components already exist and are 100% accurate in their emulation. (They often are not.) These emulation suites usually only simulate just enough for the specific machines they target to be emulated accurately.

In conclusion, your general simulator would have to be very complex, incorporating both general-purpose analog and digital simulation. Most importantly, someone would have to actually translate the many proprietary logic or electrical circuit representations of the circuits we want into this simulator.

So, theoretically, it is possible. But it is a software engineering and data collection/hardware reverse engineering problem of truly vast scope. It is unlikely to run at real-time speed. And it might forever be too computationally expensive to do for anything with extensive analog components.

8
  • 6
    great answer. maybe you could add a little footnote about "many of the chips that you would need/want to simulate are proprietary/copyrighted and therefore the designs are not available which means you can't create simulations without those designs". that would make the answer more complete in my opinion. Commented Sep 14, 2020 at 17:31
  • @TrevorBoydSmith Good idea, I've tried to give a bit more emphasis on that part.
    – RETRAC
    Commented Sep 14, 2020 at 17:53
  • 2
    That's quadratic, though. Exponential means that adding n components makes the difficulty go up tenfold, adding 2*n* components makes it go up a hundredfold, 3*n* components a thousandfold, 6*n* a millionfold, 12*n* a trillionfold, and so on. Commented Sep 14, 2020 at 18:23
  • 1
    Sorry for being nitpicky. :D Commented Sep 14, 2020 at 18:26
  • 1
    According to this paper the scaling is neither, and actually something close to linear depending on the architecture it runs on.
    – Will
    Commented Sep 15, 2020 at 11:36
35

It is feasible, but not in software, because software is not fast enough.

But indeed,

it would basically let "anyone" build machines by picking out digital versions of components which exist in real life from a huge list, and soldering would be instant and perfect every time, etc.

The hardware that makes that possible it called Field-Programmable Gate Array, or FPGA.

You can "program" such an FPGA by writing a description of the digital components, and how they are wired together, in a "language" like VHDL. So it's not that difficult from writing a program in a programming language, except that you need special hardware to "run" it.

And there are quite a few projects out there to implement components like CPUs, other special chips used in early computers, and even whole computers with those. Google "FPGA + (name of computer)", and you'll find them.

Here are some random links from my notes:

...

1
  • 4
    The MIST board is particularly impressive, as they have been able to successfully emulate Amiga, Atari ST, and Macintosh as well as most of the earlier 8-bit systems.
    – DrSheldon
    Commented Sep 14, 2020 at 18:06
14

There already exists many FPGA implementations of many old platforms. FPGAs can be "wired" or "programmed" to replicate a machine at the logic gate level. However, it is unable to replicate the imperfections and other analog aspects of how the original machine outputs analog audio and video, unless significant processing power is again used to model these imperfections, so that for example audio of C64 SID chip sounds like it is supposed to sound or the displayed image on a TFT screen looks like how it looked on a CRT.

Some old chips have been reverse-engineered from the silicon die photos. In theory the structures can be simulated in an analog circuit simulator, but CPU or GPU horsepower is not there yet to do it in real time for a whole set of chips.

7

There are a lot of good answers here but with respect, I feel that many of them are missing the true essence of this excellent question.

As others have said, emulators are fast but the level of abstraction used is high and the implementation is generally nothing like the underlying hardware.

Spice does painstaking sub component level simulation with great fidelity but is far too slow to be of practical use, even on fast modern machines.

FPGAs go some way toward answering the question, but they are a hardwarez, whatever people may say about VHDL et al.

So I believe the question simplifies to this: Is there a software simulation somewhere between what MAME does and what Spice does? Something that, say, simulates a 7404 in terms of "you put a logic 1 on pin foo, and bar picoseconds later a logic 0 comes out on pin baz"? Something that lets you, say, build a DEC VAX out of such simulated TTL?

For purely digital circuits running at a few megahertz with a few dozen chips and netlists of a few hundred pins - i.e. a typical late 1970s or early 1980s microcomputer - such an emulation ought to be possible on current hardware. (For analog circuits, haha nope.)

Later machines increasingly featured custom chips. There are already emulations of these that may or may not be useful in designing a version to work with this system. On the one hand, such custom chips pack a lot of TTL into a small space and might not be feasible to emulate; OTOH, they potentially reduce a lot of complex internal functionality to the behaviour of a few (well, typically 40) external pins, which might actually make things easier.

The stuff about proprietary chips I believe is not relevant. If you want to simulate a chip at this level you should be able to get everything you need to know about how it works from the product data sheet. (That, after all, is precisely what it is for.)

So to summarise: It is highly unlikely that you would be able to build a virtual Spectrum and plug it in to a virtual Sony TV and then play Manic Miner on it in software using current technology, or any technology in the foreseeable future. It is even less likely that you would be able to walk around it in your virtual lounge and flump down on your virtual sofa to play it.

But if you wanted to build the gubbins of a virtual Commodore PET out of virtual TTL and are prepared to fake the I/O a little bit - go for it!

And let me know when its done!

8
  • 3
    I have a horrid thought that OP expects something like quinapalus.com/wi-index.html Commented Sep 15, 2020 at 8:53
  • 2
    Simulating proprietary chips using the data sheet is how normal emulators work already! (... also if they're proprietary, you might not be able to get the data sheet) Commented Sep 15, 2020 at 11:09
  • 2
    "you put a logic 1 on pin foo, and bar picoseconds later a logic 0 comes out on pin baz", the non synthesisable parts of most HDLs do this, you can write things like Z <= not I after 1ns; Of course even modelsim will not run that in real time!
    – Dan Mills
    Commented Sep 15, 2020 at 13:02
  • 2
    @user253751 I'd say no, most emulators can't just use the data sheet. Many chips have undocumented instructions, intentional or otherwise, and programs are notorious for depending on undocumented aspects of the system, sometimes even when the programmer documentation told them not to depend on it. Even relatively well-documented systems are often a long slog of finding weird bugs that come from programs doing what they shouldn't and depending on the hardware to do exactly what it does in practice.
    – prosfilaes
    Commented Sep 16, 2020 at 1:42
  • 1
    @scruss Thanks for the warm welcome! The OP asked "why exactly [thing] is not feasible" and I said "it may be feasible but (to my knowledge) nobody has done anything exactly like that yet". How is that not an answer?
    – lob
    Commented Sep 16, 2020 at 9:41
1

To add a little to the excellent answers already posted... In digital electronics it's typical that we do as much as possible in software/firmware, for a number of good reasons (cost, space, power, risk management) and only resort to hardware for functions that code can't perform, such as power supplies and user interface. Therefore in a purely virtual (software) environment there's little point in simulating hardware, that wouldn't be required in that environment, unless you're just doing it for fun. As other contributors have pointed out, accurately simulating even a single transistor uses significant computing resources, and in this situation there's no obvious gain over a conventional software implementation. There are limited examples of where limited real-time simulation is useful (e.g. using a PC to simulate the 8-bit micro in an old arcade game).

0

What you propose would be similar to an FPGA simulator. Such things exist but they are very resource heavy and have some major limitations.

The basic issue is that with real hardware many things happen simultaneously and a lot of work is required to simulate that in software. The result probably wouldn't be any better than the traditional emulators we have now.

Also writing the code that defines these systems is somewhat specialist and less well known than writing traditional computer code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .