MAMEWorld >> News
View all threads Index   Threaded Mode Threaded  

Pages: 1

Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4462
Loc: Melbourne, Australia
Send PM


Going old-school
#367593 - 07/07/17 08:38 PM


For lulz, I decided to rewrite MAME’s Intel 4004 CPU core and add support for most 4040 features. The new CPU core operates at the bus cycle level, and exposes most useful signals. It also uses lots of address spaces for all the different kinds of memory and I/O it supports (thanks OG). Some CPU core bugs were fixed along the way - notably intra-page jumps on page boundaries were broken.

One nice benefit we get from this is being able to hook up the I/O for the Bally/Nutting solid-state Flicker pinball prototype (supposedly the first microprocessor-controlled pinball machine) how the hardware actually worked. I also hooked up the playfield lamp matrix as outputs and the operator adjustments as machine configuration while I was at it. We need a proper thermal model of a lamp with PWM dimming support before that part can be declared perfect. (It previously used a hack, pulling the low bits of RC out of the CPU using the state interface. This worked due to a quirk of the game program, and there was no way to implement it properly without the 4004 CM-RAM signals being exposed.)

Possibly more interestingly, we can now emulate the Intel INTELLEC® 4/MOD 40 development system. There seem to be very few surviving examples of this system, but fortunately we've got monitor PROM dumps, and there's some information floating around the web. It has interesting debugging features on the front panel. There’s a scanned manual, but the schematics are very poor quality. However, with some idea of how it works, it’s possible to work out what all the chips are supposed to be. That’s the fun part. Turning it into MAME code isn’t as much fun, but it’s doable.

The front panel looks like this:


That requires clickable artwork for the switches and outputs for the LEDs to get a usable experience (writing the MAME XML layout really isn’t fun). There’s a simple monitor in PROM, designed to be used with an ASCII teleprinter with paper tape reader and punch (e.g. a Teletype Model 33 ASR). MAME’s RS-232 video terminal will have to do as a substitute for that.

If you get bleeding edge MAME (i.e. built from source no more than a day or so old), you can try it out in emulation. Did you ever wonder how developers may have debugged 4004 code in the mid to late ’70s? Well even if you didn’t, now you can find out.

The front panel looks like this in emulation (without the explanatory labels), and by default MAME shows the video terminal below this:


All those LEDs are functional, and all those switches are clickable and visually reflect their current state.

So how would you actually use it in practice? That’s where this brief instruction manual on the MAMEdev wiki comes in. It’s complete with examples of how some of the monitor commands and front panel debugging features can be used. It’s marked NOT_WORKING in MAME for now because you need to manually set up the terminal the first time you use it, and I haven’t finished implementing the universal slots and storage cards. But you can do all the things described on that page.

Does anyone care? Probably not. Will anyone actually even try this system out in MAME? Probably not (apart from Robbbbbbbert). But this is another example of something that you can only do in MAME, and how completely unrelated systems can both benefit from emulating the same chip properly. It also gets rid of one previously unavoidable hack, and gets us one step closer to feature parity with EmuAllSystems.



agard
MAME Fan
Reged: 08/04/13
Posts: 331
Send PM


Re: Going old-school new [Re: Vas Crabb]
#367605 - 07/08/17 01:06 AM


Nice write up & thanks for the rewrite. Only code I used to rewrite was the high scores in games then I could put a rediculiously high score & my name then burn over someone's original disc & give it them back. My high score & name was on there disc forever. lol . That was back when I had a Commodore Amigo god I loved that system so easy to use & I'm sure I read some arcade systems was based on it too. If your willing on how & what this Intel 4004 does & have the time to show me but your in for a long time in explaining it to me I'm lost nowadays but you can have a laugh in doing so at my expense. Thanks again



BIOS-D
MAME Fan
Reged: 08/07/06
Posts: 1688
Send PM


Re: Going old-school new [Re: Vas Crabb]
#367608 - 07/08/17 02:37 AM


Up to this date I've been ignorant about how really a microprocessor works even when I am an IT graduand. Yes, I've been following emulation since 1997. I know how to read and assemble electronic diagrams. I know x86 assembly and C/C++ and even back then programmed EPROMs. Yet I've been ignorant about how all that boolean logic truly manages to get the work done. It's a missing piece of knowledge I'm willing to learn by myself.

I decided to start with the first processor ever and found about the Intel 4004 — Anniversary Project, it even comes with a browser based visual emulator. Still it's a black box hard to decipher. Looking on YouTube I found good videos explaining briefly the patterns I needed to understand what's going on inside a microprocessor. It also lead me to a great book I wish I could have found during my school years.

This is just a free time project, but now with MAME emulating this Intellect system I may be able to learn (and practice) about the first processor... even if it is for nothing more than pure entertainment from my part.



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4462
Loc: Melbourne, Australia
Send PM


Re: Going old-school new [Re: BIOS-D]
#367617 - 07/08/17 06:38 AM


> I decided to start with the first processor ever and found about the Intel 4004 —
> Anniversary Project, it even comes with a browser based visual emulator. Still it's a
> black box hard to decipher. Looking on YouTube I found good videos explaining briefly
> the patterns I needed to understand what's going on inside a microprocessor. It also
> lead me to a great book I wish I could have found during my school years.

It isn't the first processor ever - stop propagating this myth. It's just the first microprocessor sold by Intel. There's lots of confusing terminology and weasel-wording thrown around in this area.

Firstly, let's get our terminology straight. A CPU (central processing unit) fetches/executes an instruction stream. It's a specialisation of a Turing machine in some form. You can implement a CPU with transistors, thermionic valves (vacuum tubes), or integrated circuits (ICs). CPUs definitely predate the 4004. For example the IBM System/360 (direct ancestor of the modern IBM System Z) definitely has a CPU, it was announced in 1964 and delivered a year later.

A microprocessor is a CPU implemented using a single IC or a small number of ICs, depending on who you ask. The 4004 isn't the first microprocessor, either. The 1968 Viatron System 21 used a microprocessor.

The 4004, released in 1971, is probably the first microprocessor sold as an independent product (i.e. sold to customers for integration into their own designs, not only as part of a first-party system). This is a significant milestone, but it doesn't make it the first CPU or microprocessor.

You can also argue that the 4004 isn't really a single-chip microprocessor either. The 4001 ROM, 4002 RAM and other peripheral chips actually do instruction decoding themselves to implement memory access and I/O. The MAME MCS-40 CPU core implements this system behaviour, not just the functionality of the 4004 or 4040 itself.



BIOS-D
MAME Fan
Reged: 08/07/06
Posts: 1688
Send PM


Re: Going old-school new [Re: Vas Crabb]
#367621 - 07/08/17 01:26 PM


I get what you mean. After all the basics of a microprocessor relies on logic gates and they can be implemented even with vacuum tubes. What I mean with "start with the first processor ever" is "to know the basics from one of the popular first commercially available encapsulated microprocessors fabricated by a known brand still alive" but that was too long, sorry for not being too specific.

The only low level programming I'm familiar with is x86. I never bothered learning Z80. If that were the case I could had started with Z80 even if it isn't the first. While a 4004 won't look like 8086, a 4 bit processor will be enough to know the roots.



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4462
Loc: Melbourne, Australia
Send PM


Re: Going old-school new [Re: BIOS-D]
#367623 - 07/08/17 04:38 PM


> The only low level programming I'm familiar with is x86. I never bothered learning
> Z80. If that were the case I could had started with Z80 even if it isn't the first.
> While a 4004 won't look like 8086, a 4 bit processor will be enough to know the
> roots.

The 4004 is actually a bit of an anomaly. The design is heavily optimised to minimise pin count, and it's designed to scale from a very small 64 nybbles of RAM up to 1,024 nybbles of RAM with no additional hardware besides the 4001 RAM chips themselves. I/O scales with RAM and ROM as the RAM chip provide outputs and the ROM chips provide inputs and/or outputs. It's clearly designed for low-cost applications where minimising chip count, keeping pin count down and simplifying board layout are important.

It achieves this by distributing CPU functionality across the chips. All the chips in the system work in lockstep in the 8-phase instruction cycle, and RAM and ROM chips need to decode I/O instructions. The CPU doesn't really even address RAM and I/O as such. There's an instruction that places the contents of a register on the bus during certain phases of the instruction cycle. Peripheral chips need to detect this and latch the value as an address. Then when they detect a RAM or I/O instruction, they need to either read a value off or place a value on the bus during the appropriate cycle. Hence it isn't really a single-chip microprocessor.

The CPUs that came before the it have far more in common with modern Intel microprocessors than the 4004 itself. Even the 8008, which is still heavily optimised for low pin count, is a far more conventional architecture and could be described as a single-chip microprocessor.

The 4004 is interesting in and of itself, due to the rather unique constraints that it was designed for. But if you're looking to find the roots of the x86 family tree, you won't find them there.



DarkMoe
Lurker
Reged: 11/26/03
Posts: 79
Send PM


Re: Going old-school new [Re: Vas Crabb]
#367637 - 07/09/17 03:41 AM


Good ! And I'm the guy who is testing everything new to MAME


Pages: 1

MAMEWorld >> News
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  John IV, Robbbert, Tafoid 
2 registered and 198 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2245