Lably
Skip to content

Hardware abstraction

Software that hides details of hardware access

  • 5 min read
  • 2 chapters

Related on Lably

Through Software, Computer hardware and Interface (computing)

Early software was developed without a hardware abstraction, which required a developer to understand multiple devices in order to provide compatibility. With hardware abstraction, the software leverages the abstraction to access significantly different hardware via the same interface. The abstraction (often implemented in the operating system) then performs the hardware-specific operations. This allows software to be compatible with all devices supported by the abstraction.

Consider a joystick device, of which there are many physical implementations. It could be accessible via an application programming interface (API) that supports common operations such as moving, firing, configuring sensitivity, and so on across variety of different joysticks. A Joystick abstraction hides details (e.g., register format, I2C address) so programmers using the abstraction do not need to understand details regarding the device's physical interface. This also allows code reuse since the same code can process standardized messages from any kind of implementation which supplies the joystick abstraction. For example, a "nudge forward" can be from a potentiometer or from a capacitive touch sensor that recognizes "swipe" gestures, as long as they both provide a signal related to "movement".

As physical limitations may vary with hardware, an API can do little to hide that, other than by assuming a "least common denominator" model. Thus, certain deep architectural decisions from the implementation may become relevant to users of a particular instantiation of an abstraction.

A good metaphor is the abstraction of transportation. Both bicycling and driving a car are transportation. They both have commonalities (e.g., it must be steered) and physical differences (e.g., power source). One can always specify the abstraction "drive to" and let the implementer decide whether bicycling or driving a car is best. The "wheeled terrestrial transport" function is abstracted and the details of "how to drive" are encapsulated.

Programming

A high-level programming language provides for hardware abstraction by allowing a programmer write an algorithm without using instructions that are unique to a central processing unit (CPU) or its instruction set architecture (ISA) – the primitive operations of a CPU. For example, a compiler generates the CPU-specific instructions for a particular ISA. In this way, source code can support portability across multiple platforms.

Sign in to keep reading

One more chapter is free with a Lably account.

More in Computing and communication