32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import os
|
|
import subprocess
|
|
import build_env
|
|
|
|
def synthDesign(topDef: str, arch: str, lib: str, std: str):
|
|
## Add all source files present in pwd
|
|
if build_env.addAllVHDLFiles() == -1:
|
|
print("build env not working")
|
|
return -1
|
|
command = [
|
|
"ghdl", "-m", f"--workdir={lib}", f"--work={lib}", f"--std={std}",
|
|
"-o", f"{lib}/{topDef}-{arch}", f"{lib}.{topDef}", f"{arch}"]
|
|
subprocess.run(command)
|
|
|
|
def runDesign(topDef: str, arch: str, lib: str, std: str):
|
|
## synth first, then run
|
|
if synthDesign(topDef, arch, lib, std) == -1:
|
|
print("synth failed")
|
|
return -1
|
|
os.makedirs("wave",exist_ok=True)
|
|
libPath = os.path.join(os.getcwd(), lib)
|
|
wavePath = os.path.join(os.getcwd(), "wave")
|
|
command = [ ## may add -v for verbose
|
|
"ghdl", "-r", f"{topDef}", f"{arch}",
|
|
f"--wave={os.path.join(libPath, topDef)}-{arch}.ghw" ##, "--read-wave-opt=<See"
|
|
]
|
|
subprocess.run(command, cwd=libPath)
|
|
command = [
|
|
"gtkwave", f"{topDef}-{arch}.ghw", "--rcvar",
|
|
"do_initial_zoom_fit yes"]
|
|
subprocess.run(command, cwd=wavePath)
|