Skip to content

Commit

Permalink
Formatando codigo e adicionando selo do linter
Browse files Browse the repository at this point in the history
  • Loading branch information
JN513 committed Nov 19, 2024
1 parent 4d587dc commit a2d6a3b
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 30 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# ProcessorCI
# 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)
7 changes: 4 additions & 3 deletions config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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"
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion core/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
4 changes: 3 additions & 1 deletion core/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions core/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
18 changes: 10 additions & 8 deletions utils/clean.py
Original file line number Diff line number Diff line change
@@ -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."
)
48 changes: 37 additions & 11 deletions utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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()
8 changes: 5 additions & 3 deletions utils/run_all.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}")

0 comments on commit a2d6a3b

Please sign in to comment.