Search code examples
hardwaredevicecpuprocessorcpu-registers

Does devices have registers?


I have always heard registers as CPU registers. Does other devices or hardware also have its own registers like a decoder hardware, a display device, a DMA controller?

If so, how are the values stored in those device registers passed to cpu registers in case they are necessary for an instruction execution? Can any of you explain, if possible with a real world example?


Solution

  • Some devices have dedicated registers and others don't. Some of those other ones have register-like components that get lumped into the "register" category even though they shouldn't really be there.

    I/O between the device and the rest of the system can happen in a number of ways, including port based IO (a system similar to, but seperate from, typical memory access), memory based IO (use of specific addresses as control addresses, into and from which data can be moved to and from the device), or direct memory access (in which the device is capable of autonomously accessing system memory through the memory bus).

    A friend of mine wrote a Port IO based SATA HDD driver, however most modern OSs use DMA for those because it's less CPU intensive.

    Devices like graphics cards, which contain their own processing units, contain true registers used for processing. They, to the best of my knowledge, are not available directly to the processor, but the processor can (presumably through a combination of port based IO and DMA) provide executable data to the GPU which it can then execute, and it can store the output of its computations on the onboard device memory, which can be accessed through DMA.