@@ -78,7 +78,7 @@ def add_include(self, path):
78
78
raise NotADirectoryError (path )
79
79
self .data .setdefault ('includes' , []).append (path .as_posix ())
80
80
81
- def _add_file (self , pathname , hdl = None , lib = None ):
81
+ def _add_file (self , pathname , hdl = None , lib = None , options = None ):
82
82
files = glob .glob (pathname , recursive = True )
83
83
if len (files ) == 0 :
84
84
raise FileNotFoundError (pathname )
@@ -89,52 +89,64 @@ def _add_file(self, pathname, hdl=None, lib=None):
89
89
attr ['hdl' ] = hdl
90
90
if lib :
91
91
attr ['lib' ] = lib
92
+ if options :
93
+ attr ['opt' ] = options
92
94
self .data .setdefault ('files' , {})[path .as_posix ()] = attr
93
95
94
- def add_slog (self , pathname ):
96
+ def add_slog (self , pathname , options = None ):
95
97
"""Add System Verilog file/s.
96
98
97
99
:param pathname: path to a SV file (glob compliant)
98
100
:type pathname: str
101
+ :param options: extra options for the underlying command
102
+ :type options: str, optional
99
103
:raises FileNotFoundError: when pathname is not found
100
104
"""
101
105
self .logger .debug ('Executing add_slog' )
102
- self ._add_file (pathname , 'slog' )
106
+ self ._add_file (pathname , 'slog' , options )
103
107
104
- def add_vhdl (self , pathname , lib = None ):
108
+ def add_vhdl (self , pathname , lib = None , options = None ):
105
109
"""Add VHDL file/s.
106
110
107
111
:param pathname: path to a SV file (glob compliant)
108
112
:type pathname: str
109
113
:param lib: VHDL library name
110
114
:type lib: str, optional
115
+ :param options: extra options for the underlying command
116
+ :type options: str, optional
111
117
:raises FileNotFoundError: when pathname is not found
112
118
"""
113
119
self .logger .debug ('Executing add_vhdl' )
114
- self ._add_file (pathname , 'vhdl' , lib )
120
+ self ._add_file (pathname , 'vhdl' , lib , options )
115
121
116
- def add_vlog (self , pathname ):
122
+ def add_vlog (self , pathname , options = None ):
117
123
"""Add Verilog file/s.
118
124
119
125
:param pathname: path to a SV file (glob compliant)
120
126
:type pathname: str
127
+ :param options: extra options for the underlying command
128
+ :type options: str, optional
121
129
:raises FileNotFoundError: when pathname is not found
122
130
"""
123
131
self .logger .debug ('Executing add_vlog' )
124
- self ._add_file (pathname , 'vlog' )
132
+ self ._add_file (pathname , 'vlog' , options )
125
133
126
- def add_cons (self , path ):
134
+ def add_cons (self , path , options = None ):
127
135
"""Add a constraint file.
128
136
129
- :param pathname: path of a file
137
+ :param pathname: path to a constraint file
130
138
:type pathname: str
139
+ :param options: extra options for the underlying command
140
+ :type options: str, optional
131
141
:raises FileNotFoundError: if path is not found
132
142
"""
133
143
self .logger .debug ('Executing add_cons' )
134
144
path = Path (path ).resolve ()
135
145
if not path .is_file ():
136
146
raise FileNotFoundError (path )
137
147
attr = {}
148
+ if options :
149
+ attr ['opt' ] = options
138
150
self .data .setdefault ('constraints' , {})[path .as_posix ()] = attr
139
151
140
152
def add_param (self , name , value ):
@@ -200,6 +212,23 @@ def add_hook(self, stage, hook):
200
212
raise ValueError ('Invalid stage.' )
201
213
self .data .setdefault ('hooks' , {}).setdefault (stage , []).append (hook )
202
214
215
+ def add_options (self , command , options ):
216
+ """Add options for the specified underlying command.
217
+
218
+ :param command: command where to apply the options
219
+ :type command: str
220
+ :param options: extra options for the underlying command
221
+ :type options: str
222
+ :raises ValueError: when command is invalid
223
+ """
224
+ self .logger .debug ('Executing add_options' )
225
+ commands = ['prj' , 'syn' , 'par' , 'bit' ]
226
+ if command not in commands :
227
+ raise ValueError ('Invalid command.' )
228
+ self .data .setdefault ('options' , {}).setdefault (command , []).append (
229
+ options
230
+ )
231
+
203
232
def set_debug (self ):
204
233
"""Enables debug messages."""
205
234
self .logger .setLevel (logging .DEBUG )
0 commit comments