|
1 | 1 | from cerberus import Validator |
2 | 2 | from riscv_config.warl import warl_interpreter |
3 | 3 | import riscv_config.constants as constants |
| 4 | +from riscv_config.isa_validator import * |
4 | 5 | import re |
5 | | -import os |
6 | 6 |
|
7 | 7 |
|
8 | 8 | class schemaValidator(Validator): |
@@ -78,58 +78,11 @@ def _check_with_capture_isa_specifics(self, field, value): |
78 | 78 | if not constants.isa_regex.match(value): |
79 | 79 | self._error(field, 'Input ISA string does not match regex') |
80 | 80 |
|
81 | | - #ISA checks |
82 | | - str_match = re.findall('(?P<stdisa>[^\d]*?)(?!_)*(?P<zext>Z.*?)*(?P<sext>S[a-z]*)*(_|$)',value) |
83 | | - extension_list= [] |
84 | | - standard_isa = '' |
85 | | - for match in str_match: |
86 | | - stdisa, zext, sext, ignore = match |
87 | | - if stdisa != '': |
88 | | - for e in stdisa: |
89 | | - extension_list.append(e) |
90 | | - standard_isa = stdisa |
91 | | - if zext != '': |
92 | | - extension_list.append(zext) |
93 | | - if sext != '': |
94 | | - extension_list.append(sext) |
95 | | - # check ordering of ISA |
96 | | - canonical_ordering = 'IEMAFDQLCBJKTPVNSHU' |
97 | | - order_index = {c: i for i, c in enumerate(canonical_ordering)} |
98 | | - for i in range(len(standard_isa)-1): |
99 | | - a1 = standard_isa[i] |
100 | | - a2 = standard_isa[i+1] |
101 | | - |
102 | | - if order_index[a1] > order_index[a2]: |
103 | | - self._error(field, "Alphabet '" + a1 + "' should occur after '" + a2) |
104 | | - |
105 | | - if 'I' not in extension_list and 'E' not in extension_list: |
106 | | - self._error(field, 'Either of I or E base extensions need to be present in the ISA string') |
107 | | - if 'F' in extension_list and not "Zicsr" in extension_list: |
108 | | - self._error(field, "F cannot exist without Zicsr.") |
109 | | - if 'D' in extension_list and not 'F' in extension_list: |
110 | | - self._error(field, "D cannot exist without F.") |
111 | | - if 'Q' in extension_list and not 'D' in extension_list: |
112 | | - self._error(field, "Q cannot exist without D and F.") |
113 | | - if 'Zam' in extension_list and not 'A' in extension_list: |
114 | | - self._error(field, "Zam cannot exist without A.") |
115 | | - if 'N' in extension_list and not 'U' in extension_list: |
116 | | - self._error(field, "N cannot exist without U.") |
117 | | - if 'S' in extension_list and not 'U' in extension_list: |
118 | | - self._error(field, "S cannot exist without U.") |
119 | | - if 'Zkg' in extension_list and 'Zbc' in extension_list: |
120 | | - self._error(field, "Zkg being a proper subset of Zbc (from B extension) should be ommitted from the ISA string") |
121 | | - if 'Zkb' in extension_list and 'Zbp' in extension_list : |
122 | | - self._error(field, "Zkb being a proper subset of Zbp (from B extension) should be ommitted from the ISA string") |
123 | | - if 'Zks' in extension_list and ( set(['Zkse', 'Zksh','Zkg','Zkb']) & set(extension_list) ): |
124 | | - self._error(field, "Zks is a superset of Zkse, Zksh, Zkg and Zkb. In presence of Zks the subsets must be ignored in the ISA string.") |
125 | | - if 'Zkn' in extension_list and ( set(['Zkne','Zknd','Zknh','Zkg','Zkb']) & set(extension_list) ): |
126 | | - self._error(field, "Zkn is a superset of Zkne, Zknd, Zknh, Zkg and Zkb, In presence of Zkn the subsets must be ignored in the ISA string") |
127 | | - if 'K' in extension_list and ( set(['Zkn','Zkr','Zkne','Zknd','Zknh','Zkg','Zkb']) & set(extension_list) ) : |
128 | | - self._error(field, "K is a superset of Zkn and Zkr , In presence of K the subsets must be ignored in the ISA string") |
129 | | - |
130 | | -# if 'Z' in value and not self.document['User_Spec_Version'] == "2.3": |
131 | | -# self._error( |
132 | | -# field, "Z is not supported in the User Spec given version.") |
| 81 | + (extension_list, err, err_list) = get_extension_list(value) |
| 82 | + if err: |
| 83 | + for e in err_list: |
| 84 | + self._error(field, e) |
| 85 | + |
133 | 86 | #ISA encoding for future use. |
134 | 87 | for x in "ABCDEFHIJKLMNPQSTUVX": |
135 | 88 | if (x in ext): |
|
0 commit comments