Skip to content

Commit a88e6af

Browse files
Merge pull request #240 from riscv/create_param_udb_exporter
Create param udb exporter
2 parents ed7a9df + 19b6f98 commit a88e6af

88 files changed

Lines changed: 2306 additions & 43 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ repos:
1616
hooks:
1717
- id: yamlfmt
1818
args: [--mapping, '2', --sequence, '4', --offset, '2', --preserve-quotes]
19+
exclude: ^tests/params/expected/

Makefile

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ CSR_TABLE_VARIANT_FILES := \
5454
$(PARAMS_TESTS_DIR)/test-csr-table-full-default.yaml \
5555
$(PARAMS_TESTS_DIR)/test-csr-table-reordered.yaml \
5656
$(PARAMS_TESTS_DIR)/test-csr-table-minimal.yaml
57+
EXPORT_PARAMS_TO_UDB_TOOL := $(TOOLS_DIR)/export_params_to_udb.py
58+
EXPORT_PARAMS_TO_UDB_PYTHON := python3 $(EXPORT_PARAMS_TO_UDB_TOOL)
5759

5860
# Stuff for building test standards document in HTML to have links into it.
5961
DOCS = test-ch1 test-ch2
@@ -106,6 +108,8 @@ BUILT_PARAM_TABLE_VARIANTS_DIR := $(BUILD_DIR)/test-param-table-variants
106108
BUILT_PARAM_TABLE_VARIANTS_STAMP := $(BUILD_DIR)/test-param-table-variants.done
107109
BUILT_CSR_TABLE_VARIANTS_DIR := $(BUILD_DIR)/test-csr-table-variants
108110
BUILT_CSR_TABLE_VARIANTS_STAMP := $(BUILD_DIR)/test-csr-table-variants.done
111+
BUILT_EXPORT_PARAMS_TO_UDB_DIR := $(BUILD_DIR)/test-export-params-to-udb
112+
BUILT_EXPORT_PARAMS_TO_UDB_STAMP := $(BUILD_DIR)/test-export-params-to-udb.done
109113

110114
# Combine separate fnames into lists.
111115
BUILT_TEST_HTML_FNAMES := $(BUILT_TEST_CH1_HTML_FNAME) $(BUILT_TEST_CH2_HTML_FNAME)
@@ -125,6 +129,7 @@ EXPECTED_CSRS_ADOC := $(PARAMS_EXPECTED_DIR)/test-csr-appendix.adoc
125129
EXPECTED_CSR_ADOC_DIR := $(PARAMS_EXPECTED_DIR)/test-csr-appendix-adoc-includes
126130
EXPECTED_PARAM_TABLE_VARIANTS_DIR := $(PARAMS_EXPECTED_DIR)/test-param-table-variants
127131
EXPECTED_CSR_TABLE_VARIANTS_DIR := $(PARAMS_EXPECTED_DIR)/test-csr-table-variants
132+
EXPECTED_EXPORT_PARAMS_TO_UDB_DIR := $(PARAMS_EXPECTED_DIR)/test-export-params-to-udb
128133

129134
# Normative rule definition input YAML files.
130135
GOOD_NORM_RULE_DEF_FILES := $(NORM_RULE_DEF_DIR)/test-ch1.yaml $(NORM_RULE_DEF_DIR)/test-ch2.yaml
@@ -206,17 +211,26 @@ OPTIONS := --trace \
206211
--failure-level=WARN
207212

208213

214+
209215
# Default target
210216
.PHONY: all
211217
all: test
212218

219+
220+
213221
# Build tests and compare against expected
214222
.PHONY: test
215223
test: build-tests compare-tests test-tag-changes test-adoc2html test-shared-utils test-text-to-html
216224

217225
# Build tests
218-
.PHONY: build-tests build-test-tags build-test-norm-rules-json build-test-norm-rules-html build-test-tags-without-rules build-test-params-json build-test-params-html build-test-param-adoc build-test-csr-adoc build-test-param-table-variants build-test-csr-table-variants
219-
build-tests: build-test-tags build-test-norm-rules-json build-test-norm-rules-html build-test-tags-without-rules build-test-params-json build-test-params-html build-test-param-adoc build-test-csr-adoc build-test-param-table-variants build-test-csr-table-variants
226+
.PHONY: build-tests build-test-tags build-test-norm-rules-json build-test-norm-rules-html
227+
.PHONY: build-test-tags-without-rules build-test-params-json build-test-params-html
228+
.PHONY: build-test-param-adoc build-test-csr-adoc build-test-param-table-variants
229+
.PHONY: build-test-csr-table-variants build-test-export-params-to-udb
230+
build-tests: build-test-tags build-test-norm-rules-json build-test-norm-rules-html \
231+
build-test-tags-without-rules build-test-params-json build-test-params-html build-test-param-adoc \
232+
build-test-csr-adoc build-test-param-table-variants build-test-csr-table-variants \
233+
build-test-export-params-to-udb
220234
build-test-tags: $(BUILT_TEST_NORM_TAGS_FNAMES) $(BUILT_DUPLICATE_NORM_TAGS_FNAME)
221235
build-test-norm-rules-json: $(BUILT_NORM_RULES_JSON)
222236
build-test-norm-rules-html: $(BUILT_NORM_RULES_HTML)
@@ -227,10 +241,14 @@ build-test-param-adoc: $(BUILT_PARAM_ADOC_STAMP)
227241
build-test-csr-adoc: $(BUILT_CSR_ADOC_STAMP)
228242
build-test-param-table-variants: $(BUILT_PARAM_TABLE_VARIANTS_STAMP)
229243
build-test-csr-table-variants: $(BUILT_CSR_TABLE_VARIANTS_STAMP)
244+
build-test-export-params-to-udb: $(BUILT_EXPORT_PARAMS_TO_UDB_STAMP)
230245

231246
# Compare tests against expected
232247
.PHONY: compare-tests
233-
compare-tests: compare-test-tags compare-test-norm-rules-json compare-test-norm-rules-html compare-test-params-json compare-test-params-html compare-test-params-adoc compare-test-param-adoc-files compare-test-csrs-adoc compare-test-csr-adoc-files compare-test-param-table-variants compare-test-csr-table-variants
248+
compare-tests: compare-test-tags compare-test-norm-rules-json compare-test-norm-rules-html \
249+
compare-test-params-json compare-test-params-html compare-test-params-adoc \
250+
compare-test-param-adoc-files compare-test-csrs-adoc compare-test-csr-adoc-files \
251+
compare-test-param-table-variants compare-test-csr-table-variants compare-test-export-params-to-udb
234252

235253
.PHONY: compare-test-tags
236254
compare-test-tags: compare-test-ch1-tags compare-test-ch2-tags
@@ -295,7 +313,13 @@ compare-test-csr-table-variants: $(EXPECTED_CSR_TABLE_VARIANTS_DIR) $(BUILT_CSR_
295313
@echo "CHECKING CSR TABLE VARIANT OUTPUTS AGAINST EXPECTED"
296314
diff -r $(EXPECTED_CSR_TABLE_VARIANTS_DIR) $(BUILT_CSR_TABLE_VARIANTS_DIR) && echo "diff PASSED" || (echo "diff FAILED"; exit 1)
297315

316+
.PHONY: compare-test-export-params-to-udb
317+
compare-test-export-params-to-udb: $(EXPECTED_EXPORT_PARAMS_TO_UDB_DIR) $(BUILT_EXPORT_PARAMS_TO_UDB_DIR)
318+
@echo "CHECKING GENERATED EXPORT PARAMS TO UDB FILES AGAINST EXPECTED"
319+
diff -r $(EXPECTED_EXPORT_PARAMS_TO_UDB_DIR) $(BUILT_EXPORT_PARAMS_TO_UDB_DIR) && echo "diff PASSED" || (echo "diff FAILED"; exit 1)
320+
#
298321
# Test tag change detection
322+
#
299323
.PHONY: test-tag-changes test-tag-changes-basic test-tag-changes-verbose test-tag-changes-no-changes test-tag-changes-additions-only test-tag-changes-whitespace-only test-tag-changes-formatting-only test-tag-changes-update
300324
test-tag-changes: test-tag-changes-basic test-tag-changes-verbose test-tag-changes-no-changes test-tag-changes-additions-only test-tag-changes-whitespace-only test-tag-changes-formatting-only test-tag-changes-update
301325

@@ -361,9 +385,17 @@ test-tag-text-to-html-unit: $(TAG_TEXT_TO_HTML_UNIT_TEST_SCRIPT) $(TOOLS_DIR)/ta
361385
@echo "TESTING TAG_TEXT_TO_HTML UNIT HELPERS"
362386
python3 $(TAG_TEXT_TO_HTML_UNIT_TEST_SCRIPT) && echo "test-tag-text-to-html-unit PASSED" || (echo "test-tag-text-to-html-unit FAILED"; exit 1)
363387

388+
#
364389
# Update expected files from built files
390+
#
391+
365392
.PHONY: update-expected
366-
update-expected: update-test-tags update-test-norm-rules-json update-test-norm-rules-html update-test-params-json update-test-params-html update-test-params-adoc update-test-param-adoc-files update-test-csrs-adoc update-test-csr-adoc-files update-test-param-table-variants update-test-csr-table-variants
393+
update-expected: update-test-tags update-test-norm-rules-json update-test-norm-rules-html update-test-params-json update-test-params-html update-test-params-adoc update-test-param-adoc-files update-test-csrs-adoc update-test-csr-adoc-files update-test-param-table-variants update-test-csr-table-variants update-test-export-params-to-udb
394+
# Update expected UDB YAMLs from built UDB YAMLs
395+
.PHONY: update-test-export-params-to-udb
396+
update-test-export-params-to-udb: build-test-export-params-to-udb
397+
rm -rf $(PARAMS_EXPECTED_DIR)/test-export-params-to-udb
398+
cp -r $(BUILD_DIR)/test-export-params-to-udb $(PARAMS_EXPECTED_DIR)/test-export-params-to-udb
367399

368400
.PHONY: update-test-tags
369401
update-test-tags: update-test-ch1-tags update-test-ch2-tags
@@ -529,6 +561,13 @@ $(BUILT_NORM_RULES_TAGS_NO_RULES): $(BUILT_TEST_CH1_NORM_TAGS_FNAME) $(BAD_NORM_
529561
$(DOCKER_CMD) $(DOCKER_QUOTE) $(CREATE_NORM_RULE_TOOL) $(NORM_TAG_FILE_ARGS) $(BAD_NORM_RULE_DEF_ARGS) $(NORM_RULE_DOC2URL_ARGS) $(BUILD_DIR)/bogus || touch $(BUILT_NORM_RULES_TAGS_NO_RULES) $(DOCKER_QUOTE)
530562
$(WORKDIR_TEARDOWN)
531563

564+
$(BUILT_EXPORT_PARAMS_TO_UDB_STAMP): $(BUILT_PARAMS_JSON) $(EXPORT_PARAMS_TO_UDB_TOOL)
565+
$(WORKDIR_SETUP)
566+
cp -f $(BUILT_PARAMS_JSON) $@.workdir/$(BUILD_DIR)
567+
$(DOCKER_CMD) $(DOCKER_QUOTE) $(EXPORT_PARAMS_TO_UDB_PYTHON) --input $(BUILT_PARAMS_JSON) --output-dir $(BUILT_EXPORT_PARAMS_TO_UDB_DIR) && touch $(BUILT_EXPORT_PARAMS_TO_UDB_STAMP) $(DOCKER_QUOTE)
568+
mv $@.workdir/$(BUILT_EXPORT_PARAMS_TO_UDB_DIR) $(BUILT_EXPORT_PARAMS_TO_UDB_DIR)
569+
$(WORKDIR_TEARDOWN)
570+
532571
# Update docker image to latest
533572
docker-pull-latest:
534573
${DOCKER_BIN} pull ${DOCKER_IMG}

schemas/param-defs-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"$ref": "param-common-schema.json#/paramNameArray",
2626
"description": "Multiple parameter names"
2727
},
28+
"long-name": {
29+
"type": "string",
30+
"description": "Long name of the parameter (a few words)"
31+
},
2832
"note": {
2933
"type": "string",
3034
"$ref": "param-common-schema.json#/noteDesc"

schemas/params-schema.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
"type": "object",
1212
"properties": {
1313
"name": {
14-
"type": "string",
15-
"description": "Parameter name"
14+
"$ref": "param-common-schema.json#/paramName",
15+
"description": "Parameter name (all uppercase with underscores for separators)"
16+
},
17+
"long-name": {
18+
"type": "string",
19+
"description": "Long name of the parameter (a few words)"
1620
},
1721
"def_filename": {
1822
"type": "string",
@@ -62,7 +66,7 @@
6266
]
6367
}
6468
},
65-
"required": ["name", "def_filename", "chapter_name", "json-schema"],
69+
"required": ["name", "long-name", "def_filename", "chapter_name", "json-schema"],
6670
"allOf": [
6771
{
6872
"oneOf": [
@@ -165,7 +169,7 @@
165169
]
166170
}
167171
},
168-
"required": ["reg-name", "def_filename", "chapter_name", "category", "type"],
172+
"required": ["reg-name", "long-name", "def_filename", "chapter_name", "category", "type"],
169173
"allOf": [
170174
{
171175
"if": {

0 commit comments

Comments
 (0)