Register control apparatus and method thereof for allocating memory based on a count value6421825Abstract In a register controlling apparatus, whenever a routine is run, a register logicalal address, and the values of a local register pointer and a local register counter are selectively added, and thereby a register physical address and a new value of the local register pointer are outputted, resulting in the setting of the register available domain. Then, when the routine returns to a higher order routine, the set register available domain is released to be called by another subroutine, and further, when a register in another routine is accessed in an arbitrary routine, the register logical address is outputted as the register physical address to achieve the accessing, resulting in accomplishing an enhanced application efficiency of the register and an easy processing of a routine using many registers. Claims What is claimed is: Description BACKGROUND OF THE INVENTION
Routine A( ) { : declaring a high order routine
integer R0 , R1 , R2 , . . . , R10 ; : arraying the registers used in
the routine A
. : the program text
subroutine B( ) : calling a subroutine B
. : the program text
} : terminating routine A
Subroutine B( ) { : setting a subroutine B
integer R11, R12, . . . , R 17 : arraying the registers used in
the routine B
. : the program text
} : terminating subroutine B
That is, when allocating the programs, as shown above, the subroutine B should know in advance that registers R0-R10 will be used in the routine A due to the characteristic that a register having a specific address is used only in a specific routine. Therefore, when a register is to be used in each routine through some program, as shown in FIG. 3, the CPU 1 accesses a register allocated in each routine (A, B, C, . . . , N) in accordance with the flow of the program. However, in the above-described procedure, it is very difficult to create a program because a register domain used by each routine should be set in advance when creating a program, and a register having a specific address has a low usage efficiency since the register having the specific address can use only the specific address. Further, since the above-mentioned program is not proper for a high level language, especially for a C programming language, a low level language such as an assembly language should be disadvantageously used. In addition, although, a program managing a register (or a memory) may be added when compiling a program to prevent the above-described problem, the size of the program is enlarged and the running speed is undesirably slowed down. FIG. 2 is another embodiment of the conventional register controlling apparatus, wherein to solve the above-described problem, a higher performance RISC type CPU is substituted for the CPU 1 in FIG. 1, and the entire register range is divided into N register banks (4-1, 4-2, . . . , 4-n) to be used as the memory 2. Here, the RISC type CPU 3 has tens or hundreds of registers. That is, the entire register range is divided into 2-16 banks and each bank includes eight or sixteen registers. This conventional register controlling apparatus will now be described in detail. First, when the user runs a program and performs an arbitrary routine, the RISC type CPU 3 selects one register bank in a register stack divided into the N register banks 4-1, 4-2, . . . , 4-n. Then by using a register allocated in the selected register bank, the present routine is run. When the user calls a subroutine from the present routine which is a high order routine, the called subroutine automatically selects the next register bank in the register stack divided into the N register bank 4-1, 4-2, . . . , 4-n to run the program and then returns to the high order routine when the running of the program is done. When the subroutine returns to the high order routine, since the register bank which the subroutine selected and used is automatically released, the register bank can be reused when the subroutine is called from the high order routine next time. That is, as shown in FIG. 4, when a subroutine B is called while using the register Bank04-1 in a high order routine A, the called subroutine B uses the next register Bank14-2, and then returns to the high order routine A and the selection of the register Bank14-2 is released. Then, when a subroutine C is called from the high order routine A, the called subroutine C can also use the register Bank14-2 used in the subroutine B, and when a subroutine D is called from the subroutine C, the called subroutine D can use a next register Bank24-3. When the selected register Bank24-3 returns to the high order routine C from the subroutine D, the selection of the register Bank24-3 is released. Therefore, when a subroutine E is called from the subroutine C, the called subroutine E can use the register Bank24-3 used in the previous subroutine C. Therefore, in this conventional register controlling apparatus, when a subroutine is called from a high order routine to run a program and returns to the high order routine, since the register bank used in the previous subroutine can be used in another subroutine, the register controlling apparatus can achieve improved application efficiency of the register, while remaining suitable for the processing of the program created in the C programming language. However, in another embodiment of the conventional register controlling apparatus, since the entire register complement is divided into a predetermined number of register banks, registers are sometimes lacking or overabundant depending on the run routine, resulting in the undesirable lowering of the application efficiency of the register. That is, in some specific subroutines so few registers are used that many unused registers remain, while in other subroutines, subroutines are called continuously enough to exceed the number of register banks primarily because, the registers of one bank that service one routine can not be used in servicing another register even if they are not being used, resulting in the lack of available registers. In addition, when a parameter between each routine in a C programming language is set to be an address of an arbitrary variable, a variable of one routine is difficult to access from another routine. SUMMARY OF THE INVENTION Accordingly, it is an object of the present invention to provide an improved register controlling apparatus which is capable of setting the number of registers used by each routine suitably depending on each routine, and of processing the calling of subroutines until all the registers are used when each routine uses a small number of registers. It is another object of the present invention to provide an improved register controller which is capable of setting an available register domain by selectively adding up the values of a register logical address and a local register pointer from CPU and the value of a local register counter and of performing the continuous calling of another subroutine from a higher order routine by releasing the set register available domain when a subroutine returns to a higher order routine. To achieve the above object, there is provided an enhanced register controlling apparatus which includes a CPU for outputting the values of the register logical address, a first control signal and local register pointer, and the number (count value) of available registers, a register controller for selectively adding the values of a register logical address and a local register pointer, and the number (count value) of available registers and outputting a register physical address, and a memory for writing data in a domain set by the register physical address of the register controller or reading the written data. To achieve another object of the present invention, there is provided a semiconductor apparatus in which a register controller controls the creation and access operation of a register physical address for the storing domain of a memory, wherein the register controller include a control circuit for outputting first and second control signals, respectively, in accordance with the control of a CPU, a local register pointer for setting a start address of register domains which will be used in a presently running program routine, a local register counter for setting the number of registers which will be used in the present/y running program routine, and an adder for adding the register logical addresses outputted from the CPU in accordance with the first control signal from the control circuit and the values of the local register pointer and then outputting a register physical address. BRIEF DESCRIPTION OF THE DRAWINGS The present invention will become more fully understood from the detailed description given hereinbelow and the accompanying drawings which are given by way of illustration only, and thus are not limitative of the present invention, and wherein: FIG. 1 is a block diagram of a register controlling apparatus according to the conventional art; FIG. 2 is a block diagram of another register controlling apparatus according to the conventional art; FIG. 3 shows an example of the running order of a program and the setting of a register available domain in the apparatus of FIG. 1; FIG. 4 shows an example in which a register bank is used according to the running order of the program according to the conventional art; FIG. 5 is a block diagram of a register controlling apparatus according to the present invention; FIG. 6 is a detailed block diagram of a register controller in FIG. 5; FIG. 7 shows an example of a running order of a program in the inventive apparatus FIG. 5; and FIGS. 8A through 8D are views showing examples of how a register available domain is set depending on the running of the program in FIG. 7. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS As shown in FIG. 5, a register controlling apparatus according to the present invention includes a CPU 10 for outputting register logical address (RL) values, a control signal (CS) and a local register pointer when a program routing is selected and the number (count value) of available registers, a register controller 20 for selectively adding the values of the register logical address RL and the local register pointer, and the number (count value) of available registers in accordance with the control signal (CS) from the CPU 10 and for outputting a register physical address (RR), and a memory 30 for writing data in a domain set based on the register physical address (RR) from the register controller 20 or reading the written data. As shown in FIG. 6, the register controller 20 includes a control circuit 21 for outputting control signals (CTL1, CTL2) in accordance with the control signal (CS) from the CPU 10, a local register pointer 22 for receiving, storing and outputting the value of a local register pointer denoting a start address of a register domain from the CPU 10, a local register counter 23 for receiving, storing and outputting the number (count value) of the registers from the CPU 10, and an adder 24 for selectively adding up the number of the register logical address (RL), the start address of the register domain and the count value of the registers in accordance with the control signal CTL1 from the control circuit 21 and outputting a register physical address (RR). The adder 24 outputs the register physical address (RR) corresponding to the register logical address (RL) in accordance with the control signal (CTL1) from the control circuit 21, or adds the values of the register logical address (RL) and the local register pointer 22 and then outputs the register physical address (RR), or adds the values of the local register pointer 22 and the local register counter 23 and outputs a new pointer value to the local register pointer 22. The local register pointer 22 outputs the value of the pointer stored in accordance with the control signal (CTL2) or performs the inputting and outputting of data through the data bus. The local register counter 23 outputs the number (count value) of the register stored in accordance with the control signal (CTL2) or performs the inputting and outputting of data through the data bus. Referring to the accompanying drawings of the block diagrams, the register controlling apparatus according to the present invention will now be described. Assume, for example, that the running order of the program set by the user will be performed as shown in FIG. 7. First, when a routine A is run, the CPU outputs a register address from which the routine A starts and the number of registers available to the routine A to the data bus and stores them in the local register pointer 22 and the local register counter 23, respectively, as shown in FIG. 8A. The value of the local register pointer 22 is an arbitrary one, and the value of the local register counter 23 is determined when compiling a program. For example, in creating a program, since the type and number of variables are declared, as shown in the following program routine written in the C programming language, these two factors are reflected when compiling the program.
Routine A( ) { : declaring a routine name
int R0 , R1 , . . . Rn-1 : declaring the type and number of
variables
. : the contents of the program
} : finishing the routine
Accordingly, the adder 24 adds the values of the register logical address (RL) and the local register pointer 22 outputted from the CPU 10 and outputs the register physical address (RR), and thereby, a register domain which a routine will use in the memory 30 is determined and the registers are accessed in the determined register domain. Then, when a subroutine B is called in the routine A, as shown in FIG. 8B, the values of the local register pointer 22 and the local register counter 22 in the routine A are output to the memory through the data bus in accordance with the control signal (CTL2) from the control circuit 21. The local register pointer 22 and the local register counter 23 output the values of the pointer and the counter stored in accordance with the control signal (CTL2) to the adder 24, which adds the values of the local register pointer 22 and the local register counter 23 and outputs the added value as the register physical address (RR). Then, the register physical address (RR) is stored again in the local register pointer 23, and set a start address of a register domain which the routine B will use. The local register counter 24 receives and stores the number of registers which the routine B will use from the CPU 10 through the data bus in accordance with the control signal (CTL2), resulting in the decision of a register domain which the routine B uses. Then, when the register logical address (RL) for setting a start address of the routine B is output from the CPU 10, in order to run the routine B, the adder 24 receives the pointer value from the local register pointer 22, and adds the inputted pointer value and the register logical address (RL) and outputs the register physical address (RR), and thereby gets access to the corresponding registers of the memory 30. When the routine B is done and processing returns to the routine A, as shown in FIG. 8C, the values of the local register pointer 22 and the local register counter 23 in the routine A stored in the memory 30 are stored again in the local register pointer 22 and the local register counter 23 through the data bus, resulting in the continued running of routine A in the program. When the program returns to the routine A from routine B, the register domain set for routine B is released. Then, when a subroutine C is called in the routine A, the same operation as when the subroutine B was called in the routine A is repeated, and the register domain which the routine C will use is determined. When a subroutine D is called in the routine C, as shown in FIG. 8D, a register available domain for the routine D is decided next to the register available domain for the routine C. Meanwhile, when the CPU 10 outputs the control signal (CS) and the register logical address (RL) in order to get access to a register domain of another routine from an arbitrary routine, the adder 24 outputs the register logical address (RL) inputted from the CPU 10 in accordance with the control signal (CTL1) from the control circuit 21 as the register physical address (RR), and thereby the memory 30 performs the inputting and outputting of data in a domain set by the register physical address (RR) outputted from the register controller 20. As described in detail above, according to the present invention, the number of the registers used in a specific routine is set suitably for each routine. Therefore even when each routine uses a small number of registers, since the callings of the subroutines can be processed until all the registers are all used, an improved application efficiency of the registers can be achieved. Further, according to the present invention, since the limit of the number of the registers usable in one routine is the total number of the entire registers, a routine which uses many registers can be easily processed. Therefore, an easier creation of a program and a faster processing speed can be realized, and especially such a high level language as a C programming language can be processed with less effort. Although the preferred embodiments of the present invention have been disclosed for illustrative purposes, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, without departing from the scope and spirit of the invention as recited in the accompanying claims.
|
Same subclass Same class Consider this |
||||||||||
