@@ -42,15 +42,23 @@ public partial class MainWindow : Window
4242 public List < string > ModuleNames { get ; set ; }
4343
4444 private string _edifFileName ;
45-
45+
46+ private ProjectConfiguration ? _projectConfiguration ;
4647
4748 public MainWindow ( )
4849 {
4950 InitializeComponent ( ) ;
5051 }
5152
52- private void CustomModuleMenuItem_OnClick ( object ? sender , RoutedEventArgs e )
53+ private async void CustomModuleMenuItem_OnClick ( object ? sender , RoutedEventArgs e )
5354 {
55+
56+ var customModuleWindow = new CustomModules ( )
57+ {
58+ BasePath = Configuration [ "isePath" ]
59+ } ;
60+ customModuleWindow . Show ( this ) ;
61+ return ;
5462 VerilogEdit verilogEdit = new VerilogEdit ( )
5563 {
5664 WorkDir = _selectedDirectory
@@ -256,7 +264,20 @@ private async void RunButton_OnClick(object? sender, RoutedEventArgs e)
256264 var box = MessageBoxManager
257265 . GetMessageBoxStandard ( "Result" , "Synthesize completed successfully" ,
258266 ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Success ) ;
259- await box . ShowWindowDialogAsync ( this ) ;
267+ string customPath = "custommodules" ;
268+ if ( Directory . Exists ( customPath ) )
269+ Directory . CreateDirectory ( Path . Combine ( _selectedDirectory , customPath ) ) ;
270+ _projectConfiguration = new ProjectConfiguration ( )
271+ {
272+ BaseProject = _selectedDirectory ,
273+ VerilogFiles = _selectedFiles . Select ( t => t . Name ) . ToList ( ) ,
274+ EdifFile = "" ,
275+ TopModule = VerilogTopInstanceCombo . SelectedItem . ToString ( ) ?? "" ,
276+ CustomModulePath = customPath
277+ } ;
278+ await _projectConfiguration . Save ( ) ;
279+
280+ await box . ShowAsPopupAsync ( this ) ;
260281 }
261282
262283 }
@@ -307,11 +328,18 @@ private async void GenerateEdifButton_OnClick(object? sender, RoutedEventArgs e)
307328
308329 if ( result == 0 )
309330 {
331+ _edifFileName = _selectedDirectory + "/" + topModule + "_edif.ndf" ;
332+ if ( _projectConfiguration is not null )
333+ {
334+ _projectConfiguration . EdifFile = topModule + "_edif.ndf" ;
335+ await _projectConfiguration . Save ( ) ;
336+ }
310337 var box = MessageBoxManager
311338 . GetMessageBoxStandard ( "Result" , "EDIF generation completed successfully" ,
312339 ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Success ) ;
340+
313341 await box . ShowWindowDialogAsync ( this ) ;
314- _edifFileName = _selectedDirectory + "/" + topModule + "_edif.ndf" ;
342+
315343 }
316344 }
317345
@@ -434,13 +462,60 @@ private async void GenerateNetlistMenuItem_OnClick(object? sender, RoutedEventAr
434462 netGenBox . Parse ( ) ;
435463 var verilogGenerator = new VerilogGenerator ( netGenBox . Nets ) ;
436464 var verilogFile = verilogGenerator . GenerateGateLevel ( ) ;
437- var selectedModule = _fileContents [ VerilogTopInstanceCombo ? . SelectedValue as string ] ;
438- var moduleParser = new VerilogModuleParser ( selectedModule ) ;
439- var module = moduleParser . ParseModule ( ) ;
465+ var selectedModule = string . Empty ;
466+ if ( _fileContents . ContainsKey ( VerilogTopInstanceCombo ? . SelectedItem as string ?? "TP" ) )
467+ selectedModule = _fileContents [ VerilogTopInstanceCombo ? . SelectedValue as string ?? "TP" ] ;
468+ else
469+ {
470+ var msgBox = MessageBoxManager . GetMessageBoxStandard ( "Warning" ,
471+ "You didn't select top module, select top module verilog file" , ButtonEnum . Ok ,
472+ MsBox . Avalonia . Enums . Icon . Warning ) ;
473+ await msgBox . ShowAsPopupAsync ( this ) ;
474+ var topLevel = TopLevel . GetTopLevel ( this ) ;
475+ var selectedFile = await topLevel . StorageProvider . OpenFilePickerAsync ( new FilePickerOpenOptions
476+ {
477+ Title = "Open Verilog Files" ,
478+ AllowMultiple = false ,
479+ FileTypeFilter = new FilePickerFileType [ ]
480+ {
481+ new FilePickerFileType ( "Verilog File | (*.v)" )
482+ {
483+ Patterns = new [ ] { "*.v" }
484+ }
485+ } ,
486+ } ) ;
487+ if ( selectedFile . Count != 1 )
488+ return ;
489+ selectedModule = await File . ReadAllTextAsync ( selectedFile . First ( ) . Path . AbsolutePath ) ;
490+ _fileContents [ "TP" ] = selectedModule ;
491+ }
492+ var module = VerilogModuleParser . ParseModule ( selectedModule ) ;
440493 var codeViewer = new CodeViewer ( module . ExportString ( verilogFile ) )
441494 {
442495 Title = "NetList"
443496 } ;
444497 codeViewer . Show ( this ) ;
445498 }
499+
500+ private async void OpenProjectMenuItem_OnClick ( object ? sender , RoutedEventArgs e )
501+ {
502+ var topLevel = TopLevel . GetTopLevel ( this ) ;
503+
504+ var selectedFiles = await topLevel . StorageProvider . OpenFilePickerAsync ( new FilePickerOpenOptions
505+ {
506+ Title = "Open Project File" ,
507+ AllowMultiple = false ,
508+ FileTypeFilter = new FilePickerFileType [ ]
509+ {
510+ new FilePickerFileType ( "Project Configuration File | (*.json)" )
511+ {
512+ Patterns = new [ ] { "*.json" }
513+ }
514+ }
515+ } ) ;
516+ if ( selectedFiles . Count == 1 )
517+ {
518+ _projectConfiguration = await ProjectConfiguration . ReadConfigAsync ( selectedFiles . First ( ) . Path . AbsolutePath ) ;
519+ }
520+ }
446521}
0 commit comments