Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hardware/Software Implementation

Tags:

c

What does it mean to say that a function (e.g. modular multiplication,sine) is implemented in hardware as opposed to software?

like image 208
smilingbuddha Avatar asked Apr 21 '11 21:04

smilingbuddha


2 Answers

Implemented in hardware means the electrical circuit (through logical gates and so) can perform the operation.

For example, in the ALU the processor is physically able to add one byte to another.

Implemented in software are operations that usually are very complex combinations of basic implemented in hardware functions.

like image 169
Sword22 Avatar answered Oct 21 '22 16:10

Sword22


Typically, "software" is a list of instructions from a small set of precise formal instructions supported by the hardware in question. The hardware (the cpu) runs in an infinite loop executing your instruction stream stored in "memory".

When we talk about a software implementation of an algorithm, we mean that we achieve the final answer by having the CPU carry out some set of these instructions in the order put together by an outside programmer.

When we talk about a hardware implementation, we mean that the final answer is carried out with intermediate steps that don't come from a formal (inefficient) software stream coded up by a programmer but instead is carried out with intermediate steps that are not exposed to the outside world. Hardware implementations thus are likely to be faster because (a) they can be very particular to the algorithm being implemented, with no need to reach well-defined states that the outside would will see, and (b) don't have to sync up with the outside world.

Note, that I am calling things like sine(x), "algorithms".

To be more specific about efficiency, the software instructions, being a part of a formal interface, have predefined start/stop points as they await for the next clock cycle. These sync points are needed to some extent to allow other software instructions and other hardware to cleanly and unambiguously access these well defined calculations. In contrast, a hardware implementation is more likely to have a larger amount of its internal implementations be asynchronous, meaning that they run to completion instead of stopping at many intermediate points to await a clock tick.

For example, most processors have an instruction that carries out an integer addition. The entire process of calculating the final bit positions is likely done asynchronously. The stop/sync point occurs only after the added result is achieved. In turn, a more complex algorithm than "add", and which is done in software that contains many such additions, necessarily is partly carried out asynchronously (eg, in between each addition) but with many sync points (after each addition, jump, test, etc, result is known). If that more complex algorithm were done entirely in hardware, it's possible it would run to completion from beginning to end entirely independent of the timing clock. No outside program instructions would be consulted during the hardware calculation of that algorithm.

like image 3
Jose_X Avatar answered Oct 21 '22 16:10

Jose_X