241219 Cmd that used a lot but always forget

Cmd that used a lot but always forget

import os

def getDirStruct():
    # Define target directories and their display order
    main_dirs = ['design', 'constr', 'software', 'tb']

    # Get current working directory
    cwd = os.getcwd()
    print(f"Directory structure for: {cwd}\n")

    # Generate directory structure
    for dir_name in main_dirs:
        if os.path.isdir(dir_name):
            print(f"{dir_name}/")
            # Get immediate subdirectories (second level)
            subdirs = next(os.walk(dir_name))[1]
            for subdir in sorted(subdirs):
                print(f"    {subdir}/")
            print()

def genDirStruct():
    # Directory structure configuration
    dir_structure = {
        'design': ['bd', 'hdl', 'ip'],
        'constr': [],
        'software': [],
        'tb': []
    }

    # Create directories recursively
    for main_dir, sub_dirs in dir_structure.items():
        # Create main directory
        os.makedirs(main_dir, exist_ok=True)
        print(f"Created: {main_dir}/")
        
        # Create subdirectories
        for sub_dir in sub_dirs:
            sub_path = os.path.join(main_dir, sub_dir)
            os.makedirs(sub_path, exist_ok=True)
            print(f"Created: {sub_path}/")

    print("\nDirectory structure created successfully.")

Git relative

Merge specific files from another branch

Says merge branch_B's specific files or directories to branch_A

git checkout branch_A
git checkout branch_B -- path_to_files_or_dirs

Inspect and delete remote branch

git branch -r
git push <remote-name> --delete <branch-name>
git fetch origin --prune #This option tells Git to remove any remote-tracking references in your local repository that no longer exist on the remote. In other words, if a branch has been deleted on the remote, --prune will remove the corresponding reference from your local repository.

Branch rename

if on the branch that want to rename:

git branch -m <new_branch_name>

else:

git branch -m <old_branch_name> <new_branch_name>

Discard changes in branch

git restore <branch-name>

How to merge two or multiple git repositories into one

Delete large files from git history

tcl relative

export utilization hierachically in implementation

report_utilization -hierarchical  -file /path-to-export

XSIM waveform export and import

export (And there's no conversion of .wdb to other format)

log_wave -help

import

open_wave_database <name>.wdb

Compress or uncompress

# compress
tar cvzf cmprssd.tar.gz cmprssd/

REF: tar-extract-linux

To unpack or extract a tar file, type:

tar -xvf file.tar

To save disk space and bandwidth over the network all files are saved using compression program such as gzip or bzip2. To extract / unpack a .tar.gz (gzip) file, enter (note -z option):

tar -xzvf file.tar.gz

To extract / unpack a .tar.bz2 (bzip2) file, enter (note -j option):

tar -xjvf file.tar.bz2

To extract .rar

sudo apt install unrar
unrar x file.rar

chmod(change to user permission)

sudo chmod -R 777 "target_dir_name"

vsim

vsim -wlf waveform.wlf
vsim -view waveform.wlf
posted @ 2024-12-19 13:02  Wunyje  阅读(6)  评论(0)    收藏  举报