@@ -82,7 +82,7 @@ def _run_yosys(device, sources, vincpaths, build_name):
82
82
83
83
84
84
def _run_ise (build_name , ise_path , source , mode , ngdbuild_opt ,
85
- bitgen_opt , ise_commands , map_opt , par_opt , ver = None ):
85
+ toolchain , platform , ver = None ):
86
86
if sys .platform == "win32" or sys .platform == "cygwin" :
87
87
source_cmd = "call "
88
88
script_ext = ".bat"
@@ -108,14 +108,24 @@ def _run_ise(build_name, ise_path, source, mode, ngdbuild_opt,
108
108
109
109
build_script_contents += """
110
110
ngdbuild {ngdbuild_opt} -uc {build_name}.ucf {build_name}.{ext} {build_name}.ngd{fail_stmt}
111
+ """
112
+ if mode == "cpld" :
113
+ build_script_contents += """
114
+ cpldfit -ofmt verilog {par_opt} -p {device} {build_name}.ngd{fail_stmt}
115
+ taengine -f {build_name}.vm6 -detail -iopath -l {build_name}.tim{fail_stmt}
116
+ hprep6 -s IEEE1532 -i {build_name}.vm6{fail_stmt}
117
+ """
118
+ else :
119
+ build_script_contents += """
111
120
map {map_opt} -o {build_name}_map.ncd {build_name}.ngd {build_name}.pcf{fail_stmt}
112
121
par {par_opt} {build_name}_map.ncd {build_name}.ncd {build_name}.pcf{fail_stmt}
113
122
bitgen {bitgen_opt} {build_name}.ncd {build_name}.bit{fail_stmt}
114
123
"""
115
124
build_script_contents = build_script_contents .format (build_name = build_name ,
116
- ngdbuild_opt = ngdbuild_opt , bitgen_opt = bitgen_opt , ext = ext ,
117
- par_opt = par_opt , map_opt = map_opt , fail_stmt = fail_stmt )
118
- build_script_contents += ise_commands .format (build_name = build_name )
125
+ ngdbuild_opt = ngdbuild_opt , bitgen_opt = toolchain .bitgen_opt , ext = ext ,
126
+ par_opt = toolchain .par_opt , map_opt = toolchain .map_opt ,
127
+ device = platform .device , fail_stmt = fail_stmt )
128
+ build_script_contents += toolchain .ise_commands .format (build_name = build_name )
119
129
build_script_file = "build_" + build_name + script_ext
120
130
tools .write_to_file (build_script_file , build_script_contents , force_unix = False )
121
131
command = shell + [build_script_file ]
@@ -168,16 +178,16 @@ def build(self, platform, fragment, build_dir="build", build_name="top",
168
178
cwd = os .getcwd ()
169
179
os .chdir (build_dir )
170
180
try :
171
- if mode == "xst" or mode == "yosys" :
181
+ if mode in ( "xst" , "yosys" , "cpld" ) :
172
182
v_output = platform .get_verilog (fragment )
173
183
vns = v_output .ns
174
184
named_sc , named_pc = platform .resolve_signals (vns )
175
185
v_file = build_name + ".v"
176
186
v_output .write (v_file )
177
187
sources = platform .sources | {(v_file , "verilog" , "work" )}
178
- if mode == "xst" :
188
+ if mode in ( "xst" , "cpld" ) :
179
189
_build_xst_files (platform .device , sources , platform .verilog_include_paths , build_name , self .xst_opt )
180
- isemode = "xst"
190
+ isemode = mode
181
191
else :
182
192
_run_yosys (platform .device , sources , platform .verilog_include_paths , build_name )
183
193
isemode = "edif"
@@ -198,8 +208,7 @@ def build(self, platform, fragment, build_dir="build", build_name="top",
198
208
tools .write_to_file (build_name + ".ucf" , _build_ucf (named_sc , named_pc ))
199
209
if run :
200
210
_run_ise (build_name , toolchain_path , source , isemode ,
201
- ngdbuild_opt , self .bitgen_opt , self .ise_commands ,
202
- self .map_opt , self .par_opt )
211
+ ngdbuild_opt , self , platform )
203
212
finally :
204
213
os .chdir (cwd )
205
214
0 commit comments