Skip to content

Instantly share code, notes, and snippets.

@olofk
Created August 26, 2019 07:52
Show Gist options
  • Select an option

  • Save olofk/bd1b178a2ddf279cd84c31e5a14ebe45 to your computer and use it in GitHub Desktop.

Select an option

Save olofk/bd1b178a2ddf279cd84c31e5a14ebe45 to your computer and use it in GitHub Desktop.
from edalize import get_edatool
file_list = ['a.v', 'b.vhd', 'c.sdc', 'd.tcl']
name = 'myproject'
toplevel = 'mytoplevel'
tool = 'vivado'
#Where to put the output stuff
work_root = 'build'
#Set an example generic of integer type to value 614
#and another one to the string value hello
generics = [('mygeneric' , 'int', 614),
('myothergeneric', 'str', 'hello')]
###########
edam = {
'name' : name,
}
files = []
for f in file_list:
if f.endswith('.v'):
file_type = 'verilogSource'
elif f.endswith('.vhd'):
file_type = 'vhdlSource'
elif f.endswith('.sdc'):
file_type = 'SDC'
elif f.endswith('tcl'):
file_type = 'tclSource'
else:
file_type = 'user' #Or maybe file_type = ''
_file = {'name' : f,
'file_type' : file_type}
#if you have any verilog files that are only used as `include
#then set _file['is_include_file'] = True
#If you have VHDL files that needs to be compiled to a library set
#_file['logical_name'] = 'nameOfVhdlLibrary'
files.append(_file)
edam['files'] = files
#Add any top-level generics (assuming it's a vhdl design)
parameters = {}
for generic in generics:
parameters[generic[0]] = {'datatype' : generic[1],
'default' : generic[2],
'paramtype' : 'generic'}
edam['parameters'] = parameters
#Set tool-specific options
vivado_options = {'part' : 'xc7a35tcsg324-1'}
#Possible to set options for different tools by using different keys
tool_options = {'vivado' : vivado_options}
edam['tool_options'] = tool_options
#Get the vivado backend
backend = get_edatool(tool)(edam=edam, work_root=work_root)
#Create Vivado project files. After this is run, you can open the vivado
#project in the GUI if you like
backend.configure([])
#...or just build it in batch mode
backend.build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment