Commit 84d0fd35 authored by Талибов Сэрхан Махмад Оглы's avatar Талибов Сэрхан Махмад Оглы
Browse files

Made some cosmetical (filenames) improvement and some functional improvements....

Made some cosmetical (filenames) improvement and some functional improvements. If there are verilog files, app overwrites them instead of sharting all over itself. Also you can create multiple projects in one directory for some reason if you want to. Deletion is more precise. Renaming should have some work done to it tho
1 merge request!12 of 4 services are donwe
Showing with 108 additions and 42 deletions
+108 -42
......@@ -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>
......
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 = "";
......
......@@ -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
......@@ -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);
}
}
......
......@@ -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
......@@ -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)
{
......
......@@ -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");
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment