Skip to content

Commit

Permalink
Implementando criacão automatica do arquivo de config
Browse files Browse the repository at this point in the history
Implementando cricão automatica baseada em template do arquivo de config
caso ele não exista
  • Loading branch information
JN513 committed Feb 5, 2025
1 parent 91e92de commit 3a6dce3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,19 @@ Details:
1. **Configure a processor for a specific board:**

```bash
python3 script.py -c config.json -p processor_name -b board_name
python3 main.py -c config.json -p processor_name -b board_name
```

2. **Define a custom path for toolchains:**

```bash
python3 script.py -c config.json -p processor_name -b board_name -t /custom/toolchain/path
python3 main.py -c config.json -p processor_name -b board_name -t /custom/toolchain/path
```

3. **Load the bitstream onto the FPGA after the build:**

```bash
python3 script.py -c config.json -p processor_name -b board_name -l
python3 main.py -c config.json -p processor_name -b board_name -l
```

**Requirements:**
Expand Down
23 changes: 20 additions & 3 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@
import json


def create_default_config(config_path: str) -> None:
"""Creates a default configuration file with an empty dictionary.
Args:
config_path (str): Path to the JSON configuration file.
Returns:
None
Raises:
IOError: If there is an issue writing to the file.
"""
with open(config_path, 'w', encoding='utf-8') as file:
json.dump({'cores': {}}, file, indent=4)


def load_config(config_path: str) -> dict:
"""Loads a JSON configuration file and returns its content.
Expand All @@ -27,9 +43,10 @@ def load_config(config_path: str) -> dict:
json.JSONDecodeError: If the file is not a valid JSON.
"""
if not os.path.exists(config_path):
raise FileNotFoundError(
f'The configuration file {config_path} was not found.'
)
# raise FileNotFoundError(
# f'The configuration file {config_path} was not found.'
# )
create_default_config(config_path)

with open(config_path, 'r', encoding='utf-8') as file:
config_data = json.load(file)
Expand Down
8 changes: 5 additions & 3 deletions core/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ def generate_jenkinsfile(
+ f' -s {config["top_module"]} {include_dirs} {files} {sim_files}"'
)
else:
simulation_command = f'echo "simulation not supported for mixed VHDL and Verilog files"'
#raise ValueError(
simulation_command = (
f'echo "simulation not supported for mixed VHDL and Verilog files"'
)
# raise ValueError(
# f'The files must be either exclusively VHDL or Verilog. Processor {config["repository"]}'
#)
# )

# Prepare FPGA stages for each FPGA in parallel
fpga_parallel_stages = '\n '.join(
Expand Down

0 comments on commit 3a6dce3

Please sign in to comment.