Background technology
Along with the progress of science and technology and the continuous lifting of chip technology level, increasing SOC(System on Chip, systems-on-a-chip) chip provides for the user single-chip solution that performance is higher, integrated level better, cost is lower.
Generally, all be provided with a plurality of configuration registers in the SOC chip, control clock, reset, function, flow process etc.By these configuration registers, the research and development of software personnel can be easily control, the function of chip are arranged and the flow process of chip is configured the clock of each functional module, the signal such as reset, thereby chip can correctly be worked.
The bit wide of existing single configuration register is generally identical with highway width, but form to control clock, resets, the baseband signal of function, flow process etc. only needs a bit or several bit usually.Like this, a configuration register often can be divided into a plurality of register-bit sections, be used for controlling respectively clock, reset, the baseband signal of flow process, function etc., a register-bit section can be comprised of a bit or many bits, the not coordination section of same configuration register, act on different., because the base unit of read-write register is single register rather than single register-bit section, on the write operation of certain register-bit section, likely can affect whole register.Say like this and cause two problems: the one,, for the modification of each register-bit section, at first to read the value of whole register, then do suitable processing, then register is carried out write operation, thereby increased the read operation to register; The 2nd, when two threads are modified to the not coordination section that is positioned at same register, due to the value that all needs first to read whole register before revising, the register that may cause a thread just to read, revised by another thread, thereby cause the modification to the register-bit section to make mistakes at once.
Summary of the invention
Embodiment of the present invention technical matters to be solved is, a kind of configuration register reading/writing method and device are provided, can only be by reading whole register to revise the register-bit section to solve in prior art, thus increase the read operation of register and the technical matters that the modification to the register-bit section makes mistakes easily occurs.
For solving the problems of the technologies described above, the invention provides a kind of configuration register reading/writing method, in advance whole sections of register are assigned as a plurality of function digit sections and a plurality of write enable bit section, wherein, each function digit section is used for content of registers of storage, and with a corresponding setting of write enable bit section, the method comprises:
The outer operation signal for register that sends of receiving sheet, this operation signal comprises register address and read-write operation instruction.
Set the value of corresponding write enable bit section according to this read-write operation instruction.
Read according to the content of this register address to the write enable bit section of the corresponding function digit section of this register and correspondence, judge whether the value of this write enable bit section is effective value.And
According to the value of this write enable bit section, the content of registers of corresponding function digit section is carried out read-write operation.
Correspondingly, the present invention also provides a kind of configuration register read-write equipment, be connected with a plurality of registers by address bus, whole sections of this register are allocated in advance as a plurality of function digit sections and a plurality of write enable bit section, wherein, each function digit section is used for content of registers of storage, and with a corresponding setting of write enable bit section, this device comprises:
Receiving element, be used for the outer operation signal for register that sends of receiving sheet, and this operation signal comprises register address and read-write operation instruction.
Write enable bit section control module, be used for the value according to the corresponding write enable bit section of this read-write operation instruction setting.And
Read-write control unit, be used for resolving this operational order to extract address information wherein, search corresponding register according to this address information, the function digit section of this register and the content of write enable bit section are read, and determine whether to revise the value of corresponding function position section according to the value of the write enable bit section that reads, thereby the content of registers of this function digit section is carried out read-write operation.
a kind of configuration register reading/writing method provided by the invention and device, in advance configuration register is distributed into a plurality of function digit sections and corresponding write enable bit section, by the judgement to the write enable bit segment value, the content of registers of corresponding function digit section is carried out read-write operation, thereby the technical matters that the modification that effectively having solved increases register read operation and easily occur makes mistakes, reached the running time of saving processor when revising the content of registers of a certain position of configuration register section, and avoided at different threads the content of registers of the not coordination section of the same configuration register easy interactional technique effect of when operation of modifying.
Embodiment
By describing technology contents of the present invention, structural attitude in detail, being realized purpose and effect, below in conjunction with embodiment and coordinate accompanying drawing to be explained in detail.
Please refer to Fig. 1, be the high-level schematic functional block diagram of a kind of configuration register read-write equipment in the embodiment of the present invention, this read-write equipment 10 is connected with each register 20 respectively by address bus.This read-write equipment 10 comprises receiving element 11 and read-write control unit 12, and wherein, this receiving element 11 is used for the operation signal for register 20 that the receiving processor (not shown) sends, and this operation signal comprises register address and read-write operation instruction.This read-write control unit 12 is used for carrying out correspondingly read-write operation according to this read write command pair register corresponding with this address, obtains the read-write operation result.
In the present embodiment, when design, according to application, need design register definitions file, this register definitions file comprises address, content and the initial value of each register that sets in advance.Wherein, the address of each register is independent of each other, finds corresponding register while being used for addressing; The content of register is control function or the parameter meaning of each section representative in circuit in register, such as clock, reset, flow process etc.; The initial value of register is after chip power resets, when sheet does not also carry out any read-write operation to register outward, and the default value of register.In actual applications, will, according to pre-designed register definitions file, realize the read-write operation to register.And the register definitions file of each register has independently definitional part, and address, content and the initial value of the corresponding register of the definitional part of a register are unrelated between the parameter of each register.
Please consulting simultaneously Fig. 2, is that schematic diagram is distributed in the position of the register 20 in the first embodiment, and each register 20 all position section is allocated in advance as n function digit section Fn and n write enable bit section En.Wherein, the corresponding content of registers of each function digit section Fn, each write enable bit section En and a corresponding setting of function digit section Fn, be used for the read-write operation of corresponding write enable bit section Fn is controlled.For example, content of registers corresponding to function digit section F1 is for resetting, and corresponding write enable bit section E1 controls the read-write operation of function digit section F1.Each function digit section Fn and each write enable bit section En can be assigned with a bit or a plurality of bit.In the present embodiment, the bit length that is assigned with of each function digit section Fn is identical with the bit length that corresponding write enable bit section En is assigned with.In the second embodiment, the bit length that each write enable bit section En is assigned with is 1, and each function digit section Fn can be assigned with corresponding bit length according to corresponding content of registers, as shown in Figure 3.
this read-write equipment 10 also comprises write enable bit section control module 13, wherein, the value of corresponding write enable bit section En is set in the read-write operation instruction that this write enable bit section control module 13 sends according to processor, this read-write control unit 12 is used for resolving the operational order that sent by processor to extract address information wherein, search corresponding register 20 according to this address information, the function digit section Fn of this register 20 and the content of write enable bit section En are read, and determine whether to revise the value of corresponding function position section Fn according to the value of the write enable bit section En that reads, thereby Fn carries out read-write operation to this function digit section.Particularly, when processor sent the data reading command, the value of each write enable bit section En was set to invalid value, and with the value of each function digit section Fn, read in the lump.When processor transmission data write instruction, these data write instruction and also comprise data to be written, and wherein, these data to be written comprise the value of corresponding function position section Fn and the value of corresponding write enable bit section En.The value of write enable bit section En in this write enable bit section control module 13 data to be written according to this arranges the value of corresponding write enable bit section En.This read-write control unit 12 determines that the value of this write enable bit section En is effective value, data to be written is write in the content of registers of this function digit section Fn; Otherwise, the content of registers of this function digit section Fn is not made an amendment.
In the first embodiment, the invalid value of this write enable bit section En is that whole bit place values are 0, and effective value is that whole bit place values are 1.In the second embodiment, the invalid value of this write enable bit section En is 0, and effective value is 1.
See also Fig. 4, be the process flow diagram of the reading/writing method of configuration register of the present invention, the method comprises:
Step S40, be assigned as whole sections of register 20 n function digit section Fn and n write enable bit section En in advance.Wherein, content of registers of each function digit section Fn storage, each write enable bit section En and a corresponding setting of function digit section Fn.
Each function digit section Fn and each write enable bit section En can be assigned with a bit or a plurality of bit.In the first embodiment, the bit length that is assigned with of each function digit section Fn is identical with the bit length that corresponding write enable bit section En is assigned with.In the second embodiment, the bit length that each write enable bit section En is assigned with is 1, and each function digit section Fn can be assigned with corresponding bit length according to corresponding content of registers.
In the present embodiment, when design, according to application, need design register definitions file, this register definitions file comprises address, content and the initial value of each register that sets in advance.Wherein, the address of each register is independent of each other, finds corresponding register while being used for addressing; The content of register is control function or the parameter meaning of each section representative in circuit in register, such as clock, reset, flow process etc.; The initial value of register is after chip power resets, when sheet does not also carry out any read-write operation to register outward, and the default value of register.In actual applications, will, according to pre-designed register definitions file, realize the read-write operation to register.And the register definitions file of each register has independently definitional part, and address, content and the initial value of the corresponding register of the definitional part of a register are unrelated between the parameter of each register.
Step S41, the operation signal for register 20 that these receiving element 11 receiving processors send, wherein, this operation signal comprises register address and read-write operation instruction.
Step S42, the value of corresponding write enable bit section En is set in the read-write operation instruction that this write enable bit section control module 13 sends according to processor.Particularly, when this read-write operation instruction was the data reading command, the value of this write enable bit section control module 13 each write enable bit section En was set to invalid value, and with the value of each function digit section Fn, read in the lump.When this read-write operation instruction is data while writing instruction, these data write instruction and also comprise data to be written, and wherein, these data to be written comprise the value of corresponding function position section Fn and the value of corresponding write enable bit section En.The value of write enable bit section En in this write enable bit section control module 13 data to be written according to this arranges the value of corresponding write enable bit section En.The register address that step S43, this read-write control unit 12 send according to processor reads the content of the corresponding function digit section Fn of this register 20 and write enable bit section En, judges whether the value of this write enable bit section En is effective value.If, enter step S44, otherwise, step S45 entered.
In the first embodiment, the invalid value of this write enable bit section En is that whole bit place values are 0, and effective value is that whole bit place values are 1.In the second embodiment, the invalid value of this write enable bit section En is 0, and effective value is 1.
Step S44, this read-write control unit 12 write data to be written in the content of registers of this function digit section Fn, and then flow process finishes.
Step S45, this read-write control unit 12 obtains the content of registers of this function digit section Fn, and then flow process finishes.
a kind of configuration register reading/writing method provided by the invention and device, in advance configuration register is distributed into a plurality of function digit sections and corresponding write enable bit section, by the judgement to the write enable bit segment value, the content of registers of corresponding function digit section is carried out read-write operation, thereby the technical matters that the modification that effectively having solved increases register read operation and easily occur makes mistakes, reached the running time of saving processor when revising the content of registers of a certain position of configuration register section, and avoided at different threads the content of registers of the not coordination section of the same configuration register easy interactional technique effect of when operation of modifying.
The foregoing is only embodiments of the invention; not thereby limit the scope of the claims of the present invention; every equivalent structure or equivalent flow process conversion that utilizes instructions of the present invention and accompanying drawing content to do; or directly or indirectly be used in other relevant technical fields, all in like manner be included in scope of patent protection of the present invention.