1. Field of the Invention
The invention relates in general to a method for decrypting a signal, and more particularly to a method for decrypting a serial transmission signal.
2. Description of the Related Art
The serial transmission technology has been widely adopted between a transmitting terminal and a receiving terminal, and a serial transmission signal therebetween includes a serial data signal and a serial clock signal. FIG. 1 (Prior Art) is a schematic illustration showing a conventional serial transmission signal. Referring to FIG. 1, the serial transmission signal includes a serial data signal Data and a serial clock signal SCK. The serial data signal Data includes multiple bits, such as a set of command bits, a set of address bits, a set of data bits or a set of special bits. The set of special bits may include a start bit (start), an acknowledging bit (ack) or a stop bit (stop). The serial clock signal SCK includes multiple timing pulses, and each bit of the serial data signal Data is read, based on each timing pulse, in an edge triggered or level triggered manner.
FIG. 2 (Prior Art) is a flow chart showing a conventional method for decrypting the serial transmission signal. First, in step 210, a serial transmission signal including a serial data signal and a serial clock signal is received. The serial clock signal includes multiple timing pulses. Next, in step 220, an interrupt service function is triggered to read the corresponding bit, based on the timing pulse, in the edge triggered or level triggered manner.
As shown in FIG. 1, a main program of the receiving terminal triggers the interrupt service function at a rising edge (time t1) of one timing pulse of the serial clock signal SCK. At this time, the main program pushes a program address to a stack, and then executes the interrupt service function and jumps to enter a sub-program to perform a reading operation. Thereafter the corresponding bit is completely read before a falling edge (time t2) of the same timing pulse, and then the program address is popped from the stack so as to perform the original main program.
Thereafter, in step 230, it is determined whether the received bit is a command bit, an address bit, a data bit or a special bit, and the received bit then is stored to a corresponding position of a register by way of rotation. FIG. 3 (Prior Art) is a schematic illustration showing the conventional method for storing data to the register by way of rotation. As shown in FIG. 3, if the receiving terminal receives thirteen data bits as one data byte, the register 300 is a thirteen-bit register and the initial value of the register 300 is (0 0 0 . . . 0 0)2, for example.
If the data byte is, for example, (b12 b11 b10 . . . b1 b0)2=(1 0 1 . . . 1 0)2, the thirteen data bits are sequentially stored to corresponding positions of the register 300 by way of rotation. First, the bit b12 is stored to the memory cell a0. Next, the bit b12 stored to the memory cell a0 is shifted to the memory cell a1 to complete a first rotation operation. Thereafter, the bit b12 stored to the memory cell a1 is shifted to the memory cell a2 to complete a second rotation operation. After twelve rotation operations have been performed, the bit b12(=1) is stored to the memory cell a12. Thereafter, the bit b11(=0) is stored to the memory cell a11 according to eleven rotation commands. Then, the bit b1(=1) is stored to the memory cell a1 according to one rotation command. The bit b0(=0) is finally stored to the memory cell a0.
In step 240, the receiving terminal determines whether the storing operation finishes after each bit is stored. If the storing operation is not finished yet, the procedure goes back to the step 220 to continue reading the subsequent bits. If the storing operation is finished, the procedure enters step 250. In the step 250, the receiving terminal decrypts the byte stored in the register and performs a corresponding process.
The conventional method for decrypting the serial transmission signal has to push the program address to the stack in the step 220 so as to trigger the interrupt service function and jump to the sub-program, and also has to pop the program address from the stack so as to jump back to the main program. Thus, the processor of the receiving terminal needs a lot of system clock cycles to finish the operation of receiving one bit. Therefore, if the number of bits of the serial transmission signal increases and the transmission speed is required to be higher, the calculation loading of the processor of the receiving terminal will get higher and the efficiency of the processor will be reduced. In addition, if the number of bits of the serial transmission signal increases, the number of rotation commands to be performed in the step 230 will also increase so that the calculation loading of the processor thus get higher. Meanwhile, the cost is increased and the power consumption of the processor of the receiving terminal is increased.
USPTO Backgrounds
USPTO Backgrounds