From a2d6a3b8b0d56461c05590426fba92fa5daa5868 Mon Sep 17 00:00:00 2001 From: Julio Nunes Avelar Date: Tue, 19 Nov 2024 20:58:55 -0300 Subject: [PATCH] Formatando codigo e adicionando selo do linter --- README.md | 4 +++- config_generator.py | 7 ++++--- core/file_manager.py | 4 +++- core/jenkins.py | 4 +++- core/ollama.py | 6 ++++-- utils/clean.py | 18 +++++++++-------- utils/plot.py | 48 ++++++++++++++++++++++++++++++++++---------- utils/run_all.py | 8 +++++--- 8 files changed, 69 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index e04775f..040ee4e 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# ProcessorCI \ No newline at end of file +# ProcessorCI + +[![Pylint](https://github.com/LSC-Unicamp/processor-ci/actions/workflows/pylint.yml/badge.svg)](https://github.com/LSC-Unicamp/processor-ci/actions/workflows/pylint.yml) \ No newline at end of file diff --git a/config_generator.py b/config_generator.py index 83b4eb9..1af360f 100644 --- a/config_generator.py +++ b/config_generator.py @@ -13,7 +13,7 @@ find_include_dirs, ) from core.graph import build_module_graph -from core.ollama import get_filtered_files_list, get_top_module, generate_top_file +from core.ollama import get_filtered_files_list, get_top_module from core.jenkins import generate_jenkinsfile @@ -36,6 +36,7 @@ def get_top_module_file(modules: list[dict[str, str]], top_module: str) -> str: return "" + def copy_hardware_template(repo_name: str) -> None: # Caminho do diretório de origem orig = "rtl/template.v" @@ -138,8 +139,8 @@ def generate_processor_config( log_file.close() copy_hardware_template(repo_name) - #top_module_file = get_top_module_file(modulename_list, top_module) - #generate_top_file(top_module_file, repo_name) + # top_module_file = get_top_module_file(modulename_list, top_module) + # generate_top_file(top_module_file, repo_name) remove_repo(repo_name) diff --git a/core/file_manager.py b/core/file_manager.py index c526f0b..67ec0c2 100644 --- a/core/file_manager.py +++ b/core/file_manager.py @@ -14,7 +14,9 @@ def clone_repo(url, repo_name): try: # Clonar o repositório - subprocess.run(["git", "clone", "--recursive", url, destination_path], check=True) + subprocess.run( + ["git", "clone", "--recursive", url, destination_path], check=True + ) return destination_path except subprocess.CalledProcessError as e: print(f"Erro ao clonar o repositório: {e}") diff --git a/core/jenkins.py b/core/jenkins.py index b811c28..77d2e0d 100644 --- a/core/jenkins.py +++ b/core/jenkins.py @@ -54,7 +54,9 @@ def generate_jenkinsfile( file.endswith(".vhdl") or file.endswith(".vhd") for file in config.get("files", []) ) - is_verilog = any(file.endswith(".v") or file.endswith(".sv") for file in config.get("files", [])) + is_verilog = any( + file.endswith(".v") or file.endswith(".sv") for file in config.get("files", []) + ) if is_vhdl and not is_verilog: # VHDL simulation command diff --git a/core/ollama.py b/core/ollama.py index 2956859..c976726 100644 --- a/core/ollama.py +++ b/core/ollama.py @@ -8,7 +8,9 @@ client = Client(host=SERVER_URL) -def send_prompt(prompt: str, model: str = "qwen2.5:32b") -> tuple[bool, str]: # "qwen2.5:32b" +def send_prompt( + prompt: str, model: str = "qwen2.5:32b" +) -> tuple[bool, str]: # "qwen2.5:32b" response = client.generate(prompt=prompt, model=model) @@ -75,7 +77,7 @@ def get_filtered_files_list(files, sim_files, modules, tree, repo_name): if not ok: raise NameError("Erro ao consultar modelo") - print (response) + print(response) return parse_filtered_files(response) diff --git a/utils/clean.py b/utils/clean.py index 97adb92..3bed01f 100644 --- a/utils/clean.py +++ b/utils/clean.py @@ -1,18 +1,20 @@ import json # Carregar o JSON do arquivo config.json -with open('config.json', 'r') as file: +with open("config.json", "r") as file: data = json.load(file) # Remover as chaves indesejadas -for core in data['cores'].values(): - core.pop('modules', None) - core.pop('module_graph', None) - core.pop('module_graph_inverse', None) - core.pop('non_tb_files', None) +for core in data["cores"].values(): + core.pop("modules", None) + core.pop("module_graph", None) + core.pop("module_graph_inverse", None) + core.pop("non_tb_files", None) # Salvar o resultado em config2.json -with open('config2.json', 'w') as file: +with open("config2.json", "w") as file: json.dump(data, file, indent=4) -print("As chaves indesejadas foram removidas e o novo arquivo foi salvo como config2.json.") +print( + "As chaves indesejadas foram removidas e o novo arquivo foi salvo como config2.json." +) diff --git a/utils/plot.py b/utils/plot.py index 0fced38..f609c8a 100644 --- a/utils/plot.py +++ b/utils/plot.py @@ -9,7 +9,7 @@ "Mriscv": {"LUT4": 2658, "Frequency": 66.84}, "TinyRiscv": {"LUT4": 3964, "Frequency": 59.85}, "riskow": {"LUT4": 1957, "Frequency": 63.45}, - "riscado-v": {"LUT4": 2246, "Frequency": 45.22} + "riscado-v": {"LUT4": 2246, "Frequency": 45.22}, } dados_xilinx = { @@ -20,7 +20,7 @@ "Mriscv": {"LUT4": 1766, "Frequency": 86.8}, "TinyRiscv": {"LUT4": 2570, "Frequency": 77.8}, "riskow": {"LUT4": 1399, "Frequency": 82.48}, - "riscado-v": {"LUT4": 990, "Frequency": 58.7} + "riscado-v": {"LUT4": 990, "Frequency": 58.7}, } # Preparar dados para a tecnologia Lattice ECP45F (original) @@ -36,26 +36,52 @@ plt.figure(figsize=(10, 6)) # Plot para Lattice ECP45F com pontos maiores -plt.scatter(frequencia_values_lattice, lut4_values_lattice, color='blue', label='Lattice ECP45F', s=150) +plt.scatter( + frequencia_values_lattice, + lut4_values_lattice, + color="blue", + label="Lattice ECP45F", + s=150, +) # Plot para Xilinx XC7A100T com pontos maiores -plt.scatter(frequencia_values_xilinx, lut4_values_xilinx, color='red', label='Xilinx XC7A100T', s=150) +plt.scatter( + frequencia_values_xilinx, + lut4_values_xilinx, + color="red", + label="Xilinx XC7A100T", + s=150, +) # Adicionar rótulos aos pontos para Lattice com fonte maior e centralizado for i, label in enumerate(labels): - plt.text(frequencia_values_lattice[i], lut4_values_lattice[i] + 100, label, fontsize=14, ha='center', va='bottom') + plt.text( + frequencia_values_lattice[i], + lut4_values_lattice[i] + 100, + label, + fontsize=14, + ha="center", + va="bottom", + ) # Adicionar rótulos aos pontos para Xilinx com fonte maior e centralizado for i, label in enumerate(labels): - plt.text(frequencia_values_xilinx[i], lut4_values_xilinx[i] + 100, label, fontsize=14, ha='center', va='bottom') + plt.text( + frequencia_values_xilinx[i], + lut4_values_xilinx[i] + 100, + label, + fontsize=14, + ha="center", + va="bottom", + ) # Adicionar títulos e rótulos aos eixos com fonte aumentada -plt.title('Frequency vs. LUT for Lattice ECP45F and Xilinx XC7A100T', fontsize=16) -plt.xlabel('Frequency (MHz)', fontsize=18) -plt.ylabel('LUT', fontsize=18) +plt.title("Frequency vs. LUT for Lattice ECP45F and Xilinx XC7A100T", fontsize=16) +plt.xlabel("Frequency (MHz)", fontsize=18) +plt.ylabel("LUT", fontsize=18) # Aumentar o tamanho da fonte dos ticks dos eixos -plt.tick_params(axis='both', which='major', labelsize=16) +plt.tick_params(axis="both", which="major", labelsize=16) # Adicionar uma grade plt.grid(True) @@ -64,5 +90,5 @@ plt.legend(fontsize=16) # Mostrar gráfico -plt.savefig('plot.png', format='png') +plt.savefig("plot.png", format="png") plt.show() diff --git a/utils/run_all.py b/utils/run_all.py index b719714..aa32d93 100644 --- a/utils/run_all.py +++ b/utils/run_all.py @@ -1,10 +1,10 @@ import subprocess # Caminho para o arquivo que contém a lista de URLs -file_path = 'arquivos.txt' +file_path = "arquivos.txt" # Abrir o arquivo e ler as URLs -with open(file_path, 'r') as file: +with open(file_path, "r") as file: urls = file.readlines() # Remover qualquer espaço ou quebra de linha ao final de cada URL @@ -26,6 +26,8 @@ # Executar o comando com timeout subprocess.run(command_base, timeout=timeout_seconds, check=True) except subprocess.TimeoutExpired: - print(f"Comando para {url} atingiu o tempo limite de {timeout_seconds} segundos.") + print( + f"Comando para {url} atingiu o tempo limite de {timeout_seconds} segundos." + ) except subprocess.CalledProcessError as e: print(f"Erro ao executar o comando para {url}: {e}")