How do a computer’s hardware and software actually connect?

261 viewsOtherTechnology

How do a computer’s hardware and software actually connect?

In: Technology

16 Answers

Anonymous 0 Comments

I’m not sure what you mean by “connect”. The software runs on the hardware. Basically, there if a small bit of a program, called firmware, that is part of the electronics. When you power up, this hardware stuff says “look at address xxxx for a program, and run it”. Then the hardware electronics main job is to just follow the instructions that it finds. On a modern computer, of course, those instructions are incredible complicated and touch many parts of the hardware, but at its heart, that is all it is doing.

There are a bunch of systems in the hardware, of course, that do various things, such as watch the mouse action and report it to other parts.

Anonymous 0 Comments

So you the Operating System, in most cases this is Windows. The core of the operating system is called the Kernel. It’s where almost all the calculating and decision making takes place.

Then you have the Hardware Abstraction Layer, or HAL. This virtualizes the hardware so that the kernel can communicate with it, give it instructions and receive data from it. Either the OS kernel has drivers built in, or the hardware manufacturer supplies them.

For this to work, the hardware has to have a program of it’s own that allows it to speak the same language as the OS. This program, embedded into the hardware, is called firmware.

Anonymous 0 Comments

A way that I like to think about it is that there isn’t much of a difference between hardware and software when you look at how it works at the lowest level. “Hardware” is really just a bunch of a really complicated electrical circuits. “Software” is the physical electricity that runs through those circuits at different times, places, and speeds – which is used to create patterns that represent meaningful data.

Anonymous 0 Comments

The same way ink in shapes on paper (or a screen) “connect” with words…because we assign meaning to physical patterns.

The computer only has hardware. Software is the meaning *we* attach to particular states of hardware. The computer is just blindly running very complicated electrical circuits with varying voltages. We assign meanings (usually “1” and “0”) to the voltages, and by wiring it up in clever ways we can make it do way more complicated things like light up colored lights in the right pattern to make a picture and things like that, but the computer has absolutely no idea that’s what it’s doing. Just like your screen doesn’t “know” that this is a reddit post with any meaning to anyone…it’s just a complicated pattern of high and low voltages on wires and electrical components.

Anonymous 0 Comments

All computer code ultimately boils down to 1s and 0s, or highs and lows. Computer chips are meanwhile essentially billions of high/low “switches.”

So all software is essentially the 1s and 0s of code being represented in physical form on the billions of switches on computer chips’ circuits, which get flipped billions of times per second.

Anonymous 0 Comments

A computer program is “compiled” into machine code, which is a complex series of simple instructions. “Read that memory location”, “add that value to another value”, “if that result is bigger than 5, skip ahead 5 instructions”. The computer processor knows how to follow those instructions.

There’s more hardware than just the processor, so the processor needs to provide a way to interact with that hardware. There’s a couple ways that’s typically done. One way is by having specific instructions built into the processor. “Turn on the blinky light”. That was very common many decades ago, but most computers don’t work that way anymore. Another way is to make the hardware appear as if it were memory. “Write the value 1 to the memory location corresponding to the blinky light”.

Anonymous 0 Comments

Computer chips are made of circuits called logic gates. Some of these gates hold a position of on or off. Others do things like directing a signal to one place or another. There are sets of the circuits that hold the value called a register. Many registers are lined up similar to a list of instructions. There are 2 things in a register. A set of bits that determines what set of circuits are activated and a set of bits that is connected to those circuits. There’s a special set of bits called a program counter. That determines what register is activated and therefore what additional circuits are activated and what bits are fed into those circuits. The program counter starts at the first register (step one) and goes through them sequentially unless told otherwise. Like if step 8 says go to step 4 if bit 4 is 0. There are lots of sets of circuits that can be activated. Like add these 2 numbers. Move these bits one place to the left. Write this number to this register. Etc. when we write software, we’re just setting the bits in the registers. Programming languages are just ways to set bits. The “lowest level” language is assembly. This if a set of words that directly translates to what bits get set. “LSL” is logical shift left. Meaning activate the circuit that moves bits one spot to the left. C is the language the next level up. In C you can write things like “int A = X + Y;” this translates to “dedicate a register to hold A. Get the values from the registers that contain X and Y. Add them together and store the result in A. Disclaimer that this is not how modern computers do things and even when it was this isn’t 100% accurate. It’s just a lot of details to go into.

Anonymous 0 Comments

The short and real answer is ‘firmware’. Each piece of hardware is programmed by the manufacturer with something called firmware, it is like the middle ground between ‘software’ and ‘hardware’. This firmware will control the basic function of the hardware the operating system is trying to use. In order to access that firmware for the operating system, the operating system needs something called a ‘device driver’. That is a special piece of software that translates the operating system’s desires to the hardware’s function. Although it is old now, I used a DVD-ROM as an example. Windows or Mac has no idea how to spin up a DVD ROM. It doesn’t know where to point the laser, it doesn’t know what RPM it needs to spin at, it doesn’t know anything. That is controlled by the firmware and the device driver allows the operating system, and by extension some application developer, a simple way to use a piece of hardware without having to learn everything about it.

Say I am an application developer and I have a piece of hardware that scans inventory. I need to be able to do things like fire the scanner off and read what comes from it. So, I download the device’s driver and that will usually give something called an API or something like it. Using the API documentation I program my crappy software to utilize this scanner. Instead of learning all the ways this scanner works and its circuitry, I read the documentation from the developer who wrote the driver and I find the ‘scan’ function and then I can do something with that data I get back from the API.

A really popular, nowadays, driver API is the CUDA API that goes along with NVIDIA graphics cards. To connect my software to that hardware so I can run really complicated models I find the driver guide (https://docs.nvidia.com/cuda/cuda-runtime-api/index.html) and I program my software to access the API when I need to do some hefty 3d modeling or something.

Anonymous 0 Comments

I’ll try and fill the gaps that I feel aren’t quite being addressed yet. We’ll use a basic microcontroller as an example, the kind you would find in consumer electronics.

A microcontroller is basically a large amount of tiny transistor switches crammed into a miniature circuit. We control these in an on/off manner, which in actual reality, is defined by voltages – 2.0 to 3.3V might count as ‘on’, and 0 to 1.5V might count as ‘off’. The unaccounted gap in the middle is too ambiguous and close to either of them, so we avoid it. To make this useful in a logical sense, we decide to name high/low as 1 and 0 in the digital world. At its core, it’s really all there is to it.

If you do a rough overview of digital logic, you’ll see how you can start arranging your 1’s and 0’s into basic logic gates, just based on chaining switches together. If you’re a Minecraft person, redstone logic is a really interactive way of seeing this. It seems basic at first (what the hell do you do with an AND or OR gate?), but when you take into account that a CPU such as an Intel i9 has around *10 billion* switches inside it, you can see how you can start to turn it into something useful.

Then, we came up with ways to interpret all the 1’s and 0’s. Basically, we pick which set of ‘rules’ we agree on, and then we can interpret it as information. Like Morse code – they’re all dots and dashes, but we made up a set of language rules to turn them into letters. This applies to how we send information over connections, how fast we are sending it, how to interpret numbers and characters, and basically everything else you can think of. Everything comes down to these high and low voltages, and what we’ve decided it all means.

If I send info from my PS5 from my TV, we’re agreeing that we are using HDMI to do so. HDMI is a standard that tells us exactly how those two things should be connected, and exactly what those 1/0 signals represent. The PS5 has it’s own software to make decisions on what to send, and the TV has its own software on what to display on its screen. The fact that we have a universally agreed upon set of rules, is the only reason that sending random voltage signals means anything to either of them. If they aren’t on the same page, it’s suddenly meaningless. Just like if we use the same letters, but one thinks we are talking French, while the other is expecting Italian. There are many different variations of ‘language’, both in what the data means, but also the physical way they are connected and controlled. USB protocols are an incredibly common one too.

A microcontroller has memory, so it can store 1’s and 0’s that it needs to park temporarily (or long term), for use later. It also has control of pins, which allow us to connect it to other things. According to its instructions, it can check to see if something else has made this pin a 1/0, or it can set that pin to 1/0.

The magic that ties it all together is the programming. We write the behaviour of the device and the decisions it’s making, as a complex set of checking and changing values. For example, we might say ‘check pin 1 -> if it’s high -> set pin 2 to high’. Pin 1 might be a button, pin 2 might be an LED. So now we have a program that turns on a light when you press a button. Write up a very complex version of this sort of process, and this is how we tie together all of the different inputs/outputs and decisions made based on those. When we write code on our computer, some very fancy compiler software turns it from the human readable form that we’ve created, into a set of instructions specific to that machine. This is going right back to basics and fundamentally controlling all of those billions of switches in a way that actually matches our code

Anonymous 0 Comments

There are layers of increasingly complex software that tell the hardware what to do. The entire system runs on binary code. For software, that means 1s and 0s. For hardware, it means on or off and that refers to electrical circuits. Every computer has a basic set of instructions hard coded onto a microchip that triggers when you power on the computer. It wakes up all the hardware, runs a quick diagnostic, and then triggers the next layer. The last thing before you take over is the operating system, like Windows, being loaded from wherever it’s stored, usually a hard drive or SSD.