Skip to content

Commit

Permalink
GUI Implementation of Testbench creation
Browse files Browse the repository at this point in the history
  • Loading branch information
m47812 committed Apr 15, 2022
1 parent b2ec234 commit 91ada04
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 11 deletions.
15 changes: 15 additions & 0 deletions HDL_Converter_App/HDL_Converter_Classes/Converter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using HDL_Converter_Classes.HDL_Structures;

namespace HDL_Converter_Classes
Expand Down Expand Up @@ -78,6 +79,20 @@ public string generateTestbenchVerify()
return this.module.generateTestbenchVerify();
}

public void storeTestbenchToFile(string path)
{
if (!inputProcessed) this.processInputHDL();
string topLevel = this.module.generateTestbenchTopLevel();
string verify = this.module.generateTestbenchVerify();
string fileEnding = this.settings.language == HDLLanguage.Verilog ? ".v" : ".vhd";
string toplevelPath = System.IO.Path.Combine(path, "tb_"+module.name+fileEnding);
string verifyPath = System.IO.Path.Combine(path, "verify_" + module.name + fileEnding);
toplevelPath = Path.GetFullPath(toplevelPath);
verifyPath = Path.GetFullPath(verifyPath);
File.WriteAllText(toplevelPath, topLevel);
File.WriteAllText(verifyPath, verify);
}

private void processInputHDL()
{
switch (settings.language)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public override string generateHeaderPort()
public override string generateHeaderParameters()
{
string port = "#(" + System.Environment.NewLine;
int elementCount = this.wires.Count;
int elementCount = this.parameters.Count;
foreach (VeriParameter wire in this.parameters)
{
elementCount--;
Expand Down
25 changes: 20 additions & 5 deletions HDL_Converter_App/HDL_Converter_GUI/GUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,31 @@ public void generateModuleInstantiationRequest()
}
}

public void generateTestbenchRequest(string path)
public void generateTestbenchRequest(int state, string path)
{
if (setupHDLInput())
{
//string testbenchTop = converter.generateTestbenchTopLevel();
string testbenchTop = converter.generateTestbenchVerify();
System.Windows.Clipboard.SetText(testbenchTop);
{
switch (state)
{
case 0://FILE
converter.storeTestbenchToFile(path);
informGUI(new GUIEvent("Testbench was stored to file", GUIEvent.Severity.Succsess), new EventArgs());
break;
case 1://Verify
string testbenchVerify = converter.generateTestbenchVerify();
System.Windows.Clipboard.SetText(testbenchVerify);
informGUI(new GUIEvent("Testbench verify was copied to clipboard", GUIEvent.Severity.Succsess), new EventArgs());
break;
case 2://TOP
string testbenchTop = converter.generateTestbenchTopLevel();
System.Windows.Clipboard.SetText(testbenchTop);
informGUI(new GUIEvent("Testbench top level was copied to clipboard", GUIEvent.Severity.Succsess), new EventArgs());
break;
}
}
}


private bool setupHDLInput()
{
string inputHDL = inputPanel.getHDLInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
d:DesignHeight="250" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="150"/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
Expand All @@ -16,11 +17,25 @@
<RowDefinition/>
</Grid.RowDefinitions>

<Label x:Name="laFolderLocation" Content="No Folder Selected" Grid.ColumnSpan="2" />
<Button x:Name="btFolderDialog" Grid.Row="1" Content="Target Folder Location" Margin="5,5,5,5" Click="click_folder_location"
<Label x:Name="laFolderLocation" Content="No Folder Selected" Grid.ColumnSpan="3" />
<Button x:Name="btFolderDialog" Grid.Column="1" Grid.Row="1" Content="Target Folder Location" Margin="5,5,5,5" Click="click_folder_location"
Background="#FFBACEDE" FontSize="16"/>
<Button x:Name="btGenerateTestbench" Content="Generate Testbench" Grid.Column="1" Grid.Row="1" Margin="5,5,5,5" Click="click_generate_testbench"
<Button x:Name="btGenerateTestbench" Content="Generate Testbench" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5" Click="click_generate_testbench"
Background="#FFBACEDE" FontSize="16" IsEnabled="False"/>
<Grid Grid.Row="1" Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>

<RadioButton x:Name="rbFile" Content="Both to File" Grid.Row="0" IsChecked="True"
Checked="rb_check_change"/>
<RadioButton x:Name="rbTopLevel" Content="Top Level to Clipboard" Grid.Row="1"
Checked="rb_check_change"/>
<RadioButton x:Name="rbVerify" Content="Verify to Clipboard" Grid.Row="2"
Checked="rb_check_change"/>
</Grid>

</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ namespace HDL_Converter_GUI.GUI_Components
/// </summary>
public partial class TestbenchControl : UserControl
{
private enum TestbenchRequestState
{
TOFILE = 0,
ClIP_VERIFY = 1,
CLIP_TOP = 2
}
private TestbenchRequestState state = TestbenchRequestState.TOFILE;
private GUIController controller;
private string target_path;
private string target_path = "";
public TestbenchControl()
{
InitializeComponent();
Expand Down Expand Up @@ -49,7 +56,45 @@ private void click_folder_location(object sender, EventArgs e)

private void click_generate_testbench(object sender, EventArgs e)
{
this.controller.generateTestbenchRequest(this.target_path);
controller.generateTestbenchRequest((int)this.state, this.target_path);
}


private void rb_check_change(object sender, RoutedEventArgs e)
{
RadioButton button = sender as RadioButton;
switch (button.Name)
{
case "rbFile":
buttonUpdate(true);
this.state = TestbenchRequestState.TOFILE;
break;
case "rbTopLevel":
buttonUpdate(false);
this.state = TestbenchRequestState.CLIP_TOP;
break;
case "rbVerify":
buttonUpdate(false);
this.state = TestbenchRequestState.ClIP_VERIFY;
break;
default:
throw new InvalidOperationException("Check of unknown raio button occured");
}
}

private void buttonUpdate(bool switechedToFileState)
{
if (switechedToFileState)
{
btFolderDialog.IsEnabled = true;
if (target_path != "") btGenerateTestbench.IsEnabled = true;
else btGenerateTestbench.IsEnabled = false;
}
else
{
btFolderDialog.IsEnabled = false;
btGenerateTestbench.IsEnabled = true;
}
}
}
}
30 changes: 30 additions & 0 deletions HDL_Converter_App/HDL_Converter_Test/GeneralTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,35 @@ public override string generateWireDeclaration()
{
throw new NotImplementedException();
}

public override string generateParameterDeclaration()
{
throw new NotImplementedException();
}

public override string generateModuleHeader()
{
throw new NotImplementedException();
}

public override string generateHeaderPort()
{
throw new NotImplementedException();
}

public override string generateHeaderParameters()
{
throw new NotImplementedException();
}

public override string generateTestbenchTopLevel()
{
throw new NotImplementedException();
}

public override string generateTestbenchVerify()
{
throw new NotImplementedException();
}
}
}

0 comments on commit 91ada04

Please sign in to comment.