Coverage for tsfpga/ip_core_file.py: 100%
12 statements
« prev ^ index » next coverage.py v7.2.1, created at 2023-09-27 20:00 +0000
« prev ^ index » next coverage.py v7.2.1, created at 2023-09-27 20:00 +0000
1# --------------------------------------------------------------------------------------------------
2# Copyright (c) Lukas Vik. All rights reserved.
3#
4# This file is part of the tsfpga project, a project platform for modern FPGA development.
5# https://tsfpga.com
6# https://gitlab.com/tsfpga/tsfpga
7# --------------------------------------------------------------------------------------------------
10class IpCoreFile:
11 """
12 Class for handling an IP core file.
13 """
15 def __init__(self, path, **variables):
16 """
17 Arguments:
18 path (pathlib.Path): Path to the TCL script that creates the IP.
19 Should typically end in .tcl.
20 variables: These name/value variable pairs will be set in TCL before
21 the IP core ``.tcl`` file is sourced. This makes it possible to parameterize the IP
22 core creation.
24 .. note::
25 This is a "kwargs" style argument. You can pass any number of named arguments.
26 """
27 self.path = path
28 self.variables = variables
30 @property
31 def name(self):
32 """
33 str: A shorthand name for this IP core.
34 """
35 file_name_no_suffix = self.path.stem
36 if " " in file_name_no_suffix:
37 raise ValueError(f"File name may not contain spaces: {self.path}")
38 return file_name_no_suffix
40 def __str__(self):
41 return f"{self.__class__.__name__}:{self.path}:{self.variables}"