Skip to content

Commit 43ea006

Browse files
authored
Merge pull request #78 from riscv-software-src/fix-warl-dependency-checks
fix for index-based dependency checks in warl string.
2 parents 138c69e + 0003522 commit 43ea006

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## [2.14.0] - 2022-05-13
6+
7+
- fix for index-based dependency checks in warl string.
8+
59
## [2.13.1] - 2022-03-23
6-
- Added setup.cfg to automate bumpversion
7-
- Fix wording for legal strings in dependency warl fields.
10+
11+
- Added setup.cfg to automate bumpversion
12+
- Fix wording for legal strings in dependency warl fields.
813

914
## [2.13.0] - 2022-03-09
1015
- add support for detection of svnapot in ISA string

riscv_config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from pkgutil import extend_path
22
__path__ = extend_path(__path__, __name__)
3-
__version__ = '2.13.1'
3+
__version__ = '2.14.0'

riscv_config/warl.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import logging
44
import riscv_config.utils as utils
5+
import textwrap
56

67
logger = 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

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.13.1
2+
current_version = 2.14.0
33
commit = True
44
tag = True
55

0 commit comments

Comments
 (0)