How to implement binary additions by logic circuits
The first binary addition can be disassembled into two steps: Add and carry.
+ Addition |
0 |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
+ Rounding |
0 |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
Add this step can be done by the XOR gate, carry this step can be used with the door to complete.
However, the two logic gates can only be composed of one half adder, input 2 values, output plus and bit and carry. This is not enough, except that the minimum bit of addition does not require a carry mate, and the addition of the other bits is to be rounded up and added together with the input.
So you need to be able to have 3 inputs with 2 outputs of the full add-on. This can be made up of two semi-converters.
Implementation of subtraction
We can use the adder to achieve subtraction, first of all, a simple mathematical deduction.
253-176
= 253-176 + 1000-1000
+ = 253-176 + 999 + 1-1000
= 253 + (999-176) +1-1000
(999-176) can be called the complement of 176 to 9, so if we ignore-1000 (can be ignored, because if our output bit is only 3 bits then the fourth bit on the 1 is not output), then the addition of three can be done by a subtraction operation.
(999-176) +1 can be called a complement of 10.
This is the derivation under the decimal, same as in binary. 、
So the subtraction of a number can be added to this number of complement (binary is to 2 to complement, the decimal is to 10 to complement) can.
How to implement Storage
There are two kinds of stable circuit, can record binary system digital signal "1" and "0, this is the trigger."
The basic RS trigger, also known as the SR latch, is the simplest of the triggers and the basic component of various other types of triggers. A basic RS trigger can be formed by cross-coupling or termination of two inputs at the output end of a non-gate or non-gate.
How to implement addressing
To achieve a basic storage, only the storage function is not enough, but also to have a choice of storage and reading function is to have the ability to address.
If we have 32-bit binary to address, then we can select 232 units of data, if a unit of data is a byte, then the 32-bit address end can store up to about 4GB of data. That's why, as the computer's memory gets bigger, we're switching to 64-bit CPUs and systems. Because more than 4GB of storage, 32-bit is not addressable.
Why byte and 16-bit binary
The bit width in the early adder is 8 bits, which now represent a set of 8-bit data in bytes.
A byte has 8 bits, its value range is 00000000 to 11111111, can also represent a positive integer between 0~255, through the complement can also represent a positive, negative integer in the -128~127 range. Although a 8-bit binary 10110110 is natural and intuitive, it is not concise enough. This is what we can use 16-bit binary to express. A 16-bit binary number can express a 4-bit binary that is half a byte. So a byte requires only 2 16-bit binary lines, 10110110 can be split into 1011 and 0110, i.e. b6h (h indicates that this is a 16-bit binary number) expression.
How to implement automatic operation
First we have an oscillator that automatically outputs 0 and 1 without the need for manual intervention. It is often called a clock because it can be timed by oscillation. A cycle is a period in which an oscillator is returned from an initial state over a period of time and back to its previous initial state, also known as a cycle. The inverse of the cycle is the frequency of the oscillator (frequency), e.g. 20Hz means that the oscillator produces 20 cycles per second.
We can use the oscillator to achieve a counter, can cycle count. For example, a 16-bit counter can accumulate 000H~FFFFH.
The code stored in RAM is divided into 2 types: one is an instruction that allows the circuit to do what it does, often containing the address to manipulate the data. The other is the code that the data is to be executed.
A counter is a circuit that can accumulate continuously, but the code stored in RAM is often not sequential, so we need a way to re-select the command to start executing the code, i.e. jump, which can be achieved by resetting the counter.
What is a bus
Busis the way to standardize the exchange of data between computer components, that is, to provide data transfer and control logic for each component in a common way. From another point of view, if the motherboard (mother Board) is a city, then the bus is like a bus in the city, able to follow a fixed route, the transfer of back and forth bits (bit). These lines can only be responsible for transmitting one bit at a time. Therefore, multiple lines must be used at the same time to send more data, and the bus can simultaneously transmit the number of data called width (width), in bits, the greater the width of the bus, the better the transmission performance. The bandwidth of the bus (that is, the total number of data that can be transmitted in a unit of time) is: bus bandwidth = frequency x Width (bytes/sec).
There are generally five kinds of buses on a PC:
- Data bus: Transfers data between the CPU and RAM that need to be processed or stored.
- Address bus: Used to specify the address of data stored in RAM (Random Access memory).
- Control bus: The signal of the Microprocessor control unit is transmitted to the peripheral device, which is commonly used for USB bus and 1394 bus.
- Expansion bus (Expansion bus): Can connect expansion slots and computers.
- Local bus: An extension bus that replaces higher-speed data transfer.
Fixed-point and floating-point numbers
First, we introduce the following BCD code (binary-coded decimal), which is a binary encoded form with binary coded decimal code. Use a 4-bit binary number to represent the 10 digits of the 0~9 in the 1-bit decimal number. Because 2 of the complement is not used with the BCD code, the BCD code needs to be incremented to indicate a negative number.
For example, -4,325,120.25 can be represented as the following 5 bytes:
00010100 00110010 01010001) 00100000 00100101
14h 32h 51h 20h 25h
In the example above, the decimal point is before 2 decimal places. Information about the location of the decimal point is not stored in the number, and its position is fixed.
The storage and tagging method based on this binary is the fixed-point format (fixed-point format).
As the name implies, floating point is the position of its decimal point is indeterminate. The second binary storage method is as follows:
Sign is the symbol bit, exponent is the digit (single-precision 8-bit, double-precision 11-bit), fraction is a valid bit (single-precision 23-bit, double-precision 52-bit).
This is not quite like the scientific notation that we usually use.
But this approach poses a problem, that is, when the effective bit exceeds a certain time, there will be a precision problem.
// true // false
Yes, it's equal.
Because the first two will be stored as 1.000 ... (52 x 0) x253
9007199254740994 will be saved as 1.000 ... 0001x253.
The effect of the accuracy of the factor is the effective bit, in the double-precision condition of the effective bit is 53 bits (including the sign bit), because of the 210~103, so the double precision can guarantee 15 bits of the decimal effective number, single precision is 7 bits.
"Code:the Hidden Language of computer Hardware and software"--notes