6. Code Docs¶
-
csrbox.csr_gen.
create_concat_vector
(mylist, xlen)[source]¶ Function to return a bsv-string for a csr which is the concetation of the all its subfields and gaps replaced with zeros’
- Parameters
mylist – A list of 3 tuple entries. Each entry has the following
information per subfield [msb of subfield, width of the subfield, name of the subfield]
- Returns
string with concatenation of all the sub-fields.
-
csrbox.csr_gen.
csr_decoder
(isa_yaml, work_dir, bsv, logging=False)[source]¶ Function to generate the bluespec decoder file indicating if the access to the CSR if valid or not :param isa_yaml: the riscv-config isa YAML :param work_dir: path to the directory where the bluespec files should be generated :param bsv: name of the file to be created inside the work_dir
-
csrbox.csr_gen.
csr_define
(isa_yaml, work_dir, bsv, logging=False)[source]¶ Function which generates the defines file which captues the macro encodings used across the csrbox bsv modules
-
csrbox.csr_gen.
csr_gen
(isa_file, grp_file, work_dir, logging=False)[source]¶ Top level function which validates the sanity of the grouping yaml followed by calls to subfunctions which generated the corresponding bluespec code. This function further assumes that the riscv-config isa yaml provided is the validated/normalized version.
We also update the the size node for the csrs in the attributes YAML file based on the csrs that have been instantiated in the riscv-config YAML
-
csrbox.csr_gen.
csr_top
(isa_yaml, grp_yaml, attr_yaml, rvxlen, pkgname, logging=False)[source]¶ Function to create the top level bluespec module which instantiates the individual group/station and creates the connection between them.
The function also creates the methods required for handling traps and returns.
-
csrbox.csr_gen.
csr_types
(isa_yaml, work_dir, bsv, logging=False)[source]¶ Function to generate the types bluespec file which includes structures and functions that are used across the csrbox modules
-
csrbox.csr_gen.
derive_warl_func
(csr_name, width, warl_str)[source]¶ Function to convert the warl strings in the riscv-config YAML to corresponding bluespec code.
The function first splits the warl string into the condition and the legalizing strings. A regular expression is then applied to both strings separately to extract parameters and create bluespec code.
-
csrbox.csr_gen.
find_group
(bar, csrname, logging=False)[source]¶ Function to find the group which a particular csr belongs to in the grouping yaml
-
csrbox.csr_gen.
get_reset_val
(value, width, lsb, xlen)[source]¶ Function to extract ‘width’ number of bits starting at the ‘lsb’ position of the value. Note here that the python indexes the binary string from the let while the lsb defines the position from the right. Hence the need for this function
- Parameters
value – the integer value from which bits need to be extracted.
width – size of extraction
lsb – starting position of extraction
- Returns
returns the reset value in decimal form
-
csrbox.csr_gen.
groups_gen
(isa_yaml, grp_yaml, attr_yaml, work_dir, logging=False)[source]¶ Function which co-ordinates the generation of all the bluespec code for the individual groups/stations and the top level bluespec module.
The function first creates a subset of the riscv-config isa yaml based on the csrs present in each group and calls various sub-functions to generate the corresponding bsv file of the individual groups/station.
Once the station files are generated the csr_top is called which is used to generate the top module instantiating and connecting all the individual groups/stations.
-
csrbox.csr_gen.
station_interface
(isa_yaml, grp_yaml, attr_yaml, rvxlen, pkg_name, last, bsvstr, logging=False)[source]¶ Function to create the interface definition of individual groups/stations.
First Value methods are created for all csrs that are instantiated in the particular group. Next, custom action methods required for specific csrs of their subfields are created.
Finally action methods to read shadow or dependent csrs is created.
- Parameters
isa_yaml (dict) – the riscv-config isa YAML
grp_yaml (dict) – the grouping YAML
attr_yaml (dict) – the attributes YAML
rvxlen (str) – a string containing the format: “rv32” or “rv64” depending on the XLEN value of the DUT
pkg_name (str) – name of the bluespec package this code belongs to.
last (bool) – indicating this is the last station in the chain
bsvstr (str) – string containing rest of the code generated for the particular group/station
work_dir (str) – path to the directory where the bluespec files should be generated
-
csrbox.csr_gen.
station_methods
(isa_yaml, grp_yaml, attr_yaml, rvxlen, pkg_name, last, bsvstr, logging=False)[source]¶ Function to create the bluespec method definitions for each group/station. First the value methods of each csr in the group is created. Followed by custom action method and then the shadow/dependent csrs.
- Parameters
isa_yaml (dict) – the riscv-config isa YAML
grp_yaml (dict) – the grouping YAML
attr_yaml (dict) – the attributes YAML
rvxlen (str) – a string containing the format: “rv32” or “rv64” depending on the XLEN value of the DUT
pkg_name (str) – name of the bluespec package this code belongs to.
last (bool) – indicating this is the last station in the chain
bsvstr (str) – string containing rest of the code generated for the particular group/station
work_dir (str) – path to the directory where the bluespec files should be generated
-
csrbox.csr_gen.
station_modbody
(isa_yaml, grp_yaml, attr_yaml, rvxlen, pkg_name, last, bsvstr, logging=False)[source]¶ Function to create the bluespec module rules/body requirements per csr basis
- Parameters
isa_yaml (dict) – the riscv-config isa YAML
grp_yaml (dict) – the grouping YAML
attr_yaml (dict) – the attributes YAML
rvxlen (str) – a string containing the format: “rv32” or “rv64” depending on the XLEN value of the DUT
pkg_name (str) – name of the bluespec package this code belongs to.
last (bool) – indicating this is the last station in the chain
bsvstr (str) – string containing rest of the code generated for the particular group/station
work_dir (str) – path to the directory where the bluespec files should be generated
-
csrbox.csr_gen.
station_module
(isa_yaml, grp_yaml, attr_yaml, rvxlen, pkg_name, last, bsvstr, logging=False)[source]¶ Function to create the bluespec module syntax and other synthesis attributes of the module
- Parameters
isa_yaml (dict) – the riscv-config isa YAML
grp_yaml (dict) – the grouping YAML
attr_yaml (dict) – the attributes YAML
rvxlen (str) – a string containing the format: “rv32” or “rv64” depending on the XLEN value of the DUT
pkg_name (str) – name of the bluespec package this code belongs to.
last (bool) – indicating this is the last station in the chain
bsvstr (str) – string containing rest of the code generated for the particular group/station
work_dir (str) – path to the directory where the bluespec files should be generated
-
csrbox.csr_gen.
station_regs
(isa_yaml, grp_yaml, attr_yaml, rvxlen, pkg_name, last, bsvstr, logging=False)[source]¶ Function to create the register and wires required to create the csrs. The function also creates WARL bluespec syntax using the derive_warl_func function.
First the shadow/dependent wires are declared followed by the instantiation of the csrs present in the current group
- Parameters
isa_yaml (dict) – the riscv-config isa YAML
grp_yaml (dict) – the grouping YAML
attr_yaml (dict) – the attributes YAML
rvxlen (str) – a string containing the format: “rv32” or “rv64” depending on the XLEN value of the DUT
pkg_name (str) – name of the bluespec package this code belongs to.
last (bool) – indicating this is the last station in the chain
bsvstr (str) – string containing rest of the code generated for the particular group/station
work_dir (str) – path to the directory where the bluespec files should be generated
-
csrbox.csr_gen.
station_req
(isa_yaml, grp_yaml, attr_yaml, rvxlen, pkg_name, last, bsvstr, logging=False)[source]¶ The function to create the final methods which serves the request from the core for each csr.
- Parameters
isa_yaml (dict) – the riscv-config isa YAML
grp_yaml (dict) – the grouping YAML
attr_yaml (dict) – the attributes YAML
rvxlen (str) – a string containing the format: “rv32” or “rv64” depending on the XLEN value of the DUT
pkg_name (str) – name of the bluespec package this code belongs to.
last (bool) – indicating this is the last station in the chain
bsvstr (str) – string containing rest of the code generated for the particular group/station
work_dir (str) – path to the directory where the bluespec files should be generated