

6502 simulated at transistor level in Javascript - pnp
http://www.visual6502.org/JSSim/index.html

======
teilo
At the transistor level? I assume this means that each transistor is simulated
digitally, as a pure switch, and not as an analog component, which I imagine
would be near impossible to do in Javascript on current hardware.

Not the most practical way to emulate a CPU, but surely a good exercise in
learning how a processor works from the component level on up.

~~~
andreyf
_I assume this means that each transistor is simulated digitally, as a pure
switch, and not as an analog component, which I imagine would be near
impossible to do in Javascript on current hardware._

Thought this for the longest time, too, but reality can't be simulated on a
computer. Only a simplified model can.

~~~
po
Maybe not exactly, but you can get pretty damn close. The digital audio guys
are the ones who are really into this. It's the only way to get the exact feel
of old audio gear.

<http://www.simulanalog.org/>

An amp is much simpler than a microchip but the ideas are there:

<http://dafx.labri.fr/main/papers/p169.pdf>

~~~
andreyf
> Maybe not exactly, but you can get pretty damn close.

Pretty different things those two, if you consider chaos theory.

Still, computers are by design created in a way which can be easily modeled.

------
thought_alarm
Now _that_ is a hard core obsession; with retrocomputing or JavaScript, I'm
not sure which.

------
anigbrowl
I put on a hat so I could take it off again. Very impressive. Now I know what
do to do with those old Atari game cartridges which have been sitting in a box
by my desk for 5 years.

Also, this seems like it should have a unit to itself on any CS course, not to
mention serving as a platform much further research. Maybe I should take up
6502 Assembler as a hobby. Their SigGraph slides are well worth a look:
<http://www.visual6502.org/docs/6502_in_action_14_web.pdf>

~~~
Jeema3000
I might be biased as a retrocoder hobbyist myself, but I feel like 6502
assembly would still be very useful in the classroom as a teaching tool, with
it's small and (IMO) relatively straightforward instruction set - in some ways
it's sort of like the 8-bit RISC-before-there-was-RISC processor. Plus there's
great retrocoding potential once you learn it! ;)

~~~
rbanffy
We could call it "LISC". The instruction set was never reduced, but its growth
was limited by what Peddle and hist folks could fit on the chip.

And yes. I learned to program on a TI-55 calculator. Limiting complexity is a
very useful tool to introduce someone to programming.

------
malkia
This is pretty cool.

It reminds me of 6502-sim for my Apple ][ - it was a 6502 application (Sorry
Captain Obvious), but it was cool as it was showing how each instruction
worked.

This goes beyond it :)

------
jhrobert
Amazing.

It runs at 27hz (not 27Mhz)...

And some people are willing to simulate the brain? Good luck!

~~~
js2
That's the Python sim. "The JavaScript sim is only a few hertz, limited by
drawing the chip parts."

By contrast, the Apple II ran at 1 Mhz.

------
reader5000
Wow. It's beautiful.

------
zandorg
The 6510 (C64 6502 with extra ports) has secret opcodes, basically holes in
the circuitry, which emulators have to support because they're used in demos
for extra speed (eg, write to x what's in a).

I wonder if this simulation also has secret opcodes?

~~~
kragen
I thought TAX was one of the standard 6502 opcodes?

~~~
zandorg
Couldn't think of a decent example off the top of my head.

Also, proper term is 'undocumented opcodes' for further searching.

Try

"AXS __* (SAX) AXS ANDs the contents of the A and X registers (without
changing the contents of either register) and stores the result in memory. AXS
does not affect any flags in the processor status register."

<http://www.ffd2.com/fridge/docs/6502-NMOS.extra.opcodes>

------
miles
Non-CS majors who want to dig deeper might enjoy:

But How Do It Know? - The Basic Principles of Computers for Everyone
<http://amazon.com/dp/0615303765>

------
mkramlich
chip-u-licious! kudos to the creators. i'll check out the Python one tonight.
old time 6502 hacker here...

------
arethuza
Can you imagine what a contemporary CPU or GPU would look like if displayed
like this?

~~~
cma
For a modern CPU, it would have about as many transistors as there are
warp/weft crossings on a bedsheet.

~~~
kragen
A standard double-size bed is 4 ft 6 in by 6 ft 3 in
(<http://en.wikipedia.org/wiki/Bed#Bed_sizes>). A standard cotton sheet is 150
thread count, which means 75 threads per inch of warp and 75 threads per inch
of weft (usually) (<http://en.wikipedia.org/wiki/Thread_count#Thread_count>).
That gives about 4050 threads by about 5625 threads, omitting the part of the
sheet that tucks down around the edge of the mattress, for a total of about 23
million thread crossings.

The Intel Core i7 has about 781 million transistors
(<http://en.wikipedia.org/wiki/Intel_cpus#Core_i7>), which is about the number
of warp/weft crossings in 34 standard bedsheets, omitting the stuff around the
edge of the mattress. I thought maybe ARM chips would be smaller, but
[http://www.geek.com/articles/mobile/arm-introduces-
cortex-a8...](http://www.geek.com/articles/mobile/arm-introduces-
cortex-a8-chip-design-2005105/) says the Cortex-A8 has over a billion
transistors. (Although there are certainly low-end microcontroller ARMs that
are much smaller. And of course the C18 is smaller still; is it "modern"?)

If you're talking about bigger beds and finer sheets, you might get the number
down to less than 10 bedsheets per CPU.

But that doesn't mean you could make a diagram of a modern CPU that was only
the size of ten to forty bedsheets, with the transistors the size of warp/weft
crossings in a bedsheet. If I remember correctly, only a minority of the chip
area typically consists of transistors and other active devices.

------
LongSean
Awesome ... how long before someone can use this to run NES games ?

~~~
Groxx
I nearly expect it to have already been done, given that there's a gameboy
emulator in JS: <http://www.codebase.es/jsgb/>

~~~
reedlaw
NES has been done as well: <http://benfirshman.com/projects/jsnes/>

------
JabavuAdams
Wow, hot!

