# Hardware, electricity and computing



## joshbsd (Dec 15, 2022)

searching for books and resources about fundamentals of how computer work at the material level and how it is related to driver kernel and software. I want to understand how electricity is transformed into information how it is built engineer into the machine, I want to deconstruct the abstraction that I have before me. demystify the machine and the software.


----------



## Jose (Dec 15, 2022)

Home | nand2tetris
					






					www.nand2tetris.org


----------



## SirDice (Dec 15, 2022)

I would suggest starting with an 8 bit CPU based computer. It's simple enough to wrap your head around the whole concept. The fun thing is that today's modern 64 bit computers aren't that different, they still use the same concepts, only much more complex. 

8 bit 6502 based computer:




_View: https://www.youtube.com/watch?v=LnzuMJLZRdU&list=PLowKtXNTBypFbtuVMUVXNR0z1mu7dp7eH_


Entire CPU created from scratch:




_View: https://www.youtube.com/watch?v=HyznrdDSSGM&list=PLowKtXNTBypGqImE405J2565dvjafglHU_


----------



## Profighost (Dec 15, 2022)

Depends on how deep you want/need to go.

The keyword you're looking for is microelectronics - a special expert's subfield of electronics.
It's about how to design electronic circuits you need to get a computer out of basic electronics parts,
mostly those logic gates you already knew, memory (Flipflop),... and oscillators (without a tact everything stands still)
and how those are combined to more complex circuits performing basic operations such as comparations, bitshifts, calculations etc.,
(and how to bring those circuits on a piece of silicon to become a processor).

But before you can go there - if you want go there - you'll need to understand electronics.

*physics -> electrical engineering -> electronics -> logical gates (TTL) -> logic circuits (ALUs, registers, memory, multiplexers)*

could be a link-chain that may help you.
Depending on the knowledge you already have you may directly join into TTL and ALU

The best way to _really understand_ things is always do it yourself.
The hard way:
Get yourself a small electronics lab with a breadboard, some electronics parts, a microcontroller, its programmer, and (most expensive) a powersupply, multimeter and an oscilloscope to see/measure things.
Maybe you have a local school, university or know somebody with such a lab who may assist you with it.
And experiment.
You'll learn a lot!

I can recommend two books that may get you into this:
The Art of Electronics, Horowitz and Hill, Cambridge Press
and
"Student Manual for The Art of Electronics", Hayes and Horowitz, dito.
A practical lab handbook with lots of experiments including building a computer and program it.

Another way to learn how electricity becomes information - closing the gap between transistors and software - is to learn Assembler.
Not the the ones you find on today's 64bit architectures - those is high-level programming already 
As SirDice mentioned: 8bit (or even less)
Go _really down_! (You want to get down to OSI Layer 1)

When you've figured out:
On most smaller processors (8bit) there are no 'higher' operations like multiplication, especially not division, sometimes not even substraction,
but on those already amazing things can be done.
Cause all you really need is addition, one's complement, and a handful of other small operations to do anything (it's only the matter of memory and speed then.)
With those you can realize the other three elementary arithmetics.
And having those any mathematical function can be substituted by algorithms containing those four basic operations.
Anything else is just to get and set the status/value of memories and registers by algorithms containing those operations.

When you understand
Assembler commands represent machine code which is binary values, placed into a special register that causes certain circuits to be activated, obtain the according operation onto a another binary value - the value you want to check or manipulate - and how combinations of those primitive steps lead to even higher operations ...until such as blathering rubbish within a forum ...

...then your question is answered.


----------



## drhowarddrfine (Dec 15, 2022)

Profighost has the complete answer. This is my field and what my degree is in. An answer is far too broad for this forum.


----------



## cracauer@ (Dec 15, 2022)

It is reasonably easy to learn how semiconductors work and how logic gates are made from them.

However, trying to learn a CPU from logic gates up is very challenging.


----------



## astyle (Dec 15, 2022)

This looks like a decent case for an Arduino kit... It's a fun rabbit hole to go down - if you're ready to blow a bit of money on breadboards and capacitors.  One word of caution: This is the road that leads to places like analysis of a GPU's mining profitability. (I've been following the news on that, that's how I know some of the ups and downs of THAT).


----------



## Profighost (Dec 15, 2022)

cracauer@ said:


> trying to learn a CPU from logic gates up is very challenging.


If you stay restricted to a 'primitive' 4...6bit machine just to grasp the principal concept using TTL-ICs it's doable.
But if we're talking modern 64bit cores, you're right. You'll have to deal with a lot more than 'just' simple logic gates anymore.
Not to mention the features modern CPU have like multithreading, branch predictors,....

But "How does a flying machine works?" does not neccassarily means "building a Space Shuttle" 



astyle said:


> This looks like a decent case for an Arduino kit


This is a very good advice! (There are [several] other choices than Arduino - but it could be a start.)
As long as you try to program at least a few lines in Assembler,
since default Arduino programming is done in C (or even C++),
and to really grasp the link between Voltage and Software
in my eyes you shall had manipulated the one or the other register and shifted some bits


----------



## joshbsd (Dec 15, 2022)

Thank you all for your answers, appreciate it, and it will come back to the community... if i'm not too lazy... 
Now I know where too start, cause i was a bit confused about that stuff. If I may ask what is the difference between Arduino and raspberry pi is one better than the other and for what  or is it just product competition?


----------



## Jose (Dec 15, 2022)

cracauer@ said:


> It is reasonably easy to learn how semiconductors work and how logic gates are made from them.
> 
> However, trying to learn a CPU from logic gates up is very challenging.


That is exactly what you do in first half of the Nand-to-tetris course. You begin with a humble emulated NAND gate and use it to build emulated registers, adders, etc. Then you progress to building an ALU and finally a CPU. Yes, it's heavily guided, but I still found it instructive.

There's even a video of how an actual NAND gate was built from NMOS transistors back in the '80s. There are folks who have implemented this computer using an FPGA.

In the second part of the course (which I haven't completed ) You build an assembler, virtual machine, and compiler for a high-level language called Jack.

It does not cover operating systems, though. What you're left with at the end is the equivalent of an '80s personal computer. The PC "operating systems" of the time, like DOS, were really just loaders. They would read your program into memory from some awful media and then jump to its first instruction. They would be completely out of the way while your program was running*. A super interesting side-effect of this is the zero-byte program that actually did something.

* Yes, I know about TSRs. I will not utter such things here.


----------



## Crivens (Dec 15, 2022)

The 6502 is among the last CPUs which were small enough to understand each and every transistor. There are even browser based emulators, have a look here.


----------



## richardtoohey2 (Dec 15, 2022)

joshbsd said:


> what is the difference between Arduino and raspberry pi


Arduino is a microcontroller (so is Raspberry Pico) just running one program whereas a Pi is a complete computer that can run Linux or FreeBSD etc.  That’s a simplified explanation.


----------



## Profighost (Dec 15, 2022)

joshbsd said:


> what is the difference between Arduino and raspberry pi is one better than the other


Neither better nor worse, different.
Raspberry Pis are built on larger and faster Microcontrollers capable of running whole Operating Systems like FreeBSD or Linux.

To start the way I explained those may a bit too large - you could learn the same stuff on your PC.

Grasp


joshbsd said:


> to understand how electricity is transformed into information how it is built engineer into the machine


you don't need a machine doing the things you do with your PC,
you may read it out of books, wikipedia articles, watch the linked videos,
or, if you want to dig really into it, you'd better actually experiment with real electricty and transform it into information "see/measure" how information is represented by voltage.
But I would never recommend to put a soldering iron to your main computer  - not even any electronics measurement devices.
Besides the chances to destroy your system if you're not a pro are high, you won't see nothing useful helping you to understand if you don't know what where to measure and have (very expensive) proper pro-equipment (simply the frequencies are that high you would not get anything on a scope for a couple hundred bucks...)
[DON'T DO IT!]

So better on a very low level (Building simple circuits e.g. a flipflop out of transistors, or a more complex logical circuit out of TTL-ICs.

and yeah, of course you'll find several simulations on the internet doing it virtually,
or doing things like SPICE e.g. LTSpice (but besides you need to learn to use the not trivial software, of course you need to know electronics...)

Or try experiment on 8bit-Microcontrollers.
A good advice are the PIC16 or PIC18 models of Microchip
LARGE community, tons of stuff (circuit examples, programs, websites...anything)

Either way you'll learn.
Enjoy!


----------



## astyle (Dec 15, 2022)

joshbsd said:


> If I may ask what is the difference between Arduino and raspberry pi is one better than the other and for what or is it just product competition?


Hardware-wise, Arduino can be thought of as building blocks, while Pi Pico is an example of how far you can go with those building blocks...


----------



## drhowarddrfine (Dec 15, 2022)

Crivens said:


> The 6502 is among the last CPUs which were small enough to understand each and every transistor.


I used the Z80 which was simple, too. I still have some in a box in the basement.

If one really wants to get into it, I also have some 74181 ALU chips and its support chips. But if you reaaally want to get into it, I have a number of 74xx logic gate chips, too. Plus breadboards, wire wrap and tools, etc.


----------



## cracauer@ (Dec 15, 2022)

joshbsd said:


> Thank you all for your answers, appreciate it, and it will come back to the community... if i'm not too lazy...
> Now I know where too start, cause i was a bit confused about that stuff. If I may ask what is the difference between Arduino and raspberry pi is one better than the other and for what  or is it just product competition?



A Raspberry Pi is not simpler than your FreeBSD PC, with virtual memory and full multi-user OSes. An Arduino typically just runs a "naked" program.


----------



## alexseitsinger (Dec 15, 2022)

SirDice said:


> I would suggest starting with an 8 bit CPU based computer. It's simple enough to wrap your head around the whole concept. The fun thing is that today's modern 64 bit computers aren't that different, they still use the same concepts, only much more complex.
> 
> 8 bit 6502 based computer:
> 
> ...


This guy's channel is great. He creates some awesome stuff.


----------



## chrbr (Dec 15, 2022)

Regarding logic which exceeds the standard ICs I have started using GALs. I am not sure if they are still available. Later I have switched from CPLDs to FPGAs. With FPGAs you are far away from transistor or gate level design. The FPGA vendors try to lock in their customers by libraries and interfaces to Matlab and so on. Additionally they claim that FPGA design is more software than hardware. This is not true if you have clock domains, timing issues and so on. But it is perfect to lock in customers who just click black boxes together.


----------



## astyle (Dec 15, 2022)

chrbr said:


> Regarding logic which exceeds the standard ICs I have started using GALs. I am not sure if they are still available. Later I have switched from CPLDs to FPGAs. With FPGAs you are far away from transistor or gate level design. The FPGA vendors try to lock in their customers by libraries and interfaces to Matlab and so on. Additionally they claim that FPGA design is more software than hardware. This is not true if you have clock domains, timing issues and so on. But it is perfect to lock in customers who just click black boxes together.


It's actually amazing how people learned anything about electronics engineering before the advent/consumer availability of Arduino and programmable boards...


----------



## hardworkingnewbie (Dec 15, 2022)

Ben Eater has been already mentioned. Aside that you should have a look at its theoretic foundations, namely John von Neumann and the Neumann Architecture. Most computers still follow these principles today.

Having the pieces alone without knowledge about this architecture would probably make it hard to build a computer.





_View: https://www.youtube.com/watch?v=Ml3-kVYLNr8

View: https://www.youtube.com/watch?v=HyznrdDSSGM_


----------



## richardtoohey2 (Dec 15, 2022)

astyle said:


> It's actually amazing how people learned anything about electronics engineering before the advent/consumer availability of Arduino and programmable boards...


There were kits in the 1970s/80s for building your own 6800/6502/Z80 computers.


----------



## Profighost (Dec 16, 2022)

richardtoohey2 said:


> There were kits in the 1970s/80s


The Homebrew Computer Club brought out a couple of those then. (If you don't knew it check out which guys came out of it )
Also the first Apple was brought on the market as a kit to be self assembled (without a case) - chinese sweatshops weren't available yet 

This were the days when all people want to do something more with a computer but to consume had to had learn assembler.
And those who learned programming on punched cards became our teachers having no idea why we lazy lads pressing so hard on grasping things like pointers, or seeing no sense in learning logic gates and binary sh#t - ’cause we already came from "assembler is the total shit! don't do it!! never, ever!!! learn [current high level language]!"

...and today explaining people what files and harddisks are (because some internetdisturbance blocked the cloud-access again) you're seen as a hacker *facepalm*


----------



## chrbr (Dec 16, 2022)

astyle said:


> It's actually amazing how people learned anything about electronics engineering before the advent/consumer availability of Arduino and programmable boards...


For me it started with reading lexicons as a child. At home we have a pile of books where diodes and transistors have been very briefly explained. Later I have borrowed lots of books about home brew hobby electronics from our public library.

At that time some public garbage collection has been taken place two times a year. In case of the city where I lived it has been almost one week, each day in a part of the city. That weeks have been days of horror for my parents because I took lots of broken TV sets and radios to our home. At the beginning I have used the broken sets to collect resistors, capacitors, tubes and semiconductors.

I have used the components to build up simple circuits as flash lights, audio amplifiers and so on. The break through in terms of interest have been detector radios consisting of a coil, a tunable capacitor and a rectifier to receive AM stations. Later I have build simple receivers to listen to citizen band stations and simple transmitters. I still have been a child. This is how everything developed.

Decades later I have been interested in micro controllers. Therefore I have build a programmer for the famous Atmel ATMega family. A few weeks later one of my sons who has been started using computer, programming in Python and so on has become interested in micro controllers. He asked my how or where to purchase some hardware. Fortunately I have had bought spare parts for the programmer in case something has been damaged. So I asked him if he likes to build up a programmer by himself. It took one weekend to teach him using a solder iron and to build up the hardware step by step. Finally it has been a great experience. At the end of the weekend everything has been up and running and we have been very proud. Today he knows where the good and the dangerous end of the solder iron is. He is much better in programming than me but he also has learned to handle periphery of micro controller boards.

Now this post is about learning about hardware design in case of two generations . More important is my happiness that all of my children are better than me in different disciplines, characters or so on.


----------



## SirDice (Dec 16, 2022)

chrbr said:


> Regarding logic which exceeds the standard ICs I have started using GALs. I am not sure if they are still available.


Yes, Atmel GAL22V10 or GAL16V8 for example. I've used these in my own 6502 board for address decoding. Saved me a lot of separate logic gate components. But the software to program these things (WinCUPL) is really old and buggy. Lousy documentation too. Still though, it's been a great introduction in HDL and I've since gotten myself an FPGA development board (CMOD A7-15t) and still on the lookout for a DE-10 Nano (one to experiment with and one to run MiSTer ).



hardworkingnewbie said:


> Ben Eater has been already mentioned.


Yes, his entire channel is awesome, he has a lot more very interesting videos. He explains everything clearly, highly recommended.



richardtoohey2 said:


> There were kits in the 1970s/80s for building your own 6800/6502/Z80 computers.


The most awesome thing about the 6502 and Z80 is that you can still buy these 'old' CPUs, they're still being produced. Which means you can build a 6502 or Z80 system with new, modern components and don't have to source new old stock or second hand.



			https://mou.sr/3TDooXS
		


As for Z80 based systems, the RC2014 project has a lot, you can even run CP/M on it: https://rc2014.co.uk/

If you're not ready yet to buy a bunch of electronic components, I can highly recommend playing with Logisim, project unfortunately has stopped but someone else developed it further: https://github.com/logisim-evolution/logisim-evolution


----------



## smithi (Dec 16, 2022)

richardtoohey2 said:


> There were kits in the 1970s/80s for building your own 6800/6502/Z80 computers.



In Australia c. 1976 were kits using the Signetics (Philips) 2650 microcontroller, on a well-designed backplane/bus system by Bob Armstrong in Sydney.

2MHz 8-bit CPU, 4kB static RAM, simple bit-banging serial i/o for kbd and printer, a wire-wrapped S100 connector for video board to a small ex-bank monitor.

2kB EEPROM monitor/ BIOS/ "OS" driving a custom 3kB/sec audio storage board using regular cassettes, later floppy disk.  Plus two 8kB static RAM boards for 20kB total memory, whoopie!

Another Sydney bloke wrote it a decent line editor and assembler which suited me as a previously mainframe assembly hacker on NCR-315 then IBM S/3{6,7}0.

By 1979, with code and help from the authors of Tiny Pascal (later Tandy TRS-80 Pascal), I'd written it a P-Code "VM" so we had a working (albeit 16-bit integer) Pascal compiler, editor and runtime system as featured in Byte magazine around then.

With the addition of an ancient 50 baud telegraph printer, it served several years at the local Community Centre for mailing address lists, newsletters and such, while entertaining a few mad geniuses.

15 years later I got to play with design and coding a battery cell chsrging system using a pair of Atmel Tiny45s, ah so good to write in raw assembler again, despite the project being abandoned.

Excuse my nostalgia; nothing modern to contribute ...


----------



## Erichans (Dec 16, 2022)

Nice thread.



joshbsd said:


> [...] fundamentals of how computer work at the material level and how it is related to driver kernel and software.


Depending on what you actually want to learn that is quite a span of (domain) knowledge. 



cracauer@ said:


> [...] However, trying to learn a CPU from logic gates up is very challenging.


I think so too. Consider also, hardware projects with “lots of wires” could get you bogged down by electronics/timing issues that have little to do with logical design. I think precise stepped projects like those great ones from Ben Eater could be a good basis to steer you clear of those (mostly). With an Arduino kit you’ll get a lot less wires.

Ben Eater shows you how a small CPU and peripheral components interact, and can be programmed in a simple way (assembler). A nice impression and Q & A of a breadboard CPU is perhaps Tech Talk on Building a Custom TTL CPU

If you want less or no actual hardware and want to concentrate on the logical CPU design, you could opt for design in a hardware description language with simulation, something in VHDL or comparable probably*. I don’t have any current references for that however. 

For an overview, I can recommend  Code: The Hidden Language of Computer Hardware and Software, 2nd edition -  Announcing “Code” 2nd Edition. That may not cover a hands-on practical experience but it does give an overview that addresses your original broad question. Have a look at the contents and preview text; also the companion website that contains interactive examples.

Along the span of low-level hardware (basic TTL circuits) to driver software interactions with the kernel, I suggest you pick a place of interest to start and see what you actually like spending time on.

___
* pre-VHDL during my studies a long time ago, I followed a course in university where we designed and simulated parts of a CPU in APL, including the system clock timing signals. Prof. Gerrit Blaauw, a co-designer of the IBM System/360 architecture, gave the course.


edit: less broad than your question but, as you are already engaged in FreeBSD and mentioned device drivers, I think it's at least worth mentioning:

 The Design and Implementation of the FreeBSD Operating System, 2nd edition by Marshall Kirk McKusick, George V. Neville-Neil
 FreeBSD Device Drivers by Joseph Kong
See: FreeBSD Development: Books, Papers, Slides


----------



## PMc (Dec 16, 2022)

cracauer@ said:


> It is reasonably easy to learn how semiconductors work and how logic gates are made from them.
> 
> However, trying to learn a CPU from logic gates up is very challenging.


Glad You say that. 

I found it easy to understand logic gates, combine them, build some stuff with them.
I also found it understandable how to build an 8-bit computer with a given CPU (there were periodicals for radio-amateurs and electronics hobbyists, and they showed how to do it), and then combine both pieces and build peripherials.
But what stayed obscure to me, for further years, is: how does that CPU work inside? How does it manage to make the assembler commands do the specific thing?


----------



## astyle (Dec 16, 2022)

I touched upon logic gates very briefly in my first year of college - there was one chapter on that in my introductory textbook that was covered for a week in my class. The importance of that didn't quite sink in until later - the logic in C programming (another class that I took the following term) is actually a pretty decent reflection of the hardware logic circuitry... That was kind of the logic of my curriculum - learn some basics, and then learn how those basics can be put together, all the way up to the modern computer.


PMc said:


> But what stayed obscure to me, for further years, is: how does that CPU work inside? How does it manage to make the assembler commands do the specific thing?


It's those exact same breadboard transistors, and the assembler - except that the transistors are 5 nanometers across these days, thanks to Intel and TSMC... Putting it all together, coming up with specific patterns, assigning them meaning, materials research to make the whole thing even smaller, coming up with ways to regulate electrical impulses to do things correctly... all in the name of making that same breadboard power a Threadripper.


----------



## SirDice (Dec 16, 2022)

A few months ago I cleaned out some old boxes. Found my old school project. What we would now call an SBC; 6809 CPU, 6264 (8Kbx8) RAM, 2764 (8Kbx8) EPROM, MC146818 (Real-time clock), 6551 ACIA (serial port) and some glue logic. Built this in 1988. I should fire it up again, see if it still works. Some of the tantalums might be shorted or blow up though, they tend break after 35+ years. 









						6809 based SBC, built in 1988.
					

Imgur: The magic of the Internet




					imgur.com


----------



## Erichans (Dec 16, 2022)

SirDice said:


> [...]  Some of the tantalums might be shorted or blow up though, they tend break after 35+ years.
> 
> 
> 
> ...


Yeah, but nice to see those quality DIP sockets with machine rounded contacts though.
All on—taking an educated guess —an "in-school" designed and etched PCB?


----------



## Jose (Dec 16, 2022)

PMc said:


> But what stayed obscure to me, for further years, is: how does that CPU work inside? How does it manage to make the assembler commands do the specific thing?











						chapter 5 lecture.pdf
					






					drive.google.com
				





Starting at slide 32. Yes, I'm going on like a broken record now.


----------



## hardworkingnewbie (Dec 16, 2022)

richardtoohey2 said:


> There were kits in the 1970s/80s for building your own 6800/6502/Z80 computers.


Well such kits for building retro computers, like Apple I, are still available today. BTW Apple I building are easier to build together than Commodore 64, since the SID chip on C64 was proprietary chip and is no in production any longer. So getting by a SID chip is not so easy to do. 

There is also a thing called the Gigatron TTL Computer, which is a building kit for a simple 8 bit computer using TTL logic chips only, so it has no dedicated CPU. Instead you are building the CPU with these logic chips. Of course this needs some soldering experience to get the job done, but it is targeted at people who want to understand what makes a simple computer tick.





_View: https://www.youtube.com/watch?v=_2uXqTi42LI_


Deeper introduction: 



_View: https://www.youtube.com/watch?v=QUfdASs82Lw_


BTW the whole design of the Gigatron is Opensource, and its sourcecode also under the BSD license.


----------



## smithi (Dec 16, 2022)

Jose said:


> chapter 5 lecture.pdf
> 
> 
> 
> ...



Ok, a successful nag, I grabbed it.  Looks pretty anyway, I may feedback later when I've time to dive in deep.  Cheers


----------



## drhowarddrfine (Dec 16, 2022)

astyle said:


> the logic in C programming (another class that I took the following term) is actually a pretty decent reflection of the hardware logic circuitry..



To this day, when thinking about the flow of a program, I still catch myself sometimes picturing in my mind the address and data lines between the processor and memory


----------



## SirDice (Dec 16, 2022)

Erichans said:


> All on—taking an educated guess —an "in-school" designed and etched PCB?


At that time, the PCB was supplied by the teacher. I'm guessing it was produced at a 'proper' PCB maker but I honestly don't know who designed it. It's a really nice double sided board, soldermasks and everything. Not impossible to do yourself but does require some specialized equipment. Certainly not the kind of equipment the school had in the late 80s. It basically came in a kit and we had to put it together. That said, other lessons did include boolean algebra, reading timing diagrams and working out the glue logic to make the thing work. Then learning how to code for it, learning how to query the I/O chips, interrupts, the whole nine yards. The year after it we had to design and implement a 'daughterboard' for it ourselves. There's a dubbelsided pinheader that basically connects to the CPU bus and the daughterboard plugged into it.  



hardworkingnewbie said:


> BTW Apple I building are easier to build together than Commodore 64, since the SID chip on C64 was proprietary chip and is no in production any longer. So getting by a SID chip is not so easy to do.


The VIC-II (video) was a custom chip too. Impossible to get nowadays. The Apple used a fairly 'simple' circuit to drive the video signal. Easy to reproduce with modern components. You don't have to find a source for 40 year old chips whose production stopped eons ago 

The 6502 is still being produced today. The one I linked earlier is a modern variant, they even fixed some of the bugs of the original 6502. And it runs at a whopping 14 MHz. By comparison the Apple, C64/Vic-20, NES, etc. typically ran at 1 or 2 MHz. I've read an article some time ago about reverse engineering some modern bus controller and it turned out there's a soft-core 6502 running the show internally. Makes sense too, it's a reasonably simple CPU, not a lot of transistors/components. Doesn't take up much space in an FPGA or ASIC, yet it's still quite powerful. 

I've looked around for a 8088 or 8086 but those are not produced anymore. I really would have liked to put together an actual Altair 8088 or IMSAI 8080 clone, a proper clone. I know of the modern replica/clones but they all use an Arduino or ESP32 to emulate the machine. Cool but not the same thing.


----------



## astyle (Dec 16, 2022)

SirDice said:


> I've looked around for a 8088 or 8086 but those are not produced anymore. I really would have liked to put together an actual Altair 8088 or IMSAI 8080 clone, a proper clone. I know of the modern replica/clones but they all use an Arduino or ESP32 to emulate the machine. Cool but not the same thing.


Sometimes, you can find an old, out-of-production device that someone just didn't have the heart to toss out... then you can pull it apart and salvage original circuitry... And who knows, maybe you can get lucky that way.


----------



## richardtoohey2 (Dec 16, 2022)

hardworkingnewbie said:


> So getting by a SID chip is not so easy to do.


There are modern replacements like the ARMSID. Think also similar things for the PLA.
And the ZX Spectrum ULA.


----------



## ralphbsz (Dec 16, 2022)

PMc said:


> https://www.sparkfun.com/products/12614I found it easy to understand logic gates, combine them, build some stuff with them.
> I also found it understandable how to build an 8-bit computer with a given CPU (there were periodicals for radio-amateurs and electronics hobbyists, and they showed how to do it), and then combine both pieces and build peripherials.
> But what stayed obscure to me, for further years, is: how does that CPU work inside? How does it manage to make the assembler commands do the specific thing?



I agree with you to some extent.

WIth a few months worth of effort (evenings and/or weekends), one can understand how transistors and FETs work. Build discrete circuits, which make lights blink or receive and transmit radio waves. Trying this out (breadbording) is relatively simple, with modern tools: Schematic capture followed by simulation, or use an actual breadbord (link goes to a $20 large one), buy the components at Digikey or similar mail-order houses (or sometimes there are still hobby stores that have them in stock).

From there to TTL is not a huge leap: a NAND gate is just a few transistors, and a 74LS00 is nothing but four NAND gates in a convenient 14-pin box. Building small circuits which make lights flash in interesting patterns with TTL chips takes another few hours if one has experience with power supplies, wires, and transistors. You can build counters, you can add numbers (which are input with little switches and displayed bit-by-bit on LEDs), you can build "if statements" (only turn the red LED on if switch 2 and 4 are off).

The next step used to be reasonably easy: Grab an off-the-shelf CPU (like a 6502, 8080, Z80, 6809) running at a reasonably low clock rate (MHz or below), grab some memory chips with TTL interfaces (2764 for ROM, 4164 for RAM), some TTL chips for the glue, and pretty soon you have a functioning computer. The only problem with it: it has no interfaces. Adding a serial port for a terminal and a parallel port for the printer is not that hard, but who even has a terminal or printer these days? And building a video controller is actually hard at that level (BTDT).

Now coming from the other end: Anyone can push icons around on a GUI. From that, learning a CLI and knowing what files are and how to execute them isn't terribly hard. Given that skill set, programming shell scripts or BASIC is a small step, and one can quickly proceed to a serious language (Python for example), and from there to compiled languages. By the time one is programming in C, one knows concepts like bytes and word sizes, reading and writing memory, branching in the code, and if statements. Armed with that knowledge, programming in assembly is tedious, but not very hard.

Once one is writing assembly, it becomes possible to actually write all the software for the computer we built a few paragraphs above. After all, the BIOS is just a few thousand lines of assembly, and then you can find an off-the-shelf BASIC interpreter, or a floppy interface to load a commercial operating system (cp/m or OS-9).

All these are things that an energetic amateur can do, and I've done them all. In my basement is a home-built cp/m machine, with a wire-wrapped CPU and serial/parallel interface board, a few floppy drives, and a home-written BIOS that boots cp/m.

But the one mystery remains: How does the CPU chip work inside? The number of people who know how to understand that is remarkably small. Even in computer science classes, this is not actually taught. One can sort of make an educated guess: bus drivers, a little bit of memory (based on flip-flops) for the registers, an ALU (which is nothing but adders and a bit of control logic), make several copies of that (for example to both be able to add numbers, and to increment the PC and stack pointer), and you're there. It turns out there are textbooks for this, but they are very uncommon. Our (sadly recently deceased) neighbor wrote one of these textbooks, called "Microprocessor Logic Design The Flowchart Method" (it's 35 years old). He literally understood every gate in the Motorola 68000 CPU, because he architected and designed it. Ultimately, the stuff inside the CPU is just a reasonably large number of really simple components (registers, counters, ALUs), each of which is easy to understand.

If someone has a reference for a good modern book on CPU internals, I'd be delighted to hear about it.


----------



## hardworkingnewbie (Dec 16, 2022)

Well, this here is used in many universities as textbook, and covers almost everything:  John Hennessy and David Patterson: Computer Architecture. A quantitative approach. 

It's not cheap, it covers almost everything and is a monster. In case you just want to have a gentler introduction, which keeps is more simple than this book is not for you.






						Computer Architecture
					

<P><EM>Computer Architecture: A Quantitative Approach, Sixth Edition</EM> has been considered essential reading by instructors, students and practitioners of computer design for over 20 years. The sixth edition of this classic textbook from Hennessy and Patterson, winners of the 2017 ACM A.M...




					shop.elsevier.com
				




​


----------



## Jose (Dec 17, 2022)

Holy crap, someone built the Hack computer from Nand2tetris on breadboards using TTL ICs.








						The Hack computer from nand2tetris on breadboards
					

This project is a physical implementation of the Hack Computer, as described in the From Nand To Tetris course (nand2tetris.org). The course describes the hardware design of a simple computer and the software stack on top of it. I implemented the Hack CPU design and my own I/O controllers...




					hackaday.io
				




EE student, and it took him two years. Dunno that I would attempt it.


----------



## PMc (Dec 17, 2022)

ralphbsz said:


> The next step used to be reasonably easy: Grab an off-the-shelf CPU (like a 6502, 8080, Z80, 6809) running at a reasonably low clock rate (MHz or below), grab some memory chips with TTL interfaces (2764 for ROM, 4164 for RAM), some TTL chips for the glue, and pretty soon you have a functioning computer. The only problem with it: it has no interfaces.


Originally I wasn't even interested in computers. I intended to go for audio electronics, stage equipment and such. But then the home computers appeared, and people started to knock on my door: hey, you can solder, can you fix my, whatever, C64 psu? or such. (I actually had the equipment to create pcb as well.)
So I decided to have a look into how that stuff works. Came across something that appeared to be a commodore business machine (6509-based), only to find out that there was no means to store anything permanently.  One would need to buy a floppy drive or such, but that would be business equipment with business price-tags, so no way.
But, the thing should also be able to put data on a cassette. That's probably a pita - but I had an open-reel tapedeck, and that had a remote control, and a real-time tape counter. So it could be steered by the computer, and the computer could get (more or less) accurate information about where on the tape we are - it might do retry-on-error and all such fancy things.
So I started to write a tape storage with directory. It did work (it was painfully slow, obviousely - audio decks are not built for quick positioning), and afterwards I knew how to program. I didn't get further with that, because then the IBM-PC gained momentum and there were more interesting options.



ralphbsz said:


> But the one mystery remains: How does the CPU chip work inside? The number of people who know how to understand that is remarkably small. Even in computer science classes, this is not actually taught.


Hm, I thought there it would. 



ralphbsz said:


> Ultimately, the stuff inside the CPU is just a reasonably large number of really simple components (registers, counters, ALUs), each of which is easy to understand.


A huge amount of these, and very well orchestrated in their interaction. Probably it's difficult because one cannot just grab a few gatters, put them together, then add a few more in the hobbyist way - it needs a good plan to begin with.

But those people who built the 4004 and the other early microprocessors, they didn't start from scratch. There were mechanical calculators before, so the logical requirements were already known.


----------



## drhowarddrfine (Dec 17, 2022)

ralphbsz said:


> If someone has a reference for a good modern book on CPU internals, I'd be delighted to hear about it.


Bit Slice Microprocessor Design by Mick and Brick gets close. I own that plus another one but I can't recall the authors or the title.
I did study on my own transistor level design but never finished. I got to the point where I could tell which part of an Xrayed chip did what.


----------



## richardtoohey2 (Dec 17, 2022)

Lots of interesting stuff here:









						How the 8086 processor's microcode engine works
					

The 8086 microprocessor was a groundbreaking processor introduced by Intel in 1978. It led to the x86 architecture that still dominates de...




					www.righto.com


----------



## Profighost (Dec 19, 2022)

Discrete logic IC CPU


----------



## hruodr (Dec 19, 2022)

In a course of Computer Architecture we used many, many years ago, in the 1980s, a book by Hill and Peterson.
I do not remember the title, but was very clear, easy to read.

Sure outdated, it was oriented to design something like a PDP 11, or perhaps a mainframe, it used as 
hardwaŕe design language something like APL. But I think, perhaps some concepts are till today the same.


----------



## joshbsd (Dec 19, 2022)

hruodr said:


> In a course of Computer Architecture we used many, many years ago, in the 1980s, a book by Hill and Peterson.
> I do not remember the title, but was very clear, easy to read.
> 
> Sure outdated, it was oriented to design something like a PDP 11, or perhaps a mainframe, it used as
> hardwaŕe design language something like APL. But I think, perhaps some concepts are till today the same.











						Digital systems: hardware organization and design | Semantic Scholar
					

This heavily revised edition of the well-received text teaches the organization and design of complex digital systems through a register-transfer and control-sequence design language--A Hardware Program Language (AHPL), through which the design of a wide variety of digital hardware systems is...




					www.semanticscholar.org
				





Fredrick J. Hill_ Gerald R. Peterson - Digital Logic and Microprocessors (1984)

?


----------



## hruodr (Dec 19, 2022)

joshbsd said:


> Fredrick J. Hill_ Gerald R. Peterson - Digital Logic and Microprocessors (1984)


No, no microprocessors. It was the first: "Digital Systems: hardware organization and design".
It was very clear how the APL dialect "compiled" to a circuit with flip-flops. How a computer is built in that way.
A very nice book.

Something that I remember, was, that the price of using the hardware description language, was that
one needed more flip-flops. I can imagine that today there are ways to optimize it?


----------



## hruodr (Dec 19, 2022)

cracauer@ said:


> However, trying to learn a CPU from logic gates up is very challenging.


No, it is not. At least not for an old computer. It is on a different level of abstraction. The above book is for that purpose.


----------



## Crivens (Dec 19, 2022)

hruodr said:


> Something that I remember, was, that the price of using the hardware description language, was that
> one needed more flip-flops. I can imagine that today there are ways to optimize it?


Oh yes. Sometimes the compiler pulls tricks you did not think about. But it sometimes performes at glacial speed. Friend of mine did a design that took 7h for a turnaround. He also is in the altera(?) regression test set with a "design from hell", where he left 4 blocks unused and partly wired the rest in such a way that the router could do it. The next stages started pulling assert()s of the "How the hell did we get here?" type.
Did I mention he is a highly functional authist?


----------



## Jose (Dec 27, 2022)

SirDice said:


> I would suggest starting with an 8 bit CPU based computer. It's simple enough to wrap your head around the whole concept. The fun thing is that today's modern 64 bit computers aren't that different, they still use the same concepts, only much more complex.
> 
> 8 bit 6502 based computer:
> 
> ...


Man, those Ben Eater videos are amazing! I couldn't stop watching them.


----------

