From 2bab2bd71f3e4d153ba02e2829db4b56c72c422b Mon Sep 17 00:00:00 2001 From: smtalibov1 <smtalibov@edu.hse.ru> Date: Tue, 25 Mar 2025 22:18:40 +0300 Subject: [PATCH] Gradually adding GUI functionality --- Broker/Broker/Properties/launchSettings.json | 2 +- GUI/GUI/FormMain.Designer.cs | 230 +++++++++--------- GUI/GUI/FormMain.cs | 190 ++++++++++++++- .../Graph_verilog_generator/Program.cs | 5 +- Shared/Graph.cs | 14 +- Shared/ProjectGenerator.cs | 110 ++++----- 6 files changed, 360 insertions(+), 191 deletions(-) diff --git a/Broker/Broker/Properties/launchSettings.json b/Broker/Broker/Properties/launchSettings.json index 2a3fd6d..cc3414f 100644 --- a/Broker/Broker/Properties/launchSettings.json +++ b/Broker/Broker/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Broker": { "commandName": "Project", - "commandLineArgs": "--project -l ? -n ? -c" + "commandLineArgs": "--project -l D:/kal -n kal -c --graph m 3 3 --queue_type pointer --queue_position front --arbiter_type round_robin --algorithm xy --info_width 8 --queue_length 16 -v" } } } \ No newline at end of file diff --git a/GUI/GUI/FormMain.Designer.cs b/GUI/GUI/FormMain.Designer.cs index c24d9bc..bd42eb8 100644 --- a/GUI/GUI/FormMain.Designer.cs +++ b/GUI/GUI/FormMain.Designer.cs @@ -47,12 +47,12 @@ label4 = new Label(); label3 = new Label(); label1 = new Label(); - numericUpDown2 = new NumericUpDown(); - numericUpDown1 = new NumericUpDown(); - comboBox4 = new ComboBox(); - comboBox3 = new ComboBox(); - comboBox2 = new ComboBox(); - comboBox1 = new ComboBox(); + numericUpDownQLength = new NumericUpDown(); + numericUpDownWidth = new NumericUpDown(); + comboBoxAlg = new ComboBox(); + comboBoxArbType = new ComboBox(); + comboBoxQPos = new ComboBox(); + comboBoxQType = new ComboBox(); textBoxTopology = new TextBox(); label2 = new Label(); tabControl1 = new TabControl(); @@ -72,13 +72,13 @@ columnHeader5 = new ColumnHeader(); columnHeader6 = new ColumnHeader(); button2 = new Button(); - button3 = new Button(); - button4 = new Button(); + buttonSerializeGraph = new Button(); + buttonCreateVerilog = new Button(); button5 = new Button(); button6 = new Button(); button7 = new Button(); buttonCreateProj = new Button(); - button9 = new Button(); + buttonProjSettings = new Button(); label8 = new Label(); label9 = new Label(); buttonAppSettings = new Button(); @@ -97,8 +97,8 @@ ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); tabControl2.SuspendLayout(); output.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQLength).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWidth).BeginInit(); tabControl1.SuspendLayout(); dijkstra.SuspendLayout(); GA.SuspendLayout(); @@ -151,12 +151,12 @@ splitContainer1.Panel2.Controls.Add(label4); splitContainer1.Panel2.Controls.Add(label3); splitContainer1.Panel2.Controls.Add(label1); - splitContainer1.Panel2.Controls.Add(numericUpDown2); - splitContainer1.Panel2.Controls.Add(numericUpDown1); - splitContainer1.Panel2.Controls.Add(comboBox4); - splitContainer1.Panel2.Controls.Add(comboBox3); - splitContainer1.Panel2.Controls.Add(comboBox2); - splitContainer1.Panel2.Controls.Add(comboBox1); + splitContainer1.Panel2.Controls.Add(numericUpDownQLength); + splitContainer1.Panel2.Controls.Add(numericUpDownWidth); + splitContainer1.Panel2.Controls.Add(comboBoxAlg); + splitContainer1.Panel2.Controls.Add(comboBoxArbType); + splitContainer1.Panel2.Controls.Add(comboBoxQPos); + splitContainer1.Panel2.Controls.Add(comboBoxQType); splitContainer1.Panel2.Controls.Add(textBoxTopology); splitContainer1.Panel2.Controls.Add(label2); splitContainer1.Panel2.Controls.Add(tabControl1); @@ -330,63 +330,67 @@ label1.TabIndex = 8; label1.Text = "Нагрузочная ширина:"; // - // numericUpDown2 - // - numericUpDown2.Anchor = AnchorStyles.Top | AnchorStyles.Right; - numericUpDown2.Location = new Point(227, 119); - numericUpDown2.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); - numericUpDown2.Name = "numericUpDown2"; - numericUpDown2.Size = new Size(53, 23); - numericUpDown2.TabIndex = 7; - // - // numericUpDown1 - // - numericUpDown1.Anchor = AnchorStyles.Top | AnchorStyles.Right; - numericUpDown1.Location = new Point(227, 32); - numericUpDown1.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); - numericUpDown1.Name = "numericUpDown1"; - numericUpDown1.Size = new Size(53, 23); - numericUpDown1.TabIndex = 6; - // - // comboBox4 - // - comboBox4.Anchor = AnchorStyles.Top | AnchorStyles.Right; - comboBox4.FormattingEnabled = true; - comboBox4.Items.AddRange(new object[] { "GA", "XY" }); - comboBox4.Location = new Point(150, 177); - comboBox4.Name = "comboBox4"; - comboBox4.Size = new Size(130, 23); - comboBox4.TabIndex = 5; - // - // comboBox3 - // - comboBox3.Anchor = AnchorStyles.Top | AnchorStyles.Right; - comboBox3.FormattingEnabled = true; - comboBox3.Items.AddRange(new object[] { "Round robin" }); - comboBox3.Location = new Point(150, 148); - comboBox3.Name = "comboBox3"; - comboBox3.Size = new Size(130, 23); - comboBox3.TabIndex = 4; - // - // comboBox2 - // - comboBox2.Anchor = AnchorStyles.Top | AnchorStyles.Right; - comboBox2.FormattingEnabled = true; - comboBox2.Items.AddRange(new object[] { "Front", "Rear" }); - comboBox2.Location = new Point(150, 90); - comboBox2.Name = "comboBox2"; - comboBox2.Size = new Size(130, 23); - comboBox2.TabIndex = 3; - // - // comboBox1 - // - comboBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right; - comboBox1.FormattingEnabled = true; - comboBox1.Items.AddRange(new object[] { "Index", "Pointer", "Line" }); - comboBox1.Location = new Point(150, 61); - comboBox1.Name = "comboBox1"; - comboBox1.Size = new Size(130, 23); - comboBox1.TabIndex = 2; + // numericUpDownQLength + // + numericUpDownQLength.Anchor = AnchorStyles.Top | AnchorStyles.Right; + numericUpDownQLength.Location = new Point(227, 119); + numericUpDownQLength.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownQLength.Minimum = new decimal(new int[] { 2, 0, 0, 0 }); + numericUpDownQLength.Name = "numericUpDownQLength"; + numericUpDownQLength.Size = new Size(53, 23); + numericUpDownQLength.TabIndex = 7; + numericUpDownQLength.Value = new decimal(new int[] { 2, 0, 0, 0 }); + // + // numericUpDownWidth + // + numericUpDownWidth.Anchor = AnchorStyles.Top | AnchorStyles.Right; + numericUpDownWidth.Location = new Point(227, 32); + numericUpDownWidth.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownWidth.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownWidth.Name = "numericUpDownWidth"; + numericUpDownWidth.Size = new Size(53, 23); + numericUpDownWidth.TabIndex = 6; + numericUpDownWidth.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // comboBoxAlg + // + comboBoxAlg.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBoxAlg.FormattingEnabled = true; + comboBoxAlg.Items.AddRange(new object[] { "GA", "XY" }); + comboBoxAlg.Location = new Point(150, 177); + comboBoxAlg.Name = "comboBoxAlg"; + comboBoxAlg.Size = new Size(130, 23); + comboBoxAlg.TabIndex = 5; + // + // comboBoxArbType + // + comboBoxArbType.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBoxArbType.FormattingEnabled = true; + comboBoxArbType.Items.AddRange(new object[] { "Round robin" }); + comboBoxArbType.Location = new Point(150, 148); + comboBoxArbType.Name = "comboBoxArbType"; + comboBoxArbType.Size = new Size(130, 23); + comboBoxArbType.TabIndex = 4; + // + // comboBoxQPos + // + comboBoxQPos.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBoxQPos.FormattingEnabled = true; + comboBoxQPos.Items.AddRange(new object[] { "Front", "Rear" }); + comboBoxQPos.Location = new Point(150, 90); + comboBoxQPos.Name = "comboBoxQPos"; + comboBoxQPos.Size = new Size(130, 23); + comboBoxQPos.TabIndex = 3; + // + // comboBoxQType + // + comboBoxQType.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBoxQType.FormattingEnabled = true; + comboBoxQType.Items.AddRange(new object[] { "Index", "Pointer", "Line" }); + comboBoxQType.Location = new Point(150, 61); + comboBoxQType.Name = "comboBoxQType"; + comboBoxQType.Size = new Size(130, 23); + comboBoxQType.TabIndex = 2; // // textBoxTopology // @@ -550,6 +554,7 @@ // // button2 // + button2.Enabled = false; button2.Image = GUI.Properties.Resources.kal; button2.Location = new Point(208, 27); button2.Name = "button2"; @@ -557,26 +562,31 @@ button2.TabIndex = 1; button2.UseVisualStyleBackColor = true; // - // button3 + // buttonSerializeGraph // - button3.Image = GUI.Properties.Resources.kal2; - button3.Location = new Point(244, 27); - button3.Name = "button3"; - button3.Size = new Size(30, 30); - button3.TabIndex = 2; - button3.UseVisualStyleBackColor = true; + buttonSerializeGraph.Enabled = false; + buttonSerializeGraph.Image = GUI.Properties.Resources.kal2; + buttonSerializeGraph.Location = new Point(244, 27); + buttonSerializeGraph.Name = "buttonSerializeGraph"; + buttonSerializeGraph.Size = new Size(30, 30); + buttonSerializeGraph.TabIndex = 2; + buttonSerializeGraph.UseVisualStyleBackColor = true; + buttonSerializeGraph.Click += buttonSerializeGraph_Click; // - // button4 + // buttonCreateVerilog // - button4.Image = GUI.Properties.Resources.kal21; - button4.Location = new Point(280, 27); - button4.Name = "button4"; - button4.Size = new Size(30, 30); - button4.TabIndex = 3; - button4.UseVisualStyleBackColor = true; + buttonCreateVerilog.Enabled = false; + buttonCreateVerilog.Image = GUI.Properties.Resources.kal21; + buttonCreateVerilog.Location = new Point(280, 27); + buttonCreateVerilog.Name = "buttonCreateVerilog"; + buttonCreateVerilog.Size = new Size(30, 30); + buttonCreateVerilog.TabIndex = 3; + buttonCreateVerilog.UseVisualStyleBackColor = true; + buttonCreateVerilog.Click += buttonCreateVerilog_Click; // // button5 // + button5.Enabled = false; button5.Image = GUI.Properties.Resources.kal31; button5.Location = new Point(316, 27); button5.Name = "button5"; @@ -586,6 +596,7 @@ // // button6 // + button6.Enabled = false; button6.Image = GUI.Properties.Resources.kal4; button6.Location = new Point(352, 27); button6.Name = "button6"; @@ -612,14 +623,15 @@ buttonCreateProj.UseVisualStyleBackColor = true; buttonCreateProj.Click += buttonCreateProj_Click; // - // button9 + // buttonProjSettings // - button9.Image = GUI.Properties.Resources.kal7; - button9.Location = new Point(84, 27); - button9.Name = "button9"; - button9.Size = new Size(30, 30); - button9.TabIndex = 8; - button9.UseVisualStyleBackColor = true; + buttonProjSettings.Enabled = false; + buttonProjSettings.Image = GUI.Properties.Resources.kal7; + buttonProjSettings.Location = new Point(84, 27); + buttonProjSettings.Name = "buttonProjSettings"; + buttonProjSettings.Size = new Size(30, 30); + buttonProjSettings.TabIndex = 8; + buttonProjSettings.UseVisualStyleBackColor = true; // // label8 // @@ -689,13 +701,13 @@ Controls.Add(buttonAppSettings); Controls.Add(label9); Controls.Add(label8); - Controls.Add(button9); + Controls.Add(buttonProjSettings); Controls.Add(buttonCreateProj); Controls.Add(button7); Controls.Add(button6); Controls.Add(button5); - Controls.Add(button4); - Controls.Add(button3); + Controls.Add(buttonCreateVerilog); + Controls.Add(buttonSerializeGraph); Controls.Add(button2); Controls.Add(splitContainer1); Controls.Add(menuStrip1); @@ -718,8 +730,8 @@ ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); tabControl2.ResumeLayout(false); output.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownQLength).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWidth).EndInit(); tabControl1.ResumeLayout(false); dijkstra.ResumeLayout(false); GA.ResumeLayout(false); @@ -739,13 +751,13 @@ private TabPage dijkstra; private TabPage GA; private Label label2; - private ComboBox comboBox1; + private ComboBox comboBoxQType; private TextBox textBoxTopology; - private ComboBox comboBox4; - private ComboBox comboBox3; - private ComboBox comboBox2; - private NumericUpDown numericUpDown1; - private NumericUpDown numericUpDown2; + private ComboBox comboBoxAlg; + private ComboBox comboBoxArbType; + private ComboBox comboBoxQPos; + private NumericUpDown numericUpDownWidth; + private NumericUpDown numericUpDownQLength; private Label label7; private Label label6; private Label label5; @@ -763,13 +775,13 @@ private TabPage XY; private RichTextBox richTextBoxOutput; private Button button2; - private Button button3; - private Button button4; + private Button buttonSerializeGraph; + private Button buttonCreateVerilog; private Button button5; private Button button6; private Button button7; private Button buttonCreateProj; - private Button button9; + private Button buttonProjSettings; private Label label8; private Label label9; private Button buttonAppSettings; diff --git a/GUI/GUI/FormMain.cs b/GUI/GUI/FormMain.cs index 13daa0e..944e437 100644 --- a/GUI/GUI/FormMain.cs +++ b/GUI/GUI/FormMain.cs @@ -15,6 +15,7 @@ namespace HDLNoCGen public partial class FormMain : Form { string broker_location = "../../../../../Broker/Broker/bin/Debug/net8.0"; + Dictionary<string, string> graph_args = new Dictionary<string, string>(); private static Task CreateGraphFromBufferThread, RoutingThread, DrawGraphThread, DrawRouteThread; Task[] ThreadWatcher = { CreateGraphFromBufferThread, RoutingThread, DrawGraphThread, DrawRouteThread }; @@ -319,11 +320,22 @@ namespace HDLNoCGen GC.Collect(); } - private void CreateGraphFromBufferThreadRoutine(string buffer, CancellationToken token) + private void CreateGraphFromBufferThreadRoutine(string buffer, router_options parameters, CancellationToken token) { try { graph = graph.CreateGraphFromBuffer(buffer, token) as Graph; + switch (graph.graphId) + { + case GraphType.Circulant: + parameters.packet_width = 1 + graph.get_bits(graph.node_count) + parameters.info_width; + break; + case GraphType.Mesh: + case GraphType.Torus: + parameters.packet_width = 1 + 2 * graph.get_bits(graph.generators[1]) + parameters.info_width; + break; + } + graph.parameters = parameters; pictureGraph = pictureGraph.CreatePictureGraphFromBuffer(buffer, token); Draw_graph(); } @@ -333,6 +345,8 @@ namespace HDLNoCGen } finally { + buttonSerializeGraph.Invoke(new Action(() => buttonSerializeGraph.Enabled = projectOpened && graph.is_created)); + buttonCreateVerilog.Invoke(new Action(() => buttonCreateVerilog.Enabled = projectOpened && graph.is_created)); GC.Collect(); } } @@ -350,7 +364,74 @@ namespace HDLNoCGen tabControl1.TabPages.Remove(GA); tabControl1.TabPages.Remove(XY); + string buffer = textBoxTopology.Text.Trim(); + graph_args["--graph"] = buffer; + + router_options parameters = new router_options(); + + parameters.queue_length = Decimal.ToInt32(numericUpDownQLength.Value); + graph_args["--queue_length"] = Convert.ToString(numericUpDownQLength.Value); + + parameters.info_width = Decimal.ToInt32(numericUpDownWidth.Value); + graph_args["--info_width"] = Convert.ToString(numericUpDownWidth.Value); + + switch (comboBoxQPos.SelectedItem) + { + case "Front": + parameters.queue_position = RouterOptions.Queue_position.Front; + graph_args["--queue_position"] = "front"; + break; + case "Rear": + parameters.queue_position = RouterOptions.Queue_position.Rear; + graph_args["--queue_position"] = "rear"; + break; + default: + parameters.queue_position = RouterOptions.Queue_position.None; + break; + }; + switch (comboBoxQType.SelectedItem) + { + case "Index": + parameters.queue_type = RouterOptions.Queue_types.Index; + graph_args["--queue_type"] = "index"; + break; + case "Line": + parameters.queue_type = RouterOptions.Queue_types.Line; + graph_args["--queue_type"] = "line"; + break; + case "Pointer": + parameters.queue_type = RouterOptions.Queue_types.Pointer; + graph_args["--queue_type"] = "pointer"; + break; + default: + parameters.queue_type = RouterOptions.Queue_types.None; + break; + }; + switch (comboBoxArbType.SelectedItem) + { + case "Round robin": + parameters.arbiter_type = RouterOptions.Arbiter_types.Round_Robin; + graph_args["--arbiter_type"] = "round_robin"; + break; + default: + parameters.arbiter_type = RouterOptions.Arbiter_types.None; + break; + }; + switch (comboBoxAlg.SelectedItem) + { + case "XY": + parameters.algorithm = RouterOptions.Algorithm.XY; + graph_args["--algorithm"] = "xy"; + break; + case "GA": + parameters.algorithm = RouterOptions.Algorithm.GA; + graph_args["--algorithm"] = "ga"; + break; + default: + parameters.algorithm = RouterOptions.Algorithm.None; + break; + }; CreateGraphFromBufferString = new string(buffer.ToCharArray()); CreateGraphFromBufferCTS.Cancel(); @@ -360,7 +441,7 @@ namespace HDLNoCGen RoutingCTS.Dispose(); RoutingCTS = new CancellationTokenSource(); CancellationToken token = CreateGraphFromBufferCTS.Token; - Task.Run(() => CreateGraphFromBufferThreadRoutine(buffer, token), token); + Task.Run(() => CreateGraphFromBufferThreadRoutine(buffer, parameters, token), token); } catch (System.Exception) { @@ -509,12 +590,16 @@ namespace HDLNoCGen private void buttonCreateProj_Click(object sender, EventArgs e) { FormCreateProj formCreateProj = new FormCreateProj(); - + if (formCreateProj.ShowDialog() == DialogResult.OK) { projectLocation = formCreateProj.projLoc; projectName = formCreateProj.projName; } + else + { + return; + } Process broker = new Process(); @@ -529,7 +614,8 @@ namespace HDLNoCGen { if (!String.IsNullOrEmpty(e.Data)) { - richTextBoxOutput.Invoke(new Action(() => { + richTextBoxOutput.Invoke(new Action(() => + { richTextBoxOutput.AppendText($"{e.Data}\n"); richTextBoxOutput.ScrollToCaret(); })); @@ -543,20 +629,112 @@ namespace HDLNoCGen { if (broker.ExitCode == 0) { - richTextBoxOutput.Invoke(new Action(() => { + richTextBoxOutput.Invoke(new Action(() => + { richTextBoxOutput.AppendText($"Creation of project {projectName} at {projectLocation} was successful\n\n"); richTextBoxOutput.ScrollToCaret(); })); + projectOpened = true; + buttonProjSettings.Invoke(new Action(() => buttonProjSettings.Enabled = true)); + + buttonSerializeGraph.Invoke(new Action(() => buttonSerializeGraph.Enabled = projectOpened && graph.is_created)); + buttonCreateVerilog.Invoke(new Action(() => buttonCreateVerilog.Enabled = projectOpened && graph.is_created)); } else { - richTextBoxOutput.Invoke(new Action(() => { + richTextBoxOutput.Invoke(new Action(() => + { richTextBoxOutput.AppendText($"Failed to create project {projectName} at {projectLocation}\n\n"); richTextBoxOutput.ScrollToCaret(); })); + projectLocation = ""; + projectName = ""; + projectOpened = false; + buttonProjSettings.Invoke(new Action(() => buttonProjSettings.Enabled = false)); + + buttonSerializeGraph.Invoke(new Action(() => buttonSerializeGraph.Enabled = projectOpened && graph.is_created)); + buttonCreateVerilog.Invoke(new Action(() => buttonCreateVerilog.Enabled = projectOpened && graph.is_created)); + } + }); + + } + + private void createGraphVerilog(bool createVerilog) + { + string graph_args_string = string.Join(" ", graph_args.Select(m => $"{m.Key} {m.Value}")); + if (createVerilog) + { + graph_args_string += " -v"; + } + + Process broker = new Process(); + + broker.StartInfo.RedirectStandardOutput = true; + broker.StartInfo.CreateNoWindow = true; + broker.EnableRaisingEvents = true; + broker.StartInfo.FileName = $"{broker_location}/Broker.exe"; + broker.StartInfo.WorkingDirectory = broker_location; + broker.StartInfo.Arguments = $"--project -l {projectLocation} -n {projectName} -o " + + $"{graph_args_string}"; + + broker.OutputDataReceived += new DataReceivedEventHandler((sender, e) => + { + if (!String.IsNullOrEmpty(e.Data)) + { + richTextBoxOutput.Invoke(new Action(() => + { + richTextBoxOutput.AppendText($"{e.Data}\n"); + richTextBoxOutput.ScrollToCaret(); + })); } }); + broker.Start(); + broker.BeginOutputReadLine(); + + broker.Exited += new EventHandler((sender, e) => + { + if (broker.ExitCode == 0) + { + richTextBoxOutput.Invoke(new Action(() => + { + if (!createVerilog) + { + richTextBoxOutput.AppendText($"Graph at project {projectName} at {projectLocation} was serialized\n\n"); + } + else + { + richTextBoxOutput.AppendText($"Created SystemVerilog description at project {projectName} at {projectLocation}\n\n"); + } + richTextBoxOutput.ScrollToCaret(); + })); + } + else + { + richTextBoxOutput.Invoke(new Action(() => + { + if (!createVerilog) + { + richTextBoxOutput.AppendText($"Failed to serialize graph at project {projectName} at {projectLocation}\n\n"); + } + else + { + richTextBoxOutput.AppendText($"Failed to create SystemVerilog description at project {projectName} at {projectLocation}\n\n"); + } + richTextBoxOutput.ScrollToCaret(); + })); + } + }); + } + + private void buttonSerializeGraph_Click(object sender, EventArgs e) + { + createGraphVerilog(false); + } + + private void buttonCreateVerilog_Click(object sender, EventArgs e) + { + createGraphVerilog(true); } } } diff --git a/Graph_verilog_generator/Graph_verilog_generator/Program.cs b/Graph_verilog_generator/Graph_verilog_generator/Program.cs index b9989a1..69ce89f 100644 --- a/Graph_verilog_generator/Graph_verilog_generator/Program.cs +++ b/Graph_verilog_generator/Graph_verilog_generator/Program.cs @@ -282,10 +282,11 @@ namespace HDLNoCGen finish_job(metadata_location, projectSettings); } - Tuple<string, Process, Process> preparation_result = ProjectGenerator.routerPreparation(graph, $"{name}_NoC_description", location, parameters); + Tuple<string, Process, Process, Process> preparation_result = ProjectGenerator.routerPreparation(graph, $"{name}_NoC_description", location, parameters); string verilog_path = preparation_result.Item1; Process compile_process = preparation_result.Item2; - Process simulate_process = preparation_result.Item3; + Process simulate_process_1 = preparation_result.Item3; + Process simulate_process_2 = preparation_result.Item4; graph.createNoC(verilog_path, parameters); diff --git a/Shared/Graph.cs b/Shared/Graph.cs index 810130c..1898313 100644 --- a/Shared/Graph.cs +++ b/Shared/Graph.cs @@ -29,7 +29,8 @@ /// </summary> public enum Arbiter_types { - Round_Robin + Round_Robin, + None }; /// <summary> @@ -39,7 +40,8 @@ { Index, Pointer, - Line + Line, + None }; /// <summary> @@ -48,7 +50,8 @@ public enum Queue_position { Front, - Rear + Rear, + None }; /// <summary> @@ -57,7 +60,8 @@ public enum Algorithm { XY, - GA + GA, + None }; } @@ -127,7 +131,7 @@ /// <summary> /// Указывает, был ли создан граф. /// </summary> - protected bool is_created { get; set; } + public bool is_created { get; protected set; } /// <summary> /// Количество узлов в графе. diff --git a/Shared/ProjectGenerator.cs b/Shared/ProjectGenerator.cs index 4b5660c..652c1d1 100644 --- a/Shared/ProjectGenerator.cs +++ b/Shared/ProjectGenerator.cs @@ -25,58 +25,6 @@ namespace HDLNoCGen static class ProjectGenerator { - #region legacy code - - public static void initializeTCL(string project_name, string routing_algorithm, string graph_signature, List<int> generators) - { - string top_entity_name = $"top_level_{project_name}"; - string router_name = $"router_{project_name}"; - string data_selector_name = $"data_selector_{project_name}"; - - FileStream fs; - StreamWriter sw; - - Directory.CreateDirectory($"{Settings.Get_project_path()}{project_name}"); - fs = new FileStream($"{Settings.Get_project_path()}{project_name}\\Setup.tcl", FileMode.Create, FileAccess.ReadWrite); - sw = new StreamWriter(fs); - - sw.WriteLine($"project_new {project_name} -overwrite"); - sw.WriteLine(); - sw.WriteLine("set_global_assignment -name FAMILY \"Cyclone V\""); - sw.WriteLine("set_global_assignment -name DEVICE 5CGXFC9E7F35C8"); - sw.WriteLine($"set_global_assignment -name VERILOG_FILE {data_selector_name}.v"); - sw.WriteLine($"set_global_assignment -name VERILOG_FILE {top_entity_name}.v"); - sw.WriteLine($"set_global_assignment -name VERILOG_FILE {router_name}.v"); - sw.WriteLine($"set_global_assignment -name TOP_LEVEL_ENTITY {top_entity_name}"); - sw.WriteLine(); - sw.WriteLine("load_package flow"); - sw.WriteLine("execute_flow -compile"); - sw.WriteLine(); - sw.WriteLine("project_close"); - - sw.Close(); - fs.Close(); - } - - public static void createBat(string project_name) - { - FileStream fs; - StreamWriter sw; - - Directory.CreateDirectory($"{Settings.Get_project_path()}{project_name}"); - fs = new FileStream($"{Settings.Get_project_path()}{project_name}\\Compile.bat", FileMode.Create, FileAccess.ReadWrite); - sw = new StreamWriter(fs); - - sw.WriteLine("C:"); - sw.WriteLine("cd \\"); - sw.WriteLine($"cd {Settings.Get_project_path()}{project_name}"); - sw.WriteLine($"{Settings.Get_path_to_quartus()}quartus_sh -t Setup.tcl"); - - sw.Close(); - fs.Close(); - - } - #endregion public static void killProcessAndChildren(int pid) { @@ -173,7 +121,7 @@ namespace HDLNoCGen public static void createSimulateScript(string project_path, string project_name, string mode) { - var fs = new FileStream($"{project_path}\\Modelsim_simulate.tcl", FileMode.Create, FileAccess.ReadWrite); + var fs = new FileStream($"{project_path}\\Modelsim_simulate_{mode}.tcl", FileMode.Create, FileAccess.ReadWrite); var sw = new StreamWriter(fs); sw.WriteLine($"vlib work"); @@ -185,7 +133,7 @@ namespace HDLNoCGen fs.Close(); } - public static Tuple<string, Process, Process> routerPreparation(Graph graph, string project_name, string project_path, router_options parametres) + public static Tuple<string, Process, Process, Process> routerPreparation(Graph graph, string project_name, string project_path, router_options parametres) { string path = $"{project_path}\\{project_name}"; @@ -193,34 +141,51 @@ namespace HDLNoCGen FileStream fs; StreamWriter sw; + createSetupSH(path, project_name, "toplevel"); + createSetupSTA(path, project_name); + createSimulateScript(path, project_name, "queueing"); + createSimulateScript(path, project_name, "routing"); + fs = new FileStream($"{path}\\Compile.bat", FileMode.Create, FileAccess.ReadWrite); sw = new StreamWriter(fs); sw.WriteLine($"{path.Substring(0, 2)}"); sw.WriteLine($"cd {path}\n"); - sw.WriteLine($"{Settings.Get_path_to_quartus()}quartus_sh -t Setup_sh.tcl"); - sw.WriteLine($"{Settings.Get_path_to_quartus()}quartus_sta -t Setup_sta.tcl"); + sw.WriteLine($"quartus_sh -t Setup_sh.tcl"); + sw.WriteLine($"quartus_sta -t Setup_sta.tcl"); + + sw.Close(); + fs.Close(); + + + fs = new FileStream($"{path}\\Simulate_q.bat", FileMode.Create, FileAccess.ReadWrite); + sw = new StreamWriter(fs); + + sw.WriteLine($"{path.Substring(0, 2)}"); + sw.WriteLine($"cd {path}\n"); + sw.WriteLine($"vsim -c -do Modelsim_simulate_queueing.tcl"); sw.Close(); fs.Close(); - fs = new FileStream($"{path}\\Simulate.bat", FileMode.Create, FileAccess.ReadWrite); + fs = new FileStream($"{path}\\Simulate_r.bat", FileMode.Create, FileAccess.ReadWrite); sw = new StreamWriter(fs); sw.WriteLine($"{path.Substring(0, 2)}"); sw.WriteLine($"cd {path}\n"); - sw.WriteLine($"vsim -c -do Modelsim_simulate.tcl"); + sw.WriteLine($"vsim -c -do Modelsim_simulate_routing.tcl"); sw.Close(); fs.Close(); - Process simulation_process = new Process(); + Process simulation_process_1 = new Process(); + Process simulation_process_2 = new Process(); Process compilation_process = new Process(); Console.CancelKeyPress += delegate { killProcessAndChildren(compilation_process.Id); - killProcessAndChildren(simulation_process.Id); + killProcessAndChildren(simulation_process_1.Id); }; string comp_path = path + "\\Compile.bat"; @@ -233,16 +198,24 @@ namespace HDLNoCGen compilation_process.EnableRaisingEvents = true; compilation_process.StartInfo.StandardOutputEncoding = Encoding.GetEncoding("utf-8"); - simulation_process.StartInfo.FileName = sim_path; - simulation_process.StartInfo.UseShellExecute = false; - simulation_process.StartInfo.RedirectStandardOutput = true; - simulation_process.StartInfo.CreateNoWindow = true; - simulation_process.EnableRaisingEvents = true; - simulation_process.StartInfo.StandardOutputEncoding = Encoding.GetEncoding("utf-8"); - - return new Tuple<string, Process, Process>(path, compilation_process, simulation_process); + simulation_process_1.StartInfo.FileName = sim_path; + simulation_process_1.StartInfo.UseShellExecute = false; + simulation_process_1.StartInfo.RedirectStandardOutput = true; + simulation_process_1.StartInfo.CreateNoWindow = true; + simulation_process_1.EnableRaisingEvents = true; + simulation_process_1.StartInfo.StandardOutputEncoding = Encoding.GetEncoding("utf-8"); + + simulation_process_2.StartInfo.FileName = sim_path; + simulation_process_2.StartInfo.UseShellExecute = false; + simulation_process_2.StartInfo.RedirectStandardOutput = true; + simulation_process_2.StartInfo.CreateNoWindow = true; + simulation_process_2.EnableRaisingEvents = true; + simulation_process_2.StartInfo.StandardOutputEncoding = Encoding.GetEncoding("utf-8"); + + return new Tuple<string, Process, Process, Process>(path, compilation_process, simulation_process_1, simulation_process_2); } + /* public static void networkCompilation(CancellationToken GeneralPurposeCancellationToken, Process compile, Process simulate, Graph graph, router_options parameters, @@ -506,6 +479,7 @@ namespace HDLNoCGen compile.WaitForExit(); Console.WriteLine("Process exited with code " + compile.ExitCode); } + */ } } -- GitLab