forked from f4pga/f4pga-arch-defs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request f4pga#1648 from antmicro/ibex_sv2v
Add sv2v conversion to SymbiFlow build system
- Loading branch information
Showing
52 changed files
with
405 additions
and
8,411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This CMake include defines the following functions: | ||
# | ||
# * ADD_SV2V_TARGET - Converts SystemVerilog sources to Verilog using sv2v | ||
|
||
function(ADD_SV2V_TARGET) | ||
# ~~~ | ||
# ADD_SV2V_TARGET( | ||
# NAME <name> | ||
# SOURCES <source list> | ||
# FLAGS <flags> | ||
# | ||
# ADD_SV2V_TARGET is used for converting SystemVerilog SOURCES to Verilog. | ||
# FLAGS is a string with the flags that are passed to the sv2v during the conversion. | ||
# | ||
# Targets generated: | ||
# * <name>_sv2v - Output sv2v file in a Verilog format. | ||
# | ||
# Output files: | ||
# | ||
# * <name>_sv2v.v - Output Verilog file | ||
# * <name>_sv2v.v.log - Log file with errors and warnings during the sv2v conversion | ||
# | ||
# Outputs for this target will be located in the ${CMAKE_CURRENT_BINARY_DIR} | ||
# ~~~ | ||
|
||
set(oneValueArgs NAME) | ||
set(multiValueArgs SOURCES FLAGS) | ||
cmake_parse_arguments( | ||
ADD_SV2V_TARGET | ||
"${options}" | ||
"${oneValueArgs}" | ||
"${multiValueArgs}" | ||
"${ARGN}" | ||
) | ||
|
||
# Create a dependency list | ||
|
||
set(SOURCES_DEPS "") | ||
foreach(SRC ${ADD_SV2V_TARGET_SOURCES}) | ||
append_file_dependency(SOURCES_DEPS ${SRC}) | ||
endforeach() | ||
|
||
# sv2v conversion | ||
|
||
set(NAME ${ADD_SV2V_TARGET_NAME}) | ||
set(SOURCES ${ADD_SV2V_TARGET_SOURCES}) | ||
set(FLAGS ${ADD_SV2V_TARGET_FLAGS}) | ||
set(OUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_sv2v.v) | ||
|
||
add_custom_command( | ||
OUTPUT ${OUT_FILE} | ||
DEPENDS ${SOURCES_DEPS} | ||
COMMAND | ||
${CMAKE_COMMAND} -E env | ||
zachjs-sv2v ${FLAGS} ${SOURCES} > ${OUT_FILE} 2> ${OUT_FILE}.log | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
VERBATIM | ||
) | ||
add_custom_target(${NAME}_sv2v DEPENDS ${OUT_FILE}) | ||
|
||
add_file_target(FILE ${NAME}_sv2v.v GENERATED) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ pycapnp==1.0.0b1 | |
pyjson5 | ||
pytest | ||
python-constraint | ||
pyyaml | ||
scipy | ||
simplejson | ||
svgwrite | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import argparse | ||
|
||
from yaml import load, Loader | ||
|
||
SOURCE_FILE_TYPES = [ | ||
"verilogSource", | ||
"systemVerilogSource", | ||
] | ||
|
||
|
||
def get_sources(eda_yml): | ||
eda_yml_path = os.path.realpath(eda_yml) | ||
current_dir = os.path.dirname(eda_yml_path) | ||
|
||
with open(eda_yml_path) as f: | ||
data = load(f, Loader=Loader) | ||
files = data["files"] | ||
|
||
for src in files: | ||
if "file_type" not in src.keys(): | ||
continue | ||
|
||
if src["file_type"] in SOURCE_FILE_TYPES: | ||
file_path = os.path.realpath( | ||
os.path.join(current_dir, src["name"]) | ||
) | ||
basename = os.path.basename(file_path) | ||
print(basename) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="Get sources from an EDA YAML file produced by fusesoc" | ||
) | ||
parser.add_argument("eda_yml", help="An EDA YAML produced by fusesoc") | ||
|
||
args = parser.parse_args() | ||
get_sources(args.eda_yml) |
Oops, something went wrong.