-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_files.py
executable file
·51 lines (41 loc) · 1.72 KB
/
copy_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import shutil
from pathlib import Path
# Define the destination directory
dest_dir = Path("copy_dir")
# Create the destination directory if it doesn't exist
dest_dir.mkdir(exist_ok=True)
# List of folders you're working with
folders = ["dimc_macro", "qkt_macro_handler_hub", "qkv_macro_handler_hub", "snax_req_handler",
"qkt_macro_handler_unit", "qkv_macro_handler_unit", "snax_interfaces", "streamer_handler"]
# Loop through each folder and copy the required files and folders
for folder in folders:
# Define the source directory
src_dir = Path(folder) / "target_all_PIN"
# Handle different RTL file name for dimc_macro
if folder == "dimc_macro":
rtl_file = src_dir / "dimc_detail_model_rtl.v"
else:
rtl_file = src_dir / f"{folder}_rtl.v"
# Define the source v_rtl and src folders
v_rtl_dir = src_dir / "v_rtl"
src_dir_folder = src_dir / "src"
# Create a destination subdirectory for each module under copy_dir
module_dest_dir = dest_dir / folder
module_dest_dir.mkdir(exist_ok=True)
# Copy the RTL file if it exists
if rtl_file.is_file():
shutil.copy(rtl_file, module_dest_dir)
else:
print(f"RTL file not found: {rtl_file}")
# Copy the v_rtl directory if it exists
if v_rtl_dir.is_dir():
shutil.copytree(v_rtl_dir, module_dest_dir / "v_rtl", dirs_exist_ok=True)
else:
print(f"v_rtl directory not found: {v_rtl_dir}")
# Copy the src directory if it exists
if src_dir_folder.is_dir():
shutil.copytree(src_dir_folder, module_dest_dir / "src", dirs_exist_ok=True)
else:
print(f"src directory not found: {src_dir_folder}")
print(f"Files and directories copied to {dest_dir}")