|
|
import os |
|
|
from mlcroissant import Dataset |
|
|
import re |
|
|
|
|
|
|
|
|
ds = Dataset(jsonld="chipbench_meta_data.json") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ensure_dir(file_path): |
|
|
directory = os.path.dirname(file_path) |
|
|
if directory and not os.path.exists(directory): |
|
|
os.makedirs(directory) |
|
|
|
|
|
|
|
|
for case in ds.records("verilog_file"): |
|
|
case_name = case["verilog_file/design_name"] |
|
|
verilog_content = case["verilog_file/verilog_content"] |
|
|
verilog_path = case["verilog_file/verilog_path"] |
|
|
print(f"Creating Verilog file: {verilog_path}") |
|
|
ensure_dir(verilog_path) |
|
|
with open(verilog_path, 'w') as f: |
|
|
|
|
|
if isinstance(verilog_content, bytes): |
|
|
verilog_content = verilog_content.decode('utf-8') |
|
|
f.write(verilog_content) |
|
|
|
|
|
|
|
|
for sdc_case in ds.records("sdc_file"): |
|
|
sdc_name = sdc_case["sdc_file/design_name"] |
|
|
sdc_content = sdc_case["sdc_file/sdc_content"] |
|
|
sdc_path = sdc_case["sdc_file/sdc_path"] |
|
|
print(f"Creating SDC file: {sdc_path}") |
|
|
ensure_dir(sdc_path) |
|
|
with open(sdc_path, 'w') as f: |
|
|
|
|
|
if isinstance(sdc_content, bytes): |
|
|
sdc_content = sdc_content.decode('utf-8') |
|
|
f.write(sdc_content) |
|
|
|
|
|
|
|
|
for lef_case in ds.records("lef_file"): |
|
|
lef_name = lef_case["lef_file/design_name"] |
|
|
lef_content = lef_case["lef_file/lef_content"] |
|
|
lef_path = lef_case["lef_file/lef_paths"] |
|
|
print(f"Creating LEF file: {lef_path}") |
|
|
ensure_dir(lef_path) |
|
|
with open(lef_path, 'w') as f: |
|
|
|
|
|
if isinstance(lef_content, bytes): |
|
|
lef_content = lef_content.decode('utf-8') |
|
|
f.write(lef_content) |
|
|
|
|
|
|
|
|
for def_case in ds.records("def_file"): |
|
|
def_name = def_case["def_file/design_name"] |
|
|
def_content = def_case["def_file/def_content"] |
|
|
def_path = def_case["def_file/def_paths"] |
|
|
print(f"Creating DEF file: {def_path}") |
|
|
ensure_dir(def_path) |
|
|
with open(def_path, 'w') as f: |
|
|
|
|
|
if isinstance(def_content, bytes): |
|
|
def_content = def_content.decode('utf-8') |
|
|
f.write(def_content) |
|
|
|
|
|
|
|
|
for liberty_case in ds.records("lib_file"): |
|
|
liberty_name = liberty_case["lib_file/design_name"] |
|
|
liberty_content = liberty_case["lib_file/lib_content"] |
|
|
liberty_path = liberty_case["lib_file/lib_paths"] |
|
|
print(f"Creating Liberty file: {liberty_path}") |
|
|
ensure_dir(liberty_path) |
|
|
with open(liberty_path, 'w') as f: |
|
|
|
|
|
if isinstance(liberty_content, bytes): |
|
|
liberty_content = liberty_content.decode('utf-8') |
|
|
f.write(liberty_content) |
|
|
|
|
|
print("All files created successfully!") |