|
V
|
|
perl script to parse a VR_AD file and generate
write operation commands.
-
This script works on a VR_AD file and generates write operation commands.
In my case on each RW register, a VR_AD write command is generated.
There is also an option to generate a list of registers only (if a parameter is
given to the script). This script was used in a very specific case. In most cases
one would use a code style as shown in:
vr_ad get_all_regs
-
The input might look like:
reg_def KUKU_REG {
reg_fld KUKU_PAGE_1_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKUOWLEDGE_1_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKUTE_FAULT_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKURVED__012_012 : uint(bits : 1) : RW : 0x0000;
reg_fld KUKUMETRIC_PAUSE_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKUE_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKU0BT4_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKU0BTX_FD_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKU0BTX_HD_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKUBT_FD_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKUBT_HD_A1 : uint(bits : 1) : R : 0x0000 : cov;
reg_fld KUKUCTOR_FIELD_A1 : uint(bits : 5) : R : 0x0000 : cov;
};
-
The script is invoked from within vim by:
%! perl ~/bin/vim_vr_ad_wr_rd.pl
The output is:
var N_0_KUKURVED__012_012_gen : uint(bits : 1);
gen N_0_KUKURVED__012_012_gen;
PKFASTFREQ_REG_WRITE KUKU_REG {
.KUKURVED__012_012=N_0_KUKURVED__012_012_gen;
};
-
The script is listed below:
- #!/bin/perl
- #%! perl ~/bin/vim_vr_ad_wr_rd.pl
- #%! perl ~/bin/vim_vr_ad_wr_rd.pl list
- #to avoid same field naming each field is also given a
- #number, so the specm aribtrary variable has a uniqe name.
- $field_no=0;
- #some registers shall not be written randomally.
- @no_write_a = ();
- push(@no_write_a, "REG_FAST");
- push(@no_write_a, "REG_SLOW");
- push(@no_write_a, "REG_PARALLEL");
- #it is possible to generate only a list of registers
- $gen_list_only=index($ARGV[0], "list");
- $reg_name="";
- while (<STDIN>) {
- chomp($_);
- if($_ =~ /^reg_def[ \s\t]*([A-Za-z][A-Za-z0-9_]*)[ \s\t]*{.*/) {
- $reg_name=$1;
- $ignore_flg=0;
- foreach $ignore ( @no_write_a ) {
- $cmpix=index($reg_name, $ignore);
- if($cmpix == 0) {
- $ignore_flg=1;
- last;
- }
- }
- if($ignore_flg == 0 && $gen_list_only == 0) {
- print(" permitted_to_wr_l.push($reg_name);\n");
- }
- }
- elsif($_ =~ /[ \s\t]*reg_fld[ \s\t]*([A-Za-z][A-Za-z0-9_]*)[ \s\t]*:[ \s\t]*(uint\(bits[ \s\t]*:[ \s\t]*[0-9]*\))/) {
- #get reg_fields
- $reg_fld=$1;
- $reg_fld_uint=$2;
- $skip_on_RESERVED=index($reg_fld, "RESERVED");
- if($ignore_flg == 0 && $skip_on_RESERVED < 0 && $gen_list_only != 0) {
- if($_ =~ /:[ \s\t]*RW[ \s\t]*/) {
- &wr_reg($reg_name, $reg_fld, $reg_fld_uint);
- }
- }
- }
- }#while
- sub wr_reg {
- #0 reg name
- #1 reg field
- #2 uint(bits:n)
- my $var_name;
- $var_name="N_" . $field_no . "_" . $_[1] . "_gen";
- print("var $var_name : $_[2];\n");
- print("gen $var_name;\n");
- print("PKFASTFREQ_REG_REG_WRITE $_[0] {\n");
- print(" ."); print("$_[1]"); print("=$var_name;\n");
- print("};\n");
- $field_no++;
- }
|
|
... |
|
|
Search This Site
Feedback This Site
new pages on this site
|
|