added basic init, synth and simulation in gantry
This commit is contained in:
parent
92b6d6a12f
commit
ba9f8e4076
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*/wave
|
||||||
|
*/work
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import typer
|
|
||||||
|
|
||||||
app = typer.Typer()
|
|
||||||
|
|
||||||
@app.command()
|
|
||||||
def synth():
|
|
||||||
print("Synth!")
|
|
||||||
|
|
||||||
@app.command()
|
|
||||||
def build():
|
|
||||||
print("Build!")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app()
|
|
||||||
@ -26,7 +26,7 @@ def createBuildEnv():
|
|||||||
return -1
|
return -1
|
||||||
## Create build env
|
## Create build env
|
||||||
os.makedirs("work",exist_ok=True)
|
os.makedirs("work",exist_ok=True)
|
||||||
addAllVHDLFiles(init=False)
|
addAllVHDLFiles(init=True)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def addAllVHDLFiles(init=False):
|
def addAllVHDLFiles(init=False):
|
||||||
|
|||||||
45
scripts/gantry.py
Normal file
45
scripts/gantry.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import typer
|
||||||
|
import synth as syn
|
||||||
|
import build_env
|
||||||
|
from typing_extensions import Annotated
|
||||||
|
|
||||||
|
|
||||||
|
app = typer.Typer()
|
||||||
|
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def init():
|
||||||
|
print("Initializing GHDL project in current directory...")
|
||||||
|
build_env.createBuildEnv()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def complete_vhdl_ver():
|
||||||
|
return ["87", "93", "93c", "00", "02", "08"]
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def synth(
|
||||||
|
topdef: Annotated[str, typer.Argument(help="Top Definition entity to synthesize")] = "",
|
||||||
|
arch: Annotated[str, typer.Argument(help="Architecture to synthesize within the top definition provided")] = "",
|
||||||
|
library: Annotated[str, typer.Option("--library", "-l", help="Library to compile from")] = "work",
|
||||||
|
std: Annotated[str, typer.Option(help="Which VHDL standard to use. 87, 93, 93c, 00, 02 or 08", autocompletion=complete_vhdl_ver)] = "93c"
|
||||||
|
):
|
||||||
|
print(f"Synthesizing {topdef} with arch {arch} in library {library}. VHDL {std}")
|
||||||
|
syn.synthDesign(topdef, arch, library, std)
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def run(
|
||||||
|
topdef: Annotated[str, typer.Argument(help="Top Definition entity to synthesize")] = "",
|
||||||
|
arch: Annotated[str, typer.Argument(help="Architecture to synthesize within the top definition provided")] = "",
|
||||||
|
library: Annotated[str, typer.Option("--library", "-l", help="Library to compile from")] = "work",
|
||||||
|
std: Annotated[str, typer.Option(help="Which VHDL standard to use. 87, 93, 93c, 00, 02 or 08", autocompletion=complete_vhdl_ver)] = "93c"
|
||||||
|
):
|
||||||
|
print(f"Running (and synthesizing if needed) {topdef} with arch {arch} in library {library}. VHDL {std}")
|
||||||
|
syn.runDesign(topdef, arch, library, std)
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def build():
|
||||||
|
print("Build!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app()
|
||||||
31
scripts/synth.py
Normal file
31
scripts/synth.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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)
|
||||||
Loading…
x
Reference in New Issue
Block a user