Exemplary embodiments of the present invention are explained below in detail referring to the accompanying drawings. The present invention is not limited to the embodiments explained below.
Address information is transferred from each of the processors 10A to 10H to the L2 cache 30. The L2 cache 30 checks whether information requested by the processors 10A to 10H is cached in the L2 cache 30, and performs a predetermined operation based on the check result. When the requested information is not cached in the L2 cache, the memory controller 40 accesses the internal EDRAM 43 and the external SDRAM 44 based on the address.
The address information includes a command type (read, write, or the like) and a unit of data transfer (cache line size, byte, or the like) as well as the address of the memory requested by the processor, and the whole information is transferred at a time.
The L2 cache 30 is shared by the processors 10A to 10H. Each of the processors 10A to 10H issues a command, and the L2 cache 30 needs to process all of the commands. The processors 10A to 10H include level 1 (L1) caches 11A to 11H respectively, and a request in missing the corresponding L1 cache is transferred to the L2 cache 30 as a command.
Among the addresses input to the L2 cache 30, a lower level address is used as an index of a tag for the L2 cache 30, and is transferred to a tag random access memory (tag-RAM) 302. An upper level address is compared with a result output from the tag-RAM 302. The present embodiment realizes a 4-way cache.
A dispatch unit 304 dispatches a state machine in the L2 controller based on the result of pulling the tag. According to the present embodiment, there are four RC machines 306, two CPBK machines 308, and two lock machines 310 as the state machines. Each of the RC machines 306 handles a read request to the L2 cache 30. Each of the CPBK machines 308 handles a copy-back operation from the L1 caches 11A to 11H to the L2 cache 30. Each of the lock machines 310 handles a lock request to the L2 cache.
Each of the state machines operates in association with a single command. Because the L2 cache 30 handles a plurality of commands at a time, a plurality of state machines can operate at the same time.
Registers corresponding to the four RC machines 306, two CPBK machines 308, and two lock machines 310 are provided as an outstanding address buffer 320. As soon as a state machine is dispatched, a corresponding register in the outstanding address buffer 320 stores therein the address being processed by each state machine. When the state machine completes the process, the corresponding register is cleared of the address.
Comparators 322 are provided in association with shadow register 324 and each of registers in the outstanding address buffer 320. The comparators 322 are used to detect that a new request to the same address as that being processed by the L2 controller, namely the address being processed by any one of the RC machines 306, the CPBK machines 308, and the lock machines 310, is input to the L2 controller.
When a command is sent from one of the processors 10A to 10H, a cache line address in the command is transferred to the comparators 322. The comparators 322 compare it with each of cache line address stored in the corresponding register. If one of the comparators indicates an agreement, the command and the address are stored in a recycle queue (RecycleQ has 4 entries in this) 330.
When the preceding command, namely the command being processed is terminated, the command and the address are popped from the recycle queue 330. The L2 controller starts an implementation, and the cache line address popped from the recycle queue 330 is again transferred to the comparator 322. If there is no agreement, the dispatch unit 304 performs a dispatch corresponding to the command based on the result of pulling the tag.
The command and the like are entered to the recycle queue 330 not only when the comparator 322 indicates the agreement. For example, when any one type of the RC machine, the CPBK machine, and the lock machine is occupied and the command to the occupied type of machine is input, the command and the address are entered to the recycle queue 330. As described above, the command is input to the L2 controller only once in two cycles. As a result, when the corresponding state machine is determined to be full, the next command is already input to a shadow register 324 and stored in the recycle queue 330. When the recycle queue 330 is occupied, a pipeline from the processor to the L2 controller is stalled, and therefore the command cannot enter the L2 controller.
According to the present embodiment, eight state machines are dispatched, and therefore eight bits are assigned to the RC number area. More specifically, bit 7 corresponds to an RC machine RC3; bit 6 corresponds to an RC machine RC2; bit 5 corresponds to an RC machine RC1; bit 4 corresponds to an RC machine RC0; bit 3 corresponds to a CPBK machine CPBK1; bit 2 corresponds to a CPBK machine CPBK0; bit 1 corresponds to a lock machine LOCK1; and bit 0 corresponds to a lock machine LOCK0.
For example, when the command matches an address of the RC machine RC2 and is entered to the recycle queue 330, the command and the address are set in the address/command area, and the corresponding RC number area indicates bit 6.
Otherwise, when any one type of the RC machine, the CPBK machine, and the lock machine is occupied, for example all of the four RC machines are used, and the recycle queue is available, all the bits in the RC number area of the corresponding entry 332 indicate one.
A free list 331 is a register assigned with four bits corresponding to the four entries 332. When an entry is vacant, a corresponding bit indicates zero. When the entry is in use, the corresponding bit indicates one.
When the address is entered to the recycle queue 330, one is set to a bit that currently indicates zero and is the least significant bit in the free list 331. An entry manager 333 sets information in one of the entries 332 corresponding to the bit that currently indicates one and is the least significant bit in the free list 331. Moreover, the entry manager 333 sets one to the most significant bit in one of the four shift registers 334 that corresponds to the entry 332 set with the information. The entry manager 333 then shifts the remaining three of the shift registers 334 to the right.
Because the shift register 334 shifts to the right every time information is set to the entries 332, an entry corresponding to the shift register 334 including the bit located farther to the right is older. In this manner, a decoder 335 can identify an older entry based on the location of the bit in the shift register 334.
A process of determining whether the recycle queue 330 includes an executable command is explained below. When any one of the RC machines, the CPBK machines, and the lock machines terminates the operation, one of the commands in the recycle queue 330 is selected. Specifically, the RC number area in all of the entries 332 in the recycle queue 330 and the bit corresponding to the terminated state machine are inspected. When both of the bit and the terminated state machine are one, a ready register 336 corresponding to the agreed entry is set with one. In other words, the command corresponding to the RC number area is selected.
The ready register 336 indicative of one indicates that a re-executable candidate is set to the corresponding entry. As a result, the information in the ready register 336 enables decision of whether the recycle queue 330 includes an executable command.
The entries 332 are sometimes set with a plurality of identical state machines. In other words, there can be a plurality of entries 332 indicating one in the ready register 336. In such a case, the decoder 335 selects any one of the plurality of commands as the command to be re-executed by the L2 controller.
Specifically, the command is selected based on the bit of the shift register 334. As described above, when information is set to each of the entries 332, the corresponding shift register 334 indicates one, and the bit shifts to the right every time a new entry is set. This means that the entry corresponding to the shift register 334 including one in the rightmost bit among the four shift registers 334 includes the oldest information. According to the present embodiment, the oldest entry is selected to prevent an entry from remaining unexecuted for a long time.
When a command is output from the entries 332 in the recycle queue 330, all of the bits in the ready register 336 corresponding to the selected entry 332, the bits in the corresponding free list 331, and the bits in the corresponding shift register 334 are reset. Moreover, the validity area of the selected entry 332 is revised from one to zero, and the information of the command and the address of the selected entry 332 is executed again by the L2 controller.
The L2 controller needs to determine which of the command from the processor or the command in the recycle queue 330 to execute first. It is assumed herein that the command in the recycle queue 330 is always selected when there is an executable command in the recycle queue 330. This process is performed by the command receptor 301. The command receptor 301 can also read the command.
According to the present embodiment, the pipes from the processors 10A to 10H to the L2 controller are stopped accepting new command when the recycle queue 330 is full or when the recycle queue 330 includes an executable command.
The bits in the ready register 336 corresponding to the entries in the recycle queue 330 are connected to READY0 to READY3, respectively. IN0 to IN3 are inputs to the shift register 334. When a new entry is set to the recycle queue 330, one is input to the corresponding input. OUT0 to OUT3 indicate one when the corresponding entry is selected. More specifically, an entry indicating one in the rightmost bit is selected among the shift registers 334 in which READY indicate one.
The configuration of the recycle queue 330 is not limited to the present embodiment. For example, the number of entries in the recycle queue 330 can be determined according to the required performance, and is not limited by the present embodiment. If the number of entries acceptable in the recycle queue 330 is too small, the pipelines from the processors to the L2 controller are easily stalled, and thus the performance deteriorates. If the number of the entries is too large, though the risk of stalling is reduced, the use efficiency of the recycle queue 330 becomes so low and the area size is wasted. It is preferable to determine the suitable number taking these into accounts.
While the tag is pulled and only reliably executable operations are popped from the recycle queue 330 according to the present embodiment, a simple first-in first-out (FIFO) configuration can be used instead of the shift register 334 to simplify the hardware configuration. The recycle queue 330 can be configured in any way only if one of the entries 332 can be selected from the recycle queue 330. However, with the FIFO configuration, there is a risk that an entry popped from the FIFO configuration hits the address in the outstanding address buffer 320 to be entered to the recycle queue 330 again.
Furthermore, according to the present embodiment, to prevent a starvation that an old entry remains in the recycle queue 330 for a long time, the entry that was entered to the recycle queue 330 at the oldest time is popped first. However, the recycle queue 330 can be configured so that, for example, each entry is popped after a predetermined time. The recycle queue 330 can take any configuration unless there can be any entry that will not be popped for ever.
As described above, the present embodiment ensures that the L2 controller does not perform more than one process at the same address because a second request for an address identical to the address being processed for a first request is stored in the recycle queue 330 to be executed after the first request is terminated.
Moreover, according to the present embodiment, when the second request accesses the same address as the first request, the second request is stored in the recycle queue 330 without accessing a main memory. This improves the performance of the cache memory device and reduces power consumption.
Next, a locking mechanism will be explained. As described above, it is guaranteed that the L2 controller according to the present embodiment processes no more than one request at the same address. Therefore, the locking mechanism can be realized if a predetermined command from the processors 10A to 10H can exclusively read and write the data in the L2 cache 30.
In the present embodiment, a lock command from one of the processors 10A to 10H is transferred directly to the L2 cache 30 without passing through the corresponding one of the L1 caches 11A to 11H. A lock machine starts in the L2 cache 30 as a state machine for the lock command. When the lock command hits the L2 cache 30, the lock machine reads and updates the data in the L2 cache 30. At the same time, the lock machine transfers the data read from the L2 cache 30 to the corresponding one of the processors 10A to 10H. When the lock command misses the L2 cache 30, the lock machine reads data from the internal EDRAM 43 or the external SDRAM 44 and transfers the data to the corresponding one of the processors 10A to 10H. The lock machine also overwrites the L2 cache 30 with the data read from the internal EDRAM 43 or the external SDRAM 44.
More specifically, the processors 10A to 10H include a test-and-set command as the lock command. Upon detecting the test-and-set command, the processors 10A to 10H transfer the address and the command to the L2 cache 30 assuming that the test-and-set command missed the L1 caches 11A to 11H.
To simplify the hardware, it is assumed that the test-and-set command is performed on only one location of a cache line. For example, the test-and-set command is performed on the smallest address byte in the cache line so that the lowest bit of the byte is set to one. The data except the lowest bit in the cache line to which the test-and-set command is performed are meaningless.
In the L2 cache 30, the following operations are performed against the test-and-set command. Tags in the L2 cache 30 are checked. It is guaranteed at this point that no other state machine is operating at the same address because of the effect of the recycle queue 330. When the test-and-set command hits the L2 cache 30, the data hit in the L2 cache 30 is transferred to the processors 10A to 10H. The data indicating one at the lowest bit is written to the cache line. The processors 10A to 10H can read the data before writing. When the test-and-set command misses the L2 cache 30, the test-and-set command transfers the data from the internal EDRAM 43 or the external SDRAM 44 to the L2 cache 30. The data in the L2 cache 30 is then transferred to the corresponding one of the processors 10A to 10H. The lowest bit of the cache line is set to one. The processors 10A to 10H can read the data before setting one.
1. A read request hits the L2 cache 30.
2. The read request misses the L2 cache 30.
3. A write request hits the L2 cache 30.
4. The write request misses the L2 cache 30.
5. A copy back from an L2 data memory 350.
6. A test-and-set command hits the L2 cache 30.
7. The test-and-set command misses the L2 cache 30.
When the read request hits the L2 cache 30, an address of the L2 data memory 350 is supplied from an address system (shown in
When the read request misses the L2 cache 30, the data from the memory controller 40 passes through an MRLD buffer 352, a multiplexer (MUX) 354, and a locking logic 356, and is written to the L2 data memory 350. The address of the L2 data memory 350 is indicated by the corresponding RC machine. The data in the L2 data memory 350 is read and transferred to the processors 10A to 10H.
When the write request hits the L2 cache 30, the data from the processors 10A to 10H passes through the MUX 354 and the locking logic 356, and is written to the L2 data memory 350. The MUX 354 selects either one of the path from the processors 10A to 10H and the path from the memory controller 40. The address of the L2 data memory 350 is indicated by the corresponding CPBK machine.
When the write request misses the L2 cache 30, the data from the processors 10A to 10H passes through a bypass buffer 360 and a MUX 362, and is transferred to the memory controller 40. The data is not written to the L2 data memory 350.
The copy back from the L2 data memory 350 may be performed when the read request misses the L2 cache 30 or when the lock command misses the L2 cache 30. When the copy back is required for acquiring a new cache line, the data in the L2 data memory 350 is read and transferred to the memory controller 40 via an MCPBK buffer 364 and the MUX 362. The address of the L2 data memory 350 is indicated by an MCPBK machine.
When the test-and-set command hits the L2 cache 30, the data read from the L2 data memory 350 is transferred to the processors 10A to 10H. The locking logic 356 then prepares the data that indicates one at the lowest bit, and writes it to the L2 data memory 350. The address of the L2 data memory 350 is indicated by the corresponding lock machine.
When the test-and-set command misses the L2 cache 30, the data from the memory controller 40 passes through the MRLD buffer 352, the MUX 354, and the locking logic 356, and is written to the L2 data memory 350. The data is then read from the L2 data memory 350 and transferred to the processors 10A to 10H. The locking logic 356 then prepares the data that indicates one at the lowest bit, and writes it to the L2 data memory 350. The locking logic 356 generates the data that indicates one at the lowest bit.
Next, an operation of each of the state machines will be explained.
In the case of hitting, the address is transferred from the RC machine to the L2 data memory 350 and the data is read from the L2 data memory while the L2 data memory is not being accessed. The data is then transferred to the processors 10A to 10H, and the RC machine is terminated.
In the case of missing without the replacement, the MRLD machine operates. The MRLD machine is used to write data from the memory controller 40 to the L2 data memory 350. When the MRLD machine is shared with another state machine, the RC machine waits until the MRLD machine gets ready to operate. When the MRLD machine is ready to operate, the RC machine starts the MRLD machine and waits until the MRLD machine stops. After the data is written to the L2 data memory 350, the MRLD machine is terminated. After the termination of the MRLD machine, the data read from the L2 data memory 350 is transferred to the processors 10A to 10H.
In the case of missing with the replacement, it is necessary to write the cache line to be replaced to the memory controller 40 using the MCPBK machine. The MCPBK machine is used to write the data from the cache line to the internal EDRAM 43 and the external SDRAM 44. When the MCPBK machine is shared with another state machine, the RC machine waits until the MCPBK machine gets ready to operate. When the MCPBK machine is ready to operate, the RC machine starts the MCPBK machine and waits until the MCPBK machine stops. After the MCPBK machine is terminated, the RC machine follows the same path as in the case of missing without replacement.
In the case of hitting, the CPBK machine determines whether the L2 data memory 350 is being used by another state machine. If it is not being used, CPBK machine transfers the data from the requesting processor and updates the tag in the course of operations shown in
In the case of missing, the CPBK machine does not write the data to the L2 data memory 350 and writes the data to the internal EDRAM 43 or the external SDRAM 44 via the bypass buffer 360. At first, the CPBK machine waits for the bypass buffer 360 to be available, because the data cannot be written from the processors 10A to 10H to the bypass buffer 360 when another CPBK machine is using the bypass buffer 360. After the bypass buffer 360 becomes available and the writing from the processor is completed, the CPBK machine writes the data to the internal EDRAM 43 or the external SDRAM 44.
The operations after the request for writing to the internal EDRAM 43 and the external SDRAM 44 can be performed by only one of the CPBK machines and the MCPBK machines at a time. For this reason, an arbiter is used for arbitration at interlocking.
The called MRLD machine issues a request for reading to the memory controller 40, and waits for the data to be written to the MRLD buffer 352. The MRLD machine then waits for the L2 data memory 350 to be available. When the L2 data memory 350 is available, the MRLD machine writes the data from the MRLD buffer 352 to the L2 data memory 350 and updates the tag.
When the L2 data memory 350 is available, the called MCPBK machine reads the data from the L2 data memory 350 and writes the data to the MCPBK buffer 364. The MCPBK machine issues a request for reading to the memory controller 40. The arbitration is needed because the CPBK machine also issues a request for writing to the memory controller 40. More specifically, the arbiter performs the arbitration. When the request for writing to the memory controller 40 is authorized, the data is transferred from the MCPBK buffer 364 to the memory controller 40. The tag is not updated at this point because the update is performed by the RC machine.
The explanation is given herein assuming that a plurality of processors competes for a lock. For example, when the three processors 10A to 10C try to lock an address number 1,000, zero is prewritten to the address number 1,000. The processors 10A to 10C access the address number 1,000 using the test-and-set command. It is assumed herein that a first processor 10A reaches the L2 cache 30 at first. When the first processor 10A misses the L2 cache 30, the L2 cache 30 reads the value zero of the address number 1,000 from the main memory, and stores it in the L2 data memory 350. The value of the address number 1,000 in the L2 cache 30 is updated to one. The first processor 10A acknowledges that locking was successful by receiving zero from the L2 cache 30. The first processor 10A starts a predetermined process.
Commands from a second processor 10B and a third processor 10C that reached the L2 cache 30 are stored in the recycle queue 330 to be processed in the order. After the process for the command by the first processor 10A is completed, the command by the second processor 10B is popped from the recycle queue 330 and the tag is pulled, which hits this time. However, because the address number 1,000 in the L2 cache 30 is locked by the first processor 10A and indicates one, the second processor 10B receives the value one from the address number 1,000 in the L2 cache 30.
The L2 cache 30 overwrites the value in the address number 1,000 with one. The second processor 10B acknowledges failure of locking by receiving the value one. The command by the third processor 10C is popped from the recycle queue 330 to be executed in the same manner, and acknowledges the failure of locking by receiving the value one.
Upon completion of the process, the first processor 10A that succeeded locking writes zero to the address number 1,000. The first processor 10A writes zero to the address number 1,000 which is related to the locking of the L2 cache 30. Due to this, the value in the address number 1,000 returns to zero again. Then, the first processor 10A flushes the data in the L1 cache (11A) to the L2 cache 30. Therefore, the locking by the first processor 10A is released.
While the locking mechanism according to the present embodiment locks the L2 data memory 350 by writing one to the L2 data memory 350, locking can be performed by, for example, reading the data from the L2 data memory 350 and adding one to the data. A value incremented by one needs to be written to the L2 data memory 350, and the process to do so is not limited to the present embodiment.
Next, an arbitration mechanism for running a single state machine requested by a plurality of the state machines will be explained. According to the present embodiment, for example, the RC machine and the lock machine call the MRLD machine when they missed the L2 cache 30. However, because there is only one MRLD machine, the arbitration among a plurality of the state machines is required.
A value encoded by the encoder 370 is written to a dual port memory 372, and a write pointer 374 is incremented. The dual port memory 372 stores therein the values of the request in order of oldness on the FIFO basis. The dual port memory 372 has only to output the written values at appropriate timings, and a shift register or the like can be used.
The output from the dual port memory 372 is decoded again by a decoder 376 to be the 1-hot code. A ready signal is returned to the requesting state machine. However, when the write pointer 374 matches a read pointer 378, or when the FIFO configuration including the dual port memory 372 stores therein no value, the ready signal is not output. When the MRLD machine is terminated, the read pointer 378 is incremented, and a request for the MRLD machine by the next state machine is processed.
Next, an arbitration mechanism when a plurality of state machines share one equipment will be explained. According to the present embodiment, the state machines often wait for the L2 data memory 350 to be available. Each of the state machines determines whether the L2 data memory 350 is being used by another state machine, i.e. detects availability of the L2 data memory 350, and the waiting state machines acquire the L2 data memory 350 in the order determined by the arbitration.
Upon receiving the request from each of the state machines, a set-reset flip-flop (SRFF) 380 corresponding to each of the state machines is set. A selection circuit 382 selects only one of the requests. The selection circuit 382 selects the leftmost bit. The selection circuit selects only one request even if two machines send the requests at the same time.
The SRFF 380 corresponding to the request selected by the selection circuit 382 is reset by a reset signal. The selection circuit 382 outputs one bit per cycle. An encoder 384 inputs the output from the selection circuit 382 to a dual port memory 386.
The dual port memory 386 includes a write pointer 388 and a read pointer 390 to configure the FIFO. However, a shift register can be used instead.
When a value is input from the encoder 384 to the dual port memory 386, the write pointer 388 is incremented by one. Contents of the FIFO configuration are arranged in the order of using the L2 data memory 350. In other words, the first element in the FIFO uses the L2 data memory 350 at first. A decoder 392 converts the output from the dual port memory 386 to the ready signal in the L2 data memory 350 corresponding to each of the state machines. When the ready signal is output, a machine timer 394 corresponding to the type of the state machine starts to operate. The machine timer 394 can be an RC machine timer, a lock machine timer, a CPBK machine timer, an MRLD machine timer, or an MCPB machine timer.
During the operation of the machine timer 394, the first element in the FIFO is not processed, which prevents transmission of the ready signal from the L2 data memory 350 to another state machine. The machine timer 394 is set with a value corresponding to the type of the state machine. The output value is one only during a predetermined number of cycles after the ready signal is output.
When the operation of the machine timer 394 is terminated, a negative edge detector 396 detects the fact that the output is converted from one to zero, and the read pointer 390 is incremented. This makes the next element in the FIFO ready. When the FIFO is empty, the values are compared between the read pointer 390 and the write pointer 388, and they match so that the ready signal is not output.
Additional advantages and modifications will readily occur to those skilled in the art. Therefore, the invention in its broader aspects is not limited to the specific details and representative embodiments shown and described herein. Accordingly, various modifications may be made without departing from the spirit or scope of the general inventive concept as defined by the appended claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
2006-150445 | May 2006 | JP | national |