A kind of register access methods and system based on automation RAL
Technical field
It is specifically that one kind being based on automation RAL (Register the present invention relates to chip register access technique field
Abstraction Layer, register level of abstraction) register access methods and system.
Background technology
It deepens continuously with IP (Internet Protocol, Internet protocol) change process of global communication technology, packet processing
The application demand of class chip is increasing, and packet handles relevant agreement also to be increased therewith, so that the survey of packet processing class chip
It tries increasingly sophisticated, when packet processing chip is tested, needs to design, exploitation and verification of the packet processing chip through excessively taking turns.
In the driving exploitation and functional level verification process of chip, the access operation for repeatedly carrying out register is needed.Currently,
The driving development process and functional level verification process of chip are respectively present following deficiency:
For driving exploitation, due to the driving development scheme generally exploitation manually of chip, when register occurs firmly
When the design of part, software is changed, it can cause to need to carry out multiple software revision manually in driving development process, so that entirely
Convergence process appearance largely operates repeatedly, reduces development efficiency.
For chip functions level verification, since testing example design relies on the access of register, when register goes out
When the design of existing hardware, software is changed, the repetition of test case can be caused to revise, in turn result in the low problem of verification efficiency.
Invention content
The purpose of the invention is to overcome the shortcomings of above-mentioned background technology, a kind of deposit based on automation RAL is provided
Device access method and system, the present invention can be based on the access for automatically generating completion register of register level of abstraction RAL, effectively
Improve chip development and the efficiency of verification.
To achieve the above objectives, the present invention provides a kind of register access methods based on automation RAL, including following step
Suddenly:
S1:According to the format of regulation, several description files for describing register are created, S2 is transferred to;
S2:File will be described using wscript.exe and is automatically converted into the C files needed for accessing, and is transferred to S3;
S3:Register name, list item name and the domain name accessed as needed finds correspondence in the C files that conversion generates
The domain information of register, list item domain information;The reading of corresponding thresholding is carried out according to the domain information found or changes operation.
Based on the above technical solution, the type that file is described described in S1 include txt documents, doc documents and
Excel tables;The content of the description file includes fileinfo, register information and list item information:
The fileinfo include filename, file occupy address height bit;
The register information include register name, register offset address, register occupy number of words, register description and
The domain information of register;Wherein, the domain information of register includes the address height of the offset of word where domain name, domain, domain occupancy
Bit, read-only are write instruction, domain description, domain default value;
The list item information includes list item name, entry number, entry occupancy number of words, list item offset address, list item description and table
The domain information of item;Wherein, the domain information of list item includes domain name, the offset of word where domain, domain occupy address height bit,
Read-write instruction, domain description.
Based on the above technical solution, S2 specifically includes following steps:
S201:The input path of specified description file and the outgoing route after conversion C files;Obtain the institute under input path
It is described file, is transferred to S202;
S202:It is successively read each description file using wscript.exe, by the information of reading according to certain data structure
It is preserved, is transferred to S203;
S203:It is automatic under specified outgoing route according to the template style of the information and required C files that are preserved in S202
Conversion generates corresponding C files, and S2 all terminates, and is transferred to S3.
Based on the above technical solution, each description file is read in S202, by the information of reading according to certain
Data structure is preserved, and following steps are specifically included:
When reading description file every time, for one file class object of description document definition of reading, by file class
Object is stored in a file list;
The keyword instruction in description file is read line by line, when reading FileName, fileinfo is expressed as, by file
Information preservation is inside file class objects;When reading RegMem/Register, then it represents that it is list item/register information,
For the corresponding list item class objects of list item/register definitions/register class objects, by list item class objects/register
Class objects form corresponding list item list/ register list, and are stored in file class objects;When reading
When MemRegFields/Fields, then it represents that be domain information/deposit of list item for the domain information of domain information/register of list item
The domain information of device defines corresponding list item domain information class objects/register field information class objects, by list item domain information
Class objects/register field information class objects form corresponding list item domain information list/ register field information list, and protect
There are in corresponding list item class objects/register class objects.
Based on the above technical solution, corresponding C files described in S203 include following 9 files:allenum.h
File, memacc.h files, memregs.h files, intenum.h files, allfields.h files, regs.c files,
Mems.c files, switch_xx.c files and fields.c files;
Allenum.h files are used for:Register name, list item name, domain name are defined, by calling this definition to deposit
Device or list item access;
Memacc.h files are used for:Define the read-write operation in the domain of each list item;
Memregs.h files are used for:Define the read-write operation of all registers;
Intenum.h files are used for:The lookup index of definition register information, the lookup index of list item information;
Allfields.h files are used for:The domain pointer of all registers, list item is stated;
Regs.c files are used for:All register informations are preserved, including describe the filename of file, deposit belonging to register
Device occupies domain pointer, the default value of number of words, register offset address, the domain number of register, register;
Mems.c files are used for:Preserve all list item informations, including the entry minimum index of list item, entry largest index,
Filename, list item offset address, list item entry address saltus step number of words, the domain number of list item, the list item of description file belonging to list item
Domain pointer;
Switch_xx.c files are used for:The driving definition of register level of abstraction RAL, the driving definition are carried out to chip
Content include that chip type, chip title, chip correspond to register transfer layer RTL versions, the corresponding register of chip, chip
Corresponding list item and initialization value;
Fields.c files are used for:The corresponding domain information of save register, list item, domain information, the list item of each register
Domain information preserved in the form of Array for structural body ARRAY, and each domain information include the offset of word where domain name, domain,
Address height bit of domain occupancy, read-write instruction.
Based on the above technical solution, S3 specifically includes following steps:
S301:Register name, the list item name accessed as needed, judges that corresponding register, list item whether there is, if
It is to be transferred to S302;Otherwise error message is directly returned, is terminated;
S302:Believe in all domains of all domain informations, list item that corresponding register is searched in the C files that conversion generates
Breath, is transferred to S303;
S303:According to the domain name to be accessed, judge in all domain informations of the register, all domains of list item letter
Whether with domain name corresponding domain information is respectively present in breath, if so, being transferred to S304;Otherwise error message is returned, is terminated;
S304:Corresponding domain information is obtained, and carries out the reading of corresponding thresholding or change to grasp according to the corresponding domain information
Make.
Based on the above technical solution, wscript.exe described in S2 is a kind of using Tool Command Language TCL, TCL
Based on the explanatory command lanuage of character string.
The present invention also provides a kind of register access systems based on automation RAL for realizing the above method, including description
File creation module, C files conversion module and domain information operation module;
The description file creation module is used for:According to the format of regulation, several descriptions for describing register are created
File sends conversion signal to C file conversion modules;
The C files conversion module is used for:After receiving conversion signal, it is automatically converted into using wscript.exe by file is described
C files needed for accessing send operation signal to domain information operation module;
The domain information operation module is used for:After receiving operation signal, the register name that accesses as needed, list item name and
Domain name finds the domain information of corresponding register, the domain information of list item in the C files that conversion generates;According to what is found
Domain information carries out the reading of corresponding thresholding or changes operation.
Based on the above technical solution, the C files conversion module includes file acquisition submodule, document analysis
Module and C file generated submodules;
The file acquisition submodule is used for:The input path of specified description file and the outgoing route after conversion C files;
The be described file under input path is obtained, analytic signal is sent to document analysis submodule;
The document analysis submodule is used for:After receiving analytic signal, each description text is successively read using wscript.exe
Part preserves the information of reading according to certain data structure, and file generated signal is sent to C file generated submodules;
The C file generateds submodule is used for:After receiving file generated signal, according to what is preserved in document analysis submodule
The template style of information and required C files, automatic conversion generates corresponding C files under specified outgoing route.
Based on the above technical solution, the domain information operation module includes judging submodule, searches submodule, domain
Information judging submodule and domain information handle submodule;
The judging submodule is used for:Register name, the list item name accessed as needed, judges corresponding register, table
Item whether there is, if so, sending lookup signal to submodule is searched;Otherwise error message is directly returned, is terminated;
The lookup submodule is used for:It receives after searching signal, corresponding register is searched in the C files that conversion generates
All domain informations, list item all domain informations, to domain information judging submodule transmission judge signal;
The domain information judging submodule is used for:It receives after judging signal, according to the domain name to be accessed, judges the deposit
In all domain informations of device, domain information corresponding with domain name whether is respectively present in all domain informations of the list item, if so, to
Domain information handles submodule and sends processing signal;Otherwise error message is returned, is terminated;
The domain information processing submodule is used for:After receiving processing signal, corresponding domain information is obtained, and according to the correspondence
Domain information carry out the reading of corresponding thresholding or change operation.
The beneficial effects of the present invention are:
(1) present invention will describe file using wscript.exe and be automatically converted into the C files needed for accessing, automatic to realize
Generate RAL (register level of abstraction), register name, list item name and the domain name that system accesses as needed, in the C texts automatically generated
After searching the domain information of corresponding register, the domain information of list item in part, you can operate to corresponding thresholding, posted to realize
The access of storage.
Therefore, when carrying out the access of register using this method, it need not be concerned about the specifying information of register or list item, when
Register or list item have (height bit that such as address modification, domain occupy changes, increases domain newly) when update, as long as register name,
List item name, domain name do not change, with regard to without carrying out any modification to code, need to only update the abstract middle C files generated of register
, and then chip development and the efficiency of verification can be effectively improved.
(2) present invention be suitable for all kinds of chips driving exploitation and verification process, the scope of application is wider, durability compared with
It is high.
Description of the drawings
Fig. 1 is the flow chart of the register access methods based on automation RAL in the embodiment of the present invention;
Fig. 2 is the flow chart of the specific steps of S2 in the embodiment of the present invention;
Fig. 3 is the schematic diagram for the data structure that parsing information is preserved in the embodiment of the present invention;
Fig. 4 is the flow chart of the specific steps of S3 in the embodiment of the present invention.
Specific implementation mode
Below in conjunction with the accompanying drawings and specific embodiment the present invention is described in further detail.
It is shown in Figure 1, the embodiment of the present invention provide it is a kind of based on automation RAL register access methods, including with
Lower step:
S1:According to the format of regulation, several description files for describing register are created, S2 is transferred to.
The type for describing file includes txt documents, doc documents and excel tables;The content for describing file includes text
Part information, register information and list item information:
Fileinfo include filename, file occupy address height bit;
Register information includes register name, register offset address, register occupancy number of words, register description and deposit
The domain information of device;Wherein, the domain information of register includes the address height bit of the offset of word where domain name, domain, domain occupancy
Position, read-only write instruction, domain description, domain default value;
List item information includes list item name, entry number, entry occupancy number of words, list item offset address, list item description and list item
Domain information;Wherein, the domain information of list item includes the offset of word where domain name, domain, address height bit of domain occupancy, read-write
Instruction, domain description.
In addition, in same description file, register name and list item name cannot be identical, but domain name can be identical;Difference description text
In part, register name, list item name, domain name can be identical.
S2:File will be described using wscript.exe and is automatically converted into the C files needed for accessing, to realize RAL (registers
Level of abstraction) automatically generate, be transferred to S3.
The wscript.exe uses TCL (Tool Command Language, Tool Command Language) wscript.exe, and TCL is
A kind of command lanuage explanatory based on character string.
When description file is automatically converted into the C files needed for access, it can be converted and be described based on user demand selection
The description file that file, the description file for converting certain format or conversion are specified.
Shown in Figure 2, when practical operation, S2 specifically includes following steps:
S201:Obtain description file:The input path of specified description file and the outgoing route after conversion C files;It obtains
The be described file under path is inputted, S202 is transferred to.
S202:Parsing description file:It is successively read each description file using wscript.exe, by the information of reading according to one
Fixed data structure is preserved (as shown in Figure 3), is transferred to S203.
S203:Generate C files:According to the template style of the information and required C files that are preserved in S202, in specified output
Automatic conversion generates corresponding C files under path, and S2 all terminates, and is transferred to S3.
S3:Register name, list item name and the domain name accessed as needed finds correspondence in the C files that conversion generates
The domain information of register, list item domain information;The reading of corresponding thresholding is carried out according to the domain information found or changes operation.
Shown in Figure 4, when practical operation, S3 specifically includes following steps:
S301:Register name, the list item name accessed as needed, judges that corresponding register, list item whether there is, if
It is to be transferred to S302;Otherwise error message is directly returned, is terminated.
S302:Believe in all domains of all domain informations, list item that corresponding register is searched in the C files that conversion generates
Breath, is transferred to S303.
S303:According to the domain name to be accessed, judge in all domain informations of the register, all domains of list item letter
Whether with domain name corresponding domain information is respectively present in breath, if so, being transferred to S304;Otherwise error message is returned, is terminated.
S304:Corresponding domain information is obtained, and carries out the reading of corresponding thresholding or change to grasp according to the corresponding domain information
Make.
Each description file is read in S202, and the information of reading is preserved according to certain data structure, it is specific to wrap
Include following steps:Every time read description file when, for reading one file class of description document definition (class, it is similar to C++,
A kind of specific example with same alike result or function) object, by file class objects be stored in a file list (list,
The ordered set being made of specific explanation element a pile in TCL) in (correspondence can be accessed by file class object names
The information of file is described);
The keyword instruction in description file is read line by line, when reading FileName, fileinfo is expressed as, by file
Information preservation is inside file class objects;When reading RegMem/Register, then it represents that it is list item/register information,
For the corresponding list item class objects of list item/register definitions/register class objects, by list item class objects/register
Class objects form corresponding list item list/ register list, and are stored in file class objects;When reading
When MemRegFields/Fields, then it represents that be domain information/deposit of list item for the domain information of domain information/register of list item
The domain information of device defines corresponding list item domain information class objects/register field information class objects, by list item domain information
Class objects/register field information class objects form corresponding list item domain information list/ register field information list, and protect
There are in corresponding list item class objects/register class objects.
Corresponding C files described in S203 include following 9 files:Allenum.h files, memacc.h files,
Memregs.h files, intenum.h files, allfields.h files, regs.c files, mems.c files, switch_xx.c
File and fields.c files;
Allenum.h files are used for:Register name, list item name, domain name are defined, by calling this definition to deposit
Device or list item access;
Memacc.h files are used for:Define the read-write operation in the domain of each list item;
Memregs.h files are used for:Define the read-write operation of all registers;
Intenum.h files are used for:The lookup index of definition register information, the lookup index of list item information;
Allfields.h files are used for:The domain pointer of all registers, list item is stated;
Regs.c files are used for:All register informations are preserved, including describe the filename of file, deposit belonging to register
Device occupies number of words, register offset address (description file base address+register offset address=register address), register
Domain pointer (the corresponding domain information of register can be found based on the domain pointer of register), the default value of domain number, register.
Mems.c files are used for:Preserve all list item informations, including the entry minimum index of list item, entry largest index,
The filename of description file, list item offset address, list item entry address saltus step number of words (description file base address+table belonging to list item
Offset address+entry index * entry address saltus step numbers of words, the i.e. address of list item corresponding entry thus), the domain number of list item,
The domain pointer (the corresponding domain information of list item can be found based on the domain pointer of list item) of list item.
Switch_xx.c files are used for:RAL driving definition is carried out to chip, the content which defines includes chip class
It is corresponding that type, chip title, chip correspond to RTL (Register-Transport-layer, register transfer layer) version, chip
The corresponding list item of register, chip and initialization value.
Fields.c files are used for:The corresponding domain information of save register, list item, domain information, the list item of each register
Domain information preserved in the form of Array for structural body ARRAY, and each domain information include the offset of word where domain name, domain,
Address height bit of domain occupancy, read-write instruction.
The present invention also provides a kind of register access systems based on automation RAL for realizing the above method, including description
File creation module, C files conversion module and domain information operation module.
Description file creation module is used for:According to the format of regulation, several description files for describing register are created,
Conversion signal is sent to C file conversion modules.
C file conversion modules are used for:After receiving conversion signal, access is automatically converted by file is described using wscript.exe
Required C files send operation signal to domain information operation module.
Wherein, C files conversion module includes file acquisition submodule, document analysis submodule and C file generated submodules;
File acquisition submodule is used for:The input path of specified description file and the outgoing route after conversion C files;It obtains
The be described file under path is inputted, analytic signal is sent to document analysis submodule;
Document analysis submodule is used for:After receiving analytic signal, it is successively read each description file using wscript.exe, it will
The information of reading is preserved according to certain data structure, and file generated signal is sent to C file generated submodules;
C file generated submodules are used for:After receiving file generated signal, according to the information preserved in document analysis submodule
And the template style of required C files, automatic conversion generates corresponding C files under specified outgoing route.
Domain information operation module is used for:After receiving operation signal, the register name, list item name and the domain that access as needed
Name finds the domain information of corresponding register, the domain information of list item in the C files that conversion generates;According to the domain found
Information carries out the reading of corresponding thresholding or changes operation.
Wherein, domain information operation module includes judging submodule, searches submodule, domain information judging submodule and domain information
Handle submodule;
Judging submodule is used for:Register name, the list item name accessed as needed judges that corresponding register, list item are
No presence, if so, sending lookup signal to submodule is searched;Otherwise error message is directly returned, is terminated;
Submodule is searched to be used for:It receives after searching signal, the institute of corresponding register is searched in the C files that conversion generates
All domain informations for having domain information, list item judge signal to the transmission of domain information judging submodule;
Domain information judging submodule is used for:It receives after judging signal, according to the domain name to be accessed, judges the register
In all domain informations, domain information corresponding with domain name whether is respectively present in all domain informations of the list item, if so, believing to domain
Breath processing submodule sends processing signal;Otherwise error message is returned, is terminated;
Domain information processing submodule is used for:After receiving processing signal, corresponding domain information is obtained, and according to the corresponding domain
Information carries out the reading of corresponding thresholding or changes operation.
The present invention is not limited to the above-described embodiments, for those skilled in the art, is not departing from
Under the premise of the principle of the invention, several improvements and modifications can also be made, these improvements and modifications are also considered as the protection of the present invention
Within the scope of.The content not being described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.