diff --git a/Broker/Broker/Broker.csproj b/Broker/Broker/Broker.csproj index bddc63fb95cdb23b27e15d10583b0cff9ede29a1..dba7e8ab4633ee16cc72333ec645872af3b7ff1b 100644 --- a/Broker/Broker/Broker.csproj +++ b/Broker/Broker/Broker.csproj @@ -7,6 +7,10 @@ <Nullable>enable</Nullable> </PropertyGroup> + <ItemGroup> + <Compile Include="..\..\Shared\ProjectSettings.cs" Link="ProjectSettings.cs" /> + </ItemGroup> + <ItemGroup> <PackageReference Include="System.Security.Cryptography.ProtectedData" Version="9.0.2" /> </ItemGroup> diff --git a/Broker/Broker/Program.cs b/Broker/Broker/Program.cs index 59630f88f57652bd41bc22a3913b9a6c6a3f9ac5..093384206d5f449b007fe9e7eb7aa1ad84ea93a6 100644 --- a/Broker/Broker/Program.cs +++ b/Broker/Broker/Program.cs @@ -1,10 +1,40 @@ using System; using System.Diagnostics; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; namespace HDLNoCGen { static class Program { + + static void uncheckMetadata (string json_path, int stage) + { + string json = File.ReadAllText(json_path); + ProjectSettings projectSettings = JsonSerializer.Deserialize<ProjectSettings>(json); + + if (stage <= 3) + { + projectSettings.databaseMetadata.writtenToDB = false; + } + if (stage <= 2) + { + projectSettings.quartusMetadata.quartusCompiled = false; + } + if (stage <= 1) + { + projectSettings.graphVerilogMetadata.verilogGenerated = false; + } + if (stage == 0) + { + projectSettings.graphVerilogMetadata.graphSerialized = false; + } + + json = JsonSerializer.Serialize<ProjectSettings>(projectSettings, new JsonSerializerOptions { WriteIndented = true }); + File.WriteAllText(json_path, json); + } + static void Main(string[] args) { @@ -311,15 +341,16 @@ namespace HDLNoCGen if (launch_graph) { + uncheckMetadata($"{project_location}/{project_name}_metadata.json", 0); using (Process veriloger = new Process()) { string veriloger_location = "../../../../../Graph_verilog_generator/Graph_verilog_generator/bin/Debug/net8.0"; - string veriloger_arguments = $"-l {project_location} -n {project_name} {topology} {String.Join(" ", generators)}" + - $"--queue_type {queue_type}" + - $"--queue_position {queue_position}" + - $"--arbiter_type {arbiter_type}" + - $"--algorithm {algorithm}" + - $"--info_width {info_width}" + + string veriloger_arguments = $"-l {project_location} -n {project_name} {topology} {String.Join(" ", generators)} " + + $"--queue_type {queue_type} " + + $"--queue_position {queue_position} " + + $"--arbiter_type {arbiter_type} " + + $"--algorithm {algorithm} " + + $"--info_width {info_width} " + $"--queue_length {queue_length} " + $"{(create_verilog ? "-v" : " ")}"; string output_data = ""; diff --git a/Broker/Broker/Properties/launchSettings.json b/Broker/Broker/Properties/launchSettings.json index a000a2c9e710964e88924846c8ca146a1012761d..d4fc9411bdc8a3df16cbf9384b7e1df8bc8f00b2 100644 --- a/Broker/Broker/Properties/launchSettings.json +++ b/Broker/Broker/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Broker": { "commandName": "Project", - "commandLineArgs": "--project -l D:/kal -n kal -o --graph m 3 3 --queue_type pointer --queue_position front --arbiter_type round_robin --algorithm xy --info_width 8 --queue_length 16 -v" + "commandLineArgs": "--project -l D:/kal -n kal -e" } } } \ No newline at end of file diff --git a/Graph_verilog_generator/Graph_verilog_generator/Program.cs b/Graph_verilog_generator/Graph_verilog_generator/Program.cs index 0653132fe56fe5864e67bfc714053bd4e50eae0b..b9989a1699a16019c8f6eaf9ad4851bbb8422611 100644 --- a/Graph_verilog_generator/Graph_verilog_generator/Program.cs +++ b/Graph_verilog_generator/Graph_verilog_generator/Program.cs @@ -8,6 +8,14 @@ namespace HDLNoCGen { static class Program { + + static void finish_job (string json_location, ProjectSettings project_settings) + { + string json = JsonSerializer.Serialize<ProjectSettings>(project_settings, new JsonSerializerOptions { WriteIndented = true }); + File.WriteAllText(json_location, json); + Environment.Exit(0); + } + static void Main(string[] args) { string location = "C:/Users/Serha/Desktop/kal"; @@ -111,6 +119,10 @@ namespace HDLNoCGen Environment.Exit(1); } + string metadata_location = $"{location}/{name}_metadata.json"; + string project_settings_json = File.ReadAllText(metadata_location); + ProjectSettings projectSettings = JsonSerializer.Deserialize<ProjectSettings>(project_settings_json); + switch (topology) { case "c": @@ -244,56 +256,41 @@ namespace HDLNoCGen parameters.info_width = info_width; graph.parameters = parameters; - string json = ""; + string graph_json = ""; switch (graph.graphId) { case GraphType.Circulant: - json = JsonSerializer.Serialize<GraphCirculant>(graph as GraphCirculant, new JsonSerializerOptions { WriteIndented = true }); + graph_json = JsonSerializer.Serialize<GraphCirculant>(graph as GraphCirculant, new JsonSerializerOptions { WriteIndented = true }); break; case GraphType.Mesh: - json = JsonSerializer.Serialize<GraphMesh>(graph as GraphMesh, new JsonSerializerOptions { WriteIndented = true }); + graph_json = JsonSerializer.Serialize<GraphMesh>(graph as GraphMesh, new JsonSerializerOptions { WriteIndented = true }); break; case GraphType.Torus: - json = JsonSerializer.Serialize<GraphTorus>(graph as GraphTorus, new JsonSerializerOptions { WriteIndented = true }); + graph_json = JsonSerializer.Serialize<GraphTorus>(graph as GraphTorus, new JsonSerializerOptions { WriteIndented = true }); break; } - using (StreamWriter sw = new StreamWriter($"{location}/graph_object_serialized.json")) + using (StreamWriter sw = new StreamWriter($"{location}/{name}_graph_object_serialized.json")) { - sw.Write(json); + sw.Write(graph_json); } + projectSettings.graphVerilogMetadata.graphSerialized = true; if (!create_verilog) { - Environment.Exit(0); + finish_job(metadata_location, projectSettings); } - Tuple<string, Process, Process> preparation_result = ProjectGenerator.routerPreparation(graph, "NoC_description", location, parameters); + Tuple<string, 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; graph.createNoC(verilog_path, parameters); - StreamReader sr = new StreamReader($"{location}\\graph_object_serialized.json"); - string json_deser = sr.ReadToEnd(); - sr.Close(); - - GraphDeserializer des_graph_test = JsonSerializer.Deserialize<GraphDeserializer>(json_deser); - Graph graph_des; - switch (des_graph_test.graphId) - { - case GraphType.Circulant: - graph_des = new GraphCirculant(des_graph_test); - break; - case GraphType.Mesh: - graph_des = new GraphMesh(des_graph_test); - break; - case GraphType.Torus: - graph_des = new GraphTorus(des_graph_test); - break; - } + projectSettings.graphVerilogMetadata.verilogGenerated = true; + finish_job(metadata_location, projectSettings); } } diff --git a/Graph_verilog_generator/Graph_verilog_generator/Properties/launchSettings.json b/Graph_verilog_generator/Graph_verilog_generator/Properties/launchSettings.json index e176fd2ea6dcd1b4b92233fbbc5505cca77e2b0f..e2eb19bf2f4bac526fa72109a139b5291d201903 100644 --- a/Graph_verilog_generator/Graph_verilog_generator/Properties/launchSettings.json +++ b/Graph_verilog_generator/Graph_verilog_generator/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Graph_verilog_generator": { "commandName": "Project", - "commandLineArgs": "m 3 3 -v" + "commandLineArgs": "-l D:/kal -n kal 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/Project_manager/Project_manager/Program.cs b/Project_manager/Project_manager/Program.cs index 42cf356ce723ccf64a9cb7bc018c7fe3ada4431e..292bbbb0577ab809e0dd5e6e1bc66651fcba7018 100644 --- a/Project_manager/Project_manager/Program.cs +++ b/Project_manager/Project_manager/Program.cs @@ -57,6 +57,8 @@ namespace HDLNoCGen string metadata_location = $"{location}/{name}_metadata.json"; string new_metadata_location = $"{location}/{new_name}_metadata.json"; + string graph_location = $"{location}/{name}_graph_object_serialized.json"; + string verilog_location = $"{location}/{name}_NoC_description"; switch (action) { @@ -129,9 +131,9 @@ namespace HDLNoCGen } } - if (Directory.EnumerateFileSystemEntries(location).Any()) + if (File.Exists(metadata_location)) { - Console.WriteLine("Failed to create a project. Directory must be empty"); + Console.WriteLine("This project already exists"); Environment.Exit(1); } @@ -168,7 +170,18 @@ namespace HDLNoCGen try { - Directory.Delete(location, true); + if (File.Exists(graph_location)) + { + File.Delete(graph_location); + } + if (File.Exists(metadata_location)) + { + File.Delete(metadata_location); + } + if (Directory.Exists(verilog_location)) + { + Directory.Delete(verilog_location, true); + } } catch (Exception e) { diff --git a/Shared/Graph.cs b/Shared/Graph.cs index 70753783255274ebc07827e72a1eb26a3cdacb22..652221fd2aef8d3e7bd8ab55eab2958f2d8cba0f 100644 --- a/Shared/Graph.cs +++ b/Shared/Graph.cs @@ -444,9 +444,30 @@ /// <param name="parametrs">Параметры роутера.</param> public virtual void createRouter(string project_path, router_options parametrs) { - Directory.CreateDirectory(project_path); - Directory.CreateDirectory(project_path + "\\src"); - Directory.CreateDirectory(project_path + "\\inc"); + if (Directory.Exists(project_path)) + { + FileSystemWatcher watcher = new FileSystemWatcher(); + AutoResetEvent waitDeleteHandle = new AutoResetEvent(false); + + watcher.Path = project_path; + watcher.EnableRaisingEvents = true; + watcher.Deleted += new FileSystemEventHandler((sender, e) => + { + Directory.CreateDirectory(project_path); + Directory.CreateDirectory(project_path + "\\src"); + Directory.CreateDirectory(project_path + "\\inc"); + waitDeleteHandle.Set(); + }); + + Directory.Delete(project_path, true); + waitDeleteHandle.WaitOne(); + } + else + { + Directory.CreateDirectory(project_path); + Directory.CreateDirectory(project_path + "\\src"); + Directory.CreateDirectory(project_path + "\\inc"); + } File.Copy(descipher_router(parametrs.arbiter_type), project_path + "\\src\\arbiter.sv"); File.Copy(descipher_router(parametrs.algorithm), project_path + "\\src\\algorithm.sv"); diff --git a/Shared/ProjectSettings.cs b/Shared/ProjectSettings.cs index 9c67266c8837d41ae43c291239a1daaeddf51076..f2501ff2590995543f9bd8c6200237723cfaed7b 100644 --- a/Shared/ProjectSettings.cs +++ b/Shared/ProjectSettings.cs @@ -39,21 +39,21 @@ namespace HDLNoCGen } public class DatabaseMetadata { - public bool writeToDB { get; set; } public string dbIp { get; set; } public string dbUsername { get; set; } public string dbPassword { get; set; } public string dbName { get; set; } public int dbPort { get; set; } + public bool writtenToDB { get; set; } public DatabaseMetadata () { - writeToDB = false; dbIp = ""; dbUsername = ""; dbPassword = ""; dbName = ""; dbPort = -1; + writtenToDB = false; } } public class ProjectSettings