Skip to content

Commit

Permalink
Merge branch 'release-1.0.0.a4'
Browse files Browse the repository at this point in the history
Merge release 1.0.0.a4
  • Loading branch information
benjmarshall committed Sep 14, 2018
2 parents 4597d71 + 01fe52b commit 2fe76d1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ Each Vivado HLS project requires a 'config.py' file in order to use hlsclt. This
|Device String |part_name |A device string as used by Vivado HLS (see examples)|Yes|
|Clock Period |clock_period |A value in nanoseconds input as a string, e.g. "10"|Yes|
|HDL Language |language |Either "vhdl" or "verilog" |No (Default is "vhdl")|
|Compiler |Compiler |Either "gcc" or "clang" |No (HLS defaults to gcc)|
|Compiler Options |cflags |Any flag for GCC (e.g. --std=c++11)|No|


Here is an example file taken from the [simple_adder](hlsclt/examples/simple_adder) example shipped with the tool (note that some of the optional items have been commented out in order to use the defaults):
Expand All @@ -139,6 +141,7 @@ Here is an example file taken from the [simple_adder](hlsclt/examples/simple_add
top_level_function_name = "simple_adder"
#src_dir_name = "src"
#tb_dir_name = "tb"
# cflags = ""
src_files = ["dut.h","dut.cpp"]
tb_files = ["testbench.cpp"]
part_name = "xc7z020clg484-1"
Expand Down
2 changes: 1 addition & 1 deletion hlsclt/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.0.a3'
__version__ = '1.0.0.a4'
17 changes: 11 additions & 6 deletions hlsclt/build_commands/build_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ def do_start_build_stuff(ctx):
file = click.open_file("run_hls.tcl","w")
file.write("open_project " + config["project_name"] + "\n")
file.write("set_top " + config["top_level_function_name"] + "\n")
if config.get("cflags","") != "":
cf = " -cflags \"%s\"" % config["cflags"]
else:
cf = ""
for src_file in config["src_files"]:
file.write("add_files " + config["src_dir_name"] + "/" + src_file + "\n")
file.write("add_files " + config["src_dir_name"] + "/" + src_file + cf + "\n")
for tb_file in config["tb_files"]:
file.write("add_files -tb " + config["tb_dir_name"] + "/" + tb_file + "\n")
if ctx.params['keep']:
Expand All @@ -39,7 +43,7 @@ def do_start_build_stuff(ctx):
def do_default_build(ctx):
config = ctx.obj.config
file = ctx.obj.file
file.write("csim_design -clean" + "\n")
file.write("csim_design -clean" + (" -compiler clang" if config.get("compiler","") == "clang" else "") + " \n")
file.write("csynth_design" + "\n")
file.write("cosim_design -O -rtl " + config["language"] + "\n")
file.write("export_design -format ip_catalog" + "\n")
Expand All @@ -48,7 +52,8 @@ def do_default_build(ctx):
# Function which defines the main actions of the 'csim' command.
def do_csim_stuff(ctx):
file = ctx.obj.file
file.write("csim_design -clean" + "\n")
config = ctx.obj.config
file.write("csim_design -clean" + (" -compiler clang" if config.get("compiler","") == "clang" else "") + "\n")

# Function which defines the main actions of the 'syn' command.
def do_syn_stuff(ctx):
Expand Down Expand Up @@ -134,11 +139,11 @@ def build_end_callback(ctx,sub_command_returns,keep,report):
ctx.obj.file.write("exit" + "\n")
ctx.obj.file.close()
# Call the Vivado HLS process
hls_processs = subprocess.run(["vivado_hls", "-f", "run_hls.tcl"])
returncode = subprocess.call(["vivado_hls -f run_hls.tcl"],shell=True)
# Check return status of the HLS process.
if hls_processs.returncode < 0:
if returncode < 0:
raise click.Abort()
elif hls_processs.returncode > 0:
elif returncode > 0:
click.echo("Warning: HLS Process returned an error, skipping report opening!")
raise click.Abort()
else:
Expand Down
2 changes: 2 additions & 0 deletions hlsclt/examples/simple_adder/hls_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
part_name = "xc7z020clg484-1"
clock_period = "10"
language = "vhdl"
#compiler = ""
#cflags = ""
26 changes: 19 additions & 7 deletions hlsclt/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import imp
from glob import glob
from .classes import *

### Function Definitions ###
# Function to generate the default config dicttionary
Expand All @@ -18,7 +19,9 @@ def generate_default_config():
"top_level_function_name" : "",
"src_dir_name" : "src",
"tb_dir_name" : "tb",
"cflags": "",
"src_files" : "",
"compiler": "",
"tb_files" : "",
"part_name" : "",
"clock_period" : "",
Expand All @@ -42,15 +45,24 @@ def parse_config_vars(config_loaded, config, errors):
config_loaded_set = set(config_loaded_dict)
config_set = set(config)
options_defined = config_loaded_set.intersection(config_set)
del_list = [];
for name in config:
if str(name) in options_defined:
# Catch optional config entries which don't need defaults
if str(name) == "compiler" or str(name) == "cflags":
if str(name) not in options_defined:
del_list.append(name)
else:
config[name] = config_loaded_dict[name]
elif str(name) in options_defined:
config[name] = config_loaded_dict[name]
try:
if not config[name]:
raise ConfigError("Error: " + name + " is not defined in config file. No default exists, please define a value in the config file.")
except ConfigError as err:
errors.append(err)
continue
try:
if not config[name]:
raise ConfigError("Error: " + name + " is not defined in config file. No default exists, please define a value in the config file.")
except ConfigError as err:
errors.append(err)
continue
for name in del_list:
del config[name]

# Function to find the highest solution number within a HLS project.
def find_solution_num(ctx):
Expand Down

0 comments on commit 2fe76d1

Please sign in to comment.