22import os
33import logging
44import riscv_config .utils as utils
5+ import textwrap
56
67logger = logging .getLogger (__name__ )
78
@@ -27,7 +28,8 @@ def prevsum(self, i, k):
2728 def islegal (self , value , dependency_vals = []):
2829 is_legal = False
2930 logger .debug ('Checking for isLegal for WARL: \n ' +
30- utils .pretty_print_yaml (self .warl ) + '\n With following args:' \
31+ textwrap .indent (utils .pretty_print_yaml (self .warl ),' ' )
32+ + '\n With following args:'
3133 + 'val : ' + str (value ) + ' dep_vals :' +
3234 str (dependency_vals ))
3335 if not self .dependencies : # no dependencies in the warl
@@ -77,9 +79,19 @@ def islegal(self, value, dependency_vals=[]):
7779 dep_search = self .exp .search (dep_str )
7880 if csr_search is None or dep_search is None :
7981 logger .error ('Warl legal string is wrong :\n \t ' + legal_str )
80- raise SystemExit
82+ raise SystemExit ( 1 )
8183 dep_csr = dep_search .group ('csr' )
8284 dep_ind = dep_search .group ('csr_ind' )
85+ if ':' in dep_ind :
86+ msb = int (dep_ind .split (':' )[0 ],0 )
87+ lsb = int (dep_ind .split (':' )[1 ],0 )
88+ else :
89+ lsb = int (dep_ind ,0 )
90+ msb = lsb
91+ if (msb < lsb ):
92+ logger .error ('msb < lsb for in dependency field of warl:\n \n ' +
93+ utils .pretty_print_yaml (self .warl ))
94+ raise SystemExit (1 )
8395 dep_vals = dep_search .group ('csr_vals' )
8496 dep_bitmask = True if 'bitmask' in legal_str .split ('->' )[0 ] else False
8597
@@ -90,6 +102,7 @@ def islegal(self, value, dependency_vals=[]):
90102 raise SystemExit
91103 dep_satified = False
92104 recvd_val = dependency_vals [leaf_dependencies .index (dep_csr )]
105+ recvd_val = (recvd_val >> lsb ) & ((1 << (msb - lsb ))- 1 )
93106
94107 # check if the dependency value is satisfied.
95108 if ":" in dep_vals : # range is specified
0 commit comments