Add batch 5 (Luthiraa_TALOS-V2, dawsonjon_fpu, The-OpenROAD-Project_OpenROAD-flow-scripts, antonblanchard_microwatt, alexforencich_verilog-i2c)
784ee2c verified Download The-OpenROAD-Project_OpenROAD-flow-scripts/tools/FakeRAM2.0/utils/run_utils.py from SAIFIINDUSTRIES/verilog_data-1: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/datasets/SAIFIINDUSTRIES/verilog_data-1/resolve/main/The-OpenROAD-Project_OpenROAD-flow-scripts/tools/FakeRAM2.0/utils/run_utils.py
- Command line
-
hf download hf://datasets/SAIFIINDUSTRIES/verilog_data-1/The-OpenROAD-Project_OpenROAD-flow-scripts/tools/FakeRAM2.0/utils/run_utils.py
-
curl -L -o run_utils.py https://huggingface.co/datasets/SAIFIINDUSTRIES/verilog_data-1/resolve/main/The-OpenROAD-Project_OpenROAD-flow-scripts/tools/FakeRAM2.0/utils/run_utils.py
2.26 kB
| #!/usr/bin/env python3 | |
| import os | |
| import json | |
| from pathlib import Path | |
| class RunUtils: | |
| def get_config(config_file): | |
| """Load the JSON configuration file""" | |
| with open(config_file, "r") as fid: | |
| raw = [line.strip() for line in fid if not line.strip().startswith("#")] | |
| json_data = json.loads("\n".join(raw)) | |
| return json_data | |
| def ensure_results_dir(output_dir, memory_name): | |
| """Ensures that the results directory exists""" | |
| p = str(Path(output_dir).expanduser().resolve(strict=False)) | |
| results_dir = os.sep.join([p, memory_name]) | |
| if not os.path.exists(results_dir): | |
| os.makedirs(results_dir) | |
| return results_dir | |
| def get_output_file_names(memory_name, output_dir): | |
| """ | |
| Returns the full paths to the output file names using the memory name | |
| as the base name | |
| """ | |
| results_dir = RunUtils.ensure_results_dir(output_dir, memory_name) | |
| lib_file_name = os.path.join(results_dir, memory_name + ".lib") | |
| lef_file_name = os.path.join(results_dir, memory_name + ".lef") | |
| verilog_file_name = os.path.join(results_dir, memory_name + ".v") | |
| sv_blackbox_file_name = os.path.join(results_dir, memory_name + ".sv") | |
| return (lib_file_name, lef_file_name, verilog_file_name, sv_blackbox_file_name) | |
| def write_memory(memory, output_dir): | |
| """Generates the output file names and then writes the files""" | |
| lib_file_name, lef_file_name, verilog_file_name, sv_blackbox_file_name = ( | |
| RunUtils.get_output_file_names(memory.get_name(), output_dir) | |
| ) | |
| RunUtils.write_all( | |
| memory, | |
| lib_file_name, | |
| lef_file_name, | |
| verilog_file_name, | |
| sv_blackbox_file_name, | |
| ) | |
| def write_all( | |
| memory, lib_file_name, lef_file_name, verilog_file_name, sv_blackbox_file_name | |
| ): | |
| """Writes the files""" | |
| memory.write_liberty_file(lib_file_name) | |
| memory.write_lef_file(lef_file_name) | |
| memory.write_verilog_file(verilog_file_name) | |
| memory.write_verilog_file(sv_blackbox_file_name, True) | |