From a92da3e0a41871a2e96a88810348eed7827fe20c Mon Sep 17 00:00:00 2001 From: Dragon-Git <1762578117@qq.com> Date: Sun, 17 Dec 2023 20:36:54 +0800 Subject: [PATCH] [doc] update README --- README.md | 71 +++++++++++++++++++++++++++++++++++++------- src/uvmgen/uvmgen.py | 10 +++++-- 2 files changed, 69 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6707361..89aecad 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,66 @@ -# icdk (IC Deveplopment Toolkit) +# icdk (IC Deveplopment Toolkit) +![PyPI - Python Version](https://img.shields.io/pypi/pyversions/uvmgen) +[![PyPI - Version](https://img.shields.io/pypi/v/uvmgen)](https://pypi.org/project/uvmgen) +![GitHub language count](https://img.shields.io/github/languages/count/Dragon-Git/icdk?logo=python) +[![Latest Release](https://img.shields.io/github/v/release/Dragon-Git/icdk?color=blue&label=Latest%20Release)](https://github.com/Dragon-Git/icdk/releases/latest) +[![downloads](https://pepy.tech/badge/uvmgen)](https://pepy.tech/project/uvmgen) +[![CI](https://github.com/Dragon-Git/icdk/actions/workflows/python_package.yml/badge.svg)](https://github.com/Dragon-Git/icdk/actions/workflows/python_package.yml) +![GitHub deployments](https://img.shields.io/github/deployments/Dragon-Git/icdk/release) +--- +## Introduction + +uvmgen is a command-line interface (CLI) program for generating testbench structures based on a provided JSON configuration file. This user guide provides detailed information on how to use uvmgen effectively. ## Installing - Install from [PyPi](https://pypi.org/project/uvmgen) using pip: - ```bash - python3 -m pip install uvmgen - ``` -## Using steps - - python3 -m pip install uvmgen - - if you want to generate a complete UVM environment , modify typeical. json in example file - - if you want to generate a agent or others, modify your expected json in base_pkg file - - enter the json folder to execute uvmgen ***.json command ,and can generate environment +
+ Prerequisites + +- Operating systems + - Windows + - Linux + - macOS +- Python: 3.8 ~ 3.12 +
+ +Use Python's package installer pip to install uvmgen: +```bash +python3 -m pip install uvmgen +``` + +## Usage + +The basic usage of uvmgen is as follows: +```bash +uvmgen --input --output +``` + +### Options + +- `--input `: Specifies the input JSON file containing the configuration for the testbench structure. +- `--output `: Specifies the directory where the generated files will be placed. + +### Help + +For additional help and options, you can use the -h or --help option: + +```bash +uvmgen -h +``` + +## Example + +Suppose you have a JSON configuration file named testbench_config.json and you want to generate the testbench structure in a directory named tb, you would run the following command: + +```bash +uvmgen --input testbench_config.json --output tb +# or +uvmgen -i testbench_config.json -o tb +# or +uvmgen -i testbench_config.json +``` +You can use `test/json/example/typical.json` to generate a complete UVM environment, or use `test/json/base_pkg/***.json` to generate a single package. +## Contribute +Contributions are always welcome! Simple fork this repo and submit a pull request. diff --git a/src/uvmgen/uvmgen.py b/src/uvmgen/uvmgen.py index 5c9b517..8315879 100644 --- a/src/uvmgen/uvmgen.py +++ b/src/uvmgen/uvmgen.py @@ -7,7 +7,7 @@ class uvm_gen(): """ """ - def __init__(self, template_path = ""): + def __init__(self, template_path:str = ""): template_path = template_path or Path(__file__).parent / "templates" self.template_paths = [template_path] + list(template_path.iterdir()) @@ -31,7 +31,13 @@ def serve_template(self, template_name, output_name, data): Path(self.output_path / output_name).write_text(tpl.render(**data["vars"])) print("*** Generate Target File < " + output_name + " > is Done!") - def gen(self, input, output = "tb"): + def gen(self, input:str, output:str = "tb"): + """gennerate testbench framework + + Args: + input: JSON file to configure the testbench structure + output: directory where the generated files will be placed + """ self.data = json.load(open(input)) for k,v in self.data.items(): pkg_tpl_path = Path(self.template_paths[0]) / v["type"]