@@ -221,7 +221,7 @@ def onecmd(
221
221
except Exception :
222
222
logger .debug (traceback .format_exc ())
223
223
self .exit_code = 1
224
- if not self .interactive :
224
+ if self .interactive :
225
225
return False
226
226
else :
227
227
return not self .force
@@ -757,17 +757,18 @@ def do_place_and_route(self, args):
757
757
"--log" ,
758
758
f"{ self .projectDir } /{ parent } /{ log_file } " ,
759
759
]
760
- try :
761
- sp .run (
762
- " " .join (runCmd ),
763
- stdout = sys .stdout ,
764
- stderr = sp .STDOUT ,
765
- check = True ,
766
- shell = True ,
760
+ result = sp .run (
761
+ " " .join (runCmd ),
762
+ stdout = sys .stdout ,
763
+ stderr = sp .STDOUT ,
764
+ check = True ,
765
+ shell = True ,
766
+ )
767
+ if result .returncode != 0 :
768
+ logger .opt (exception = CommandError ()).error (
769
+ "Nextpnr failed. Please check the logs for more details."
767
770
)
768
- except sp .CalledProcessError as e :
769
- logger .opt (exception = e ).error ("Placement and Routing failed." )
770
-
771
+ return
771
772
else :
772
773
logger .opt (exception = FileNotFoundError ()).error (
773
774
f'Cannot find file "{ json_file } " in path "./{ parent } /", which is generated by running Yosys with Nextpnr backend (e.g. synthesis).'
@@ -865,6 +866,7 @@ def do_run_simulation(self, args):
865
866
if bitstreamPath .suffix != ".bin" :
866
867
logger .error ("No bitstream file specified." )
867
868
return
869
+
868
870
if not bitstreamPath .exists ():
869
871
logger .opt (exception = FileNotFoundError ()).error (
870
872
f"Cannot find { bitstreamPath } file which is generated by running gen_bitStream_binary. Potentially the bitstream generation failed."
@@ -894,27 +896,28 @@ def do_run_simulation(self, args):
894
896
iverilog = check_if_application_exists (
895
897
os .getenv ("FAB_IVERILOG_PATH" , "iverilog" )
896
898
)
897
- try :
898
- runCmd = [
899
- f"{ iverilog } " ,
900
- "-D" ,
901
- f"{ defined_option } " ,
902
- "-s" ,
903
- f"{ topModuleTB } " ,
904
- "-o" ,
905
- f"{ buildDir } /{ vvpFile } " ,
906
- * file_list ,
907
- f"{ bitstreamPath .parent } /{ designFile } " ,
908
- f"{ testPath } /{ testBench } " ,
909
- ]
910
- if self .verbose or self .debug :
911
- logger .info (f"Running simulation with { args .format } format" )
912
- logger .info (f"Running command: { ' ' .join (runCmd )} " )
913
- sp .run (runCmd , check = True )
899
+ runCmd = [
900
+ f"{ iverilog } " ,
901
+ "-D" ,
902
+ f"{ defined_option } " ,
903
+ "-s" ,
904
+ f"{ topModuleTB } " ,
905
+ "-o" ,
906
+ f"{ buildDir } /{ vvpFile } " ,
907
+ * file_list ,
908
+ f"{ bitstreamPath .parent } /{ designFile } " ,
909
+ f"{ testPath } /{ testBench } " ,
910
+ ]
911
+ if self .verbose or self .debug :
912
+ logger .info (f"Running simulation with { args .format } format" )
913
+ logger .info (f"Running command: { ' ' .join (runCmd )} " )
914
914
915
- except sp .CalledProcessError as e :
916
- remove_dir (buildDir )
917
- logger .opt (exception = e ).error ("Simulation failed" )
915
+ result = sp .run (runCmd , check = True )
916
+ if result .returncode != 0 :
917
+ logger .opt (exception = CommandError ()).error (
918
+ "Simulation failed. Please check the logs for more details."
919
+ )
920
+ return
918
921
919
922
# bitstream hex file is used for simulation so it'll be created in the test directory
920
923
bitstreamHexPath = (buildDir .parent / bitstreamPath .stem ).with_suffix (".hex" )
@@ -931,16 +934,18 @@ def do_run_simulation(self, args):
931
934
if waveform_format == "fst" :
932
935
vvpArgs .append ("-fst" )
933
936
934
- try :
935
- runCmd = [f"{ vvp } " , f"{ buildDir } /{ vvpFile } " ]
936
- runCmd .extend (vvpArgs )
937
- if self .verbose or self .debug :
938
- logger .info (f"Running command: { ' ' .join (runCmd )} " )
939
- sp .run (runCmd , check = True )
940
- remove_dir (buildDir )
941
- except sp .CalledProcessError as e :
942
- remove_dir (buildDir )
943
- logger .opt (exception = e ).error ("Simulation failed" )
937
+ runCmd = [f"{ vvp } " , f"{ buildDir } /{ vvpFile } " ]
938
+ runCmd .extend (vvpArgs )
939
+ if self .verbose or self .debug :
940
+ logger .info (f"Running command: { ' ' .join (runCmd )} " )
941
+
942
+ result = sp .run (runCmd , check = True )
943
+ remove_dir (buildDir )
944
+ if result .returncode != 0 :
945
+ logger .opt (exception = CommandError ()).error (
946
+ "Simulation failed. Please check the logs for more details."
947
+ )
948
+ return
944
949
945
950
logger .info ("Simulation finished" )
946
951
@@ -976,12 +981,14 @@ def do_run_FABulous_bitstream(self, args):
976
981
do_synth_args += f" -extra-plib { primsLib } "
977
982
else :
978
983
logger .info ("No external primsLib found." )
984
+
979
985
self .onecmd_plus_hooks (f"synthesis { do_synth_args } " )
980
986
if self .exit_code != 0 :
981
987
logger .opt (exception = CommandError ()).error (
982
988
"Synthesis failed. Please check the logs for more details."
983
989
)
984
990
return
991
+
985
992
self .onecmd_plus_hooks (f"place_and_route { json_file_path } " )
986
993
if self .exit_code != 0 :
987
994
logger .opt (exception = CommandError ()).error (
@@ -1026,6 +1033,11 @@ def do_run_script(self, args):
1026
1033
with open (args .file , "r" ) as f :
1027
1034
for i in f .readlines ():
1028
1035
self .onecmd_plus_hooks (i .strip ())
1036
+ if self .exit_code != 0 :
1037
+ logger .opt (exception = CommandError ()).error (
1038
+ f"Script execution failed at line: { i .strip ()} "
1039
+ )
1040
+ return
1029
1041
1030
1042
logger .info ("Script executed" )
1031
1043
0 commit comments