• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nbiotcloud / ucdp / 15022777255

14 May 2025 02:02PM UTC coverage: 95.976% (-0.2%) from 96.142%
15022777255

push

github

iccode17
Merge branch 'Vulcanos-the-real-one-feature/create-mod'

15 of 26 new or added lines in 3 files covered. (57.69%)

4865 of 5069 relevant lines covered (95.98%)

7.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.22
/src/ucdp/cli.py
1
#
2
# MIT License
3
#
4
# Copyright (c) 2024-2025 nbiotcloud
5
#
6
# Permission is hereby granted, free of charge, to any person obtaining a copy
7
# of this software and associated documentation files (the "Software"), to deal
8
# in the Software without restriction, including without limitation the rights
9
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
# copies of the Software, and to permit persons to whom the Software is
11
# furnished to do so, subject to the following conditions:
12
#
13
# The above copyright notice and this permission notice shall be included in all
14
# copies or substantial portions of the Software.
15
#
16
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
# SOFTWARE.
23
#
24

25
"""Command Line Interface."""
26

27
import logging
8✔
28
import sys
8✔
29
from collections import defaultdict
8✔
30
from collections.abc import Iterable
8✔
31
from logging import StreamHandler
8✔
32
from pathlib import Path
8✔
33
from typing import Literal
8✔
34

35
import click
8✔
36
from click_bash42_completion import patch
8✔
37
from pydantic import BaseModel, ConfigDict
8✔
38
from rich.console import Console
8✔
39
from rich.logging import RichHandler
8✔
40
from rich.pretty import pprint
8✔
41
from rich.table import Table
8✔
42

43
from ._cligroup import MainGroup
8✔
44
from ._logging import HasErrorHandler
8✔
45
from .cache import CACHE
8✔
46
from .cliutil import (
8✔
47
    PathType,
48
    arg_template_filepaths,
49
    arg_top,
50
    arg_tops,
51
    auto_path,
52
    defines2data,
53
    opt_check,
54
    opt_create,
55
    opt_defines,
56
    opt_dry_run,
57
    opt_file,
58
    opt_filelist,
59
    opt_filepath,
60
    opt_local,
61
    opt_maxlevel,
62
    opt_maxworkers,
63
    opt_path,
64
    opt_show_diff,
65
    opt_tag,
66
    opt_target,
67
    opt_topsfile,
68
    read_file,
69
)
70
from .consts import PATH
8✔
71
from .create import TB_MAP, TYPE_CHOICES, CreateInfo
8✔
72
from .create import create as create_
8✔
73
from .fileset import FileSet
8✔
74
from .finder import find
8✔
75
from .generate import Generator, clean, get_makolator, render_generate, render_inplace
8✔
76
from .iterutil import namefilter
8✔
77
from .loader import load
8✔
78
from .modfilelist import iter_modfilelists
8✔
79
from .modtopref import PAT_TOPMODREF, TopModRef
8✔
80
from .pathutil import relative
8✔
81
from .top import Top
8✔
82
from .util import LOGGER, guess_path
8✔
83

84
patch()
8✔
85

86

87
_LOGLEVELMAP = {
8✔
88
    0: logging.WARNING,
89
    1: logging.INFO,
90
    2: logging.DEBUG,
91
}
92

93

94
class Ctx(BaseModel):
8✔
95
    """Command Line Context."""
96

97
    model_config = ConfigDict(
8✔
98
        arbitrary_types_allowed=True,
99
    )
100

101
    console: Console
8✔
102
    has_error_handler: HasErrorHandler | None = None
8✔
103

104
    verbose: int = 0
8✔
105
    no_cache: bool = False
8✔
106
    no_color: bool | None = None
8✔
107

108
    @staticmethod
8✔
109
    def create(no_color: bool | None = None, **kwargs) -> "Ctx":
8✔
110
        """Create."""
111
        console = Console(log_time=False, log_path=False, no_color=no_color)
8✔
112
        has_error_handler = HasErrorHandler()
8✔
113
        return Ctx(console=console, has_error_handler=has_error_handler, no_color=no_color, **kwargs)
8✔
114

115
    def __enter__(self):
8✔
116
        # Logging
117
        level = _LOGLEVELMAP.get(self.verbose, logging.DEBUG)
8✔
118
        if not self.no_color:
8✔
119
            handler = RichHandler(
×
120
                show_time=False,
121
                show_path=False,
122
                rich_tracebacks=True,
123
                console=Console(stderr=True, no_color=self.no_color),
124
            )
125
            format_ = "%(message)s"
×
126
        else:
127
            handler = StreamHandler(stream=sys.stderr)
8✔
128
            format_ = "%(levelname)s %(message)s"
8✔
129
        handlers = [handler, self.has_error_handler]
8✔
130
        logging.basicConfig(level=level, format=format_, handlers=handlers)
8✔
131

132
        # Cache
133
        if self.no_cache:
8✔
134
            CACHE.disable()
×
135

136
        return self
8✔
137

138
    def __exit__(self, exc_type, exc_value, tb):
8✔
139
        if exc_type or self.has_error_handler.has_errors:
8✔
140
            if exc_type is KeyboardInterrupt:
8✔
141
                self.console.print("[red]Aborted.")
×
142
            else:
143
                self.console.print("[red][bold]Failed.")
8✔
144
            sys.exit(1)
8✔
145

146

147
@click.group(cls=MainGroup, context_settings={"help_option_names": ["-h", "--help"]})
8✔
148
@click.option("-v", "--verbose", count=True, help="Increase Verbosity.")
8✔
149
@click.option("-C", "--no-cache", is_flag=True, help="Disable Caching.")
8✔
150
@click.option("--no-color", is_flag=True, help="Disable Coloring.", envvar="UCDP_NO_COLOR")
8✔
151
@click.version_option()
8✔
152
@click.pass_context
8✔
153
def ucdp(ctx, verbose=0, no_cache=False, no_color=False):
8✔
154
    """Unified Chip Design Platform."""
155
    ctx.obj = ctx.with_resource(Ctx.create(verbose=verbose, no_cache=no_cache, no_color=no_color))
8✔
156

157

158
pass_ctx = click.make_pass_decorator(Ctx)
8✔
159

160

161
def get_group(help=None):  # pragma: no cover
162
    """Create Command Group."""
163

164
    @click.group(help=help)
165
    @click.pass_context
166
    def group(ctx):
167
        ctx.obj = Ctx(console=Console(log_time=False, log_path=False))
168

169
    return group
170

171

172
def load_top(ctx: Ctx, top: str | TopModRef, paths: Iterable[str | Path], quiet: bool = False) -> Top:
8✔
173
    """Load Top Module."""
174
    lpaths = [Path(path) for path in paths]
8✔
175
    # Check if top seems to be some kind of file path
176
    topmodref = TopModRef.cast(guess_path(top) or top) if isinstance(top, str) else top
8✔
177
    if quiet:
8✔
178
        return load(topmodref, paths=lpaths)
8✔
179
    with ctx.console.status(f"Loading '{topmodref!s}'"):
8✔
180
        result = load(topmodref, paths=lpaths)
8✔
181
    ctx.console.log(f"'{topmodref!s}' checked.")
8✔
182
    return result
8✔
183

184

185
@ucdp.command(
8✔
186
    help=f"""
187
Load Data Model and Check.
188

189
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
190
"""
191
)
192
@arg_top
8✔
193
@opt_path
8✔
194
@click.option("--stat", default=False, is_flag=True, help="Show Statistics.")
8✔
195
@pass_ctx
8✔
196
def check(ctx, top, path, stat=False):
8✔
197
    """Check."""
198
    top = load_top(ctx, top, path)
8✔
199
    if stat:
8✔
200
        print("Statistics:")
8✔
201
        for name, value in top.get_stat().items():
8✔
202
            print(f"  {name}: {value}")
8✔
203

204

205
@ucdp.command(
8✔
206
    help=f"""
207
Load Data Model and Generate Files.
208

209
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
210
"""
211
)
212
@arg_tops
8✔
213
@opt_path
8✔
214
@opt_filelist
8✔
215
@opt_target
8✔
216
@opt_show_diff
8✔
217
@opt_maxworkers
8✔
218
@opt_defines
8✔
219
@opt_local
8✔
220
@opt_topsfile
8✔
221
@opt_check
8✔
222
@opt_create
8✔
223
@pass_ctx
8✔
224
def gen(
8✔
225
    ctx,
226
    tops,
227
    path,
228
    filelist,
229
    target=None,
230
    show_diff=False,
231
    maxworkers=None,
232
    define=None,
233
    local=None,
234
    check=False,
235
    create=False,
236
    tops_file=None,
237
):
238
    """Generate."""
239
    tops = list(tops)
8✔
240
    for filepath in tops_file or []:
8✔
241
        tops.extend(read_file(filepath))
8✔
242
    makolator = get_makolator(show_diff=show_diff, paths=path, create=create)
8✔
243
    data = defines2data(define)
8✔
244
    filelist = filelist or ["*"]
8✔
245
    with Generator(makolator=makolator, maxworkers=maxworkers, check=check) as generator:
8✔
246
        for info in find(path, patterns=tuple(tops), local=local, is_top=True):
8✔
247
            try:
8✔
248
                top = load_top(ctx, info.topmodref, path)
8✔
249
            except Exception as exc:
×
250
                LOGGER.warning(f"Cannot load '{info.topmodref}'")
×
251
                LOGGER.warning(str(exc))
×
252
                LOGGER.warning(f"Debug with 'ucdp check {info.topmodref}'")
×
253
                continue
×
254
            for item in filelist:
8✔
255
                generator.generate(top, item, target=target, data=data)
8✔
256

257

258
@ucdp.command(
8✔
259
    help=f"""
260
Load Data Model and Render Template and Create File.
261

262
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
263

264
TEMPLATE_FILEPATHS: Templates to render. Environment Variable 'UCDP_TEMPLATE_FILEPATHS'
265
                    Templates in `templates` folders are found automatically.
266

267
GENFILE: Generated File.
268
"""
269
)
270
@arg_top
8✔
271
@opt_path
8✔
272
@arg_template_filepaths
8✔
273
@click.argument("genfile", type=PathType, shell_complete=auto_path, nargs=1)
8✔
274
@opt_show_diff
8✔
275
@opt_defines
8✔
276
@opt_create
8✔
277
@pass_ctx
8✔
278
def rendergen(ctx, top, path, template_filepaths, genfile, show_diff=False, define=None, create=False):
8✔
279
    """Render Generate."""
280
    top = load_top(ctx, top, path)
8✔
281
    makolator = get_makolator(show_diff=show_diff, paths=path, create=create)
8✔
282
    data = defines2data(define)
8✔
283
    render_generate(top, template_filepaths, genfile=genfile, makolator=makolator, data=data)
8✔
284

285

286
@ucdp.command(
8✔
287
    help=f"""
288
Load Data Model and Render Template and Update File.
289

290
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
291

292
TEMPLATE_FILEPATHS: Templates to render. Environment Variable 'UCDP_TEMPLATE_FILEPATHS'
293
                    Templates in `templates` folders are found automatically.
294

295
INPLACEFILE: Inplace File.
296
"""
297
)
298
@arg_top
8✔
299
@opt_path
8✔
300
@arg_template_filepaths
8✔
301
@click.argument("inplacefile", type=PathType, shell_complete=auto_path, nargs=1)
8✔
302
@opt_show_diff
8✔
303
@opt_defines
8✔
304
@opt_create
8✔
305
@click.option("--ignore_unknown", "-i", default=False, is_flag=True, help="Ignore Unknown Placeholder.")
8✔
306
@pass_ctx
8✔
307
def renderinplace(
8✔
308
    ctx, top, path, template_filepaths, inplacefile, show_diff=False, define=None, ignore_unknown=False, create=False
309
):
310
    """Render Inplace."""
311
    top = load_top(ctx, top, path)
8✔
312
    makolator = get_makolator(show_diff=show_diff, paths=path, create=create)
8✔
313
    data = defines2data(define)
8✔
314
    render_inplace(
8✔
315
        top,
316
        template_filepaths,
317
        inplacefile=inplacefile,
318
        makolator=makolator,
319
        data=data,
320
        ignore_unknown=ignore_unknown,
321
    )
322

323

324
@ucdp.command(
8✔
325
    help=f"""
326
Load Data Model and REMOVE Generated Files.
327

328
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
329
"""
330
)
331
@arg_top
8✔
332
@opt_path
8✔
333
@opt_filelist
8✔
334
@opt_target
8✔
335
@opt_show_diff
8✔
336
@opt_dry_run
8✔
337
@opt_maxworkers
8✔
338
@pass_ctx
8✔
339
def cleangen(ctx, top, path, filelist, target=None, show_diff=False, maxworkers=None, dry_run=False):
8✔
340
    """Clean Generated Files."""
341
    top = load_top(ctx, top, path)
8✔
342
    makolator = get_makolator(show_diff=show_diff, paths=path)
8✔
343
    for item in filelist or ["*"]:
8✔
344
        clean(top, item, target=target, makolator=makolator, maxworkers=maxworkers, dry_run=dry_run)
8✔
345

346

347
@ucdp.command(
8✔
348
    help=f"""
349
Load Data Model and Generate File List.
350

351
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
352
"""
353
)
354
@arg_top
8✔
355
@opt_path
8✔
356
@opt_filelist
8✔
357
@opt_target
8✔
358
@opt_file
8✔
359
@pass_ctx
8✔
360
def filelist(ctx, top, path, filelist, target=None, file=None):
8✔
361
    """File List."""
362
    # Load quiet, otherwise stdout is messed-up
363
    top = load_top(ctx, top, path, quiet=True)
8✔
364
    for item in filelist or ["*"]:
8✔
365
        fileset = FileSet.from_mod(top.mod, item, target=target)
8✔
366
        for line in fileset:
8✔
367
            print(line, file=file)
8✔
368

369

370
@ucdp.command(
8✔
371
    help=f"""
372
Load Data Model and Show File Information
373

374
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
375
"""
376
)
377
@arg_top
8✔
378
@opt_path
8✔
379
@opt_filelist
8✔
380
@opt_target
8✔
381
@opt_maxlevel
8✔
382
@click.option("--minimal", "-m", default=False, is_flag=True, help="Skip defaults.")
8✔
383
@opt_file
8✔
384
@pass_ctx
8✔
385
def fileinfo(ctx, top, path, filelist, target=None, maxlevel=None, minimal=False, file=None):
8✔
386
    """File List."""
387
    # Load quiet, otherwise stdout is messed-up
388
    top = load_top(ctx, top, path, quiet=True)
8✔
389
    console = Console(file=file) if file else ctx.console
8✔
390
    for item in filelist or ["*"]:
8✔
391
        data = defaultdict(list)
8✔
392
        for mod, modfilelist in iter_modfilelists(top.mod, item, target=target, maxlevel=maxlevel):
8✔
393
            data[str(mod)].append(modfilelist.model_dump(exclude_defaults=minimal))
8✔
394
        pprint(dict(data), indent_guides=False, console=console)
8✔
395

396

397
@ucdp.command(
8✔
398
    help="""
399
              List Available Data Models.
400

401
              PATTERN: Limit list to these modules only.
402

403
              Examples:
404

405
                ucdp ls
406

407
                ucdp ls -n
408

409
                ucdp ls glbl_lib*
410
              """
411
)
412
@arg_tops
8✔
413
@opt_path
8✔
414
@click.option("--names", "-n", default=False, is_flag=True, help="Just print names")
8✔
415
@click.option("--top/--no-top", "-t/-T", default=None, is_flag=True, help="List loadable top modules only.")
8✔
416
@click.option("--tb/--no-tb", "-b/-B", default=None, is_flag=True, help="List testbench modules only.")
8✔
417
@click.option("--generic-tb", "-g", default=False, is_flag=True, help="List Generic Testbench modules only.")
8✔
418
@opt_local
8✔
419
@click.option("--base", "-A", default=False, is_flag=True, help="Show Base Classes.")
8✔
420
@click.option("--filepath", "-f", default=False, is_flag=True, help="Show File Path.")
8✔
421
@click.option("--abs-filepath", "-F", default=False, is_flag=True, help="Show Absolute File Path.")
8✔
422
@opt_tag
8✔
423
@pass_ctx
8✔
424
def ls(  # noqa: C901
8✔
425
    ctx,
426
    path=None,
427
    tops=None,
428
    names=False,
429
    top=None,
430
    tb=None,
431
    local=None,
432
    generic_tb=False,
433
    tag=None,
434
    base=False,
435
    filepath=False,
436
    abs_filepath=False,
437
):
438
    """List Modules."""
439
    with ctx.console.status("Searching"):
8✔
440
        infos = find(path, patterns=tops or ["*"], local=local)
8✔
441
    if top is not None:
8✔
442
        infos = [info for info in infos if info.is_top == top]
8✔
443
    if tb is not None:
8✔
444
        infos = [info for info in infos if bool(info.tb) == tb]
8✔
445
    if generic_tb:
8✔
446
        infos = [info for info in infos if info.tb == "Generic"]
8✔
447
    if tag:
8✔
448
        filter_ = namefilter(tag)
8✔
449
        infos = [info for info in infos if any(filter_(tag) for tag in info.tags)]
8✔
450

451
    def fill_row(row, info):
8✔
452
        if base:
8✔
453
            row.append(info.modbasecls.__name__)
8✔
454
        if filepath:
8✔
455
            row.append(str(relative(info.filepath)))
8✔
456
        if abs_filepath:
8✔
457
            row.append(str(info.filepath))
8✔
458

459
    if names:
8✔
460
        for info in infos:
8✔
461
            row = [info.topmodref]
8✔
462
            fill_row(row, info)
8✔
463
            print(*row)
8✔
464
    else:
465
        table = Table(expand=filepath or abs_filepath)
8✔
466
        table.add_column("Reference")
8✔
467
        table.add_column("Top", justify="center")
8✔
468
        table.add_column("Tb ", justify="center")
8✔
469
        table.add_column("Tags")
8✔
470
        if base:
8✔
471
            table.add_column("Bases on", justify="right")
8✔
472
        if filepath:
8✔
473
            table.add_column("Filepath")
×
474
        if abs_filepath:
8✔
475
            table.add_column("Absolute Filepath")
×
476
        for info in infos:
8✔
477
            row = [
8✔
478
                str(info.topmodref),
479
                "X" if info.is_top else "",
480
                "X" if info.tb else "",
481
                ",".join(sorted(info.tags)),
482
            ]
483
            fill_row(row, info)
8✔
484
            table.add_row(*row)
8✔
485
        ctx.console.print(table)
8✔
486

487

488
@ucdp.command(
8✔
489
    help=f"""
490
Load Data Model and Module Information.
491

492
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
493
"""
494
)
495
@arg_tops
8✔
496
@opt_path
8✔
497
@opt_local
8✔
498
@click.option("--top", "-t", default=None, is_flag=True, help="List loadable top modules only.")
8✔
499
@click.option("--sub", "-S", default=False, is_flag=True, help="Show Submodules.")
8✔
500
@pass_ctx
8✔
501
def modinfo(ctx, tops, path, local, top, sub):
8✔
502
    """Module Information."""
503
    sep = ""
8✔
504
    for info in find(path, patterns=tops, local=local, is_top=top):
8✔
505
        try:
8✔
506
            top = load_top(ctx, info.topmodref, path, quiet=True)
8✔
507
        except Exception as exc:
8✔
508
            LOGGER.warning(str(exc))
8✔
509
            continue
8✔
510
        print(sep + top.mod.get_info(sub=sub))
8✔
511
        sep = "\n\n"
8✔
512

513

514
@ucdp.command(
8✔
515
    help=f"""
516
Load Data Model and Show Module Overview.
517

518
TOP: Top Module. {PAT_TOPMODREF}. Environment Variable 'UCDP_TOP'
519
"""
520
)
521
@arg_top
8✔
522
@opt_path
8✔
523
@click.option("--minimal", "-m", default=False, is_flag=True, help="Skip modules without specific details")
8✔
524
@opt_filepath
8✔
525
@opt_tag
8✔
526
@pass_ctx
8✔
527
def overview(ctx, top, path, minimal=False, file=None, tag=None):
8✔
528
    """Overview."""
529
    # Load quiet, otherwise stdout is messed-up
530
    top = load_top(ctx, top, path, quiet=True)
8✔
531
    data = {"minimal": minimal, "tags": tag}
8✔
532
    render_generate(top, [PATH / "ucdp-templates" / "overview.txt.mako"], genfile=file, data=data, no_stat=True)
8✔
533

534

535
@ucdp.group(context_settings={"help_option_names": ["-h", "--help"]})
8✔
536
def info():
8✔
537
    """Information."""
538

539

540
@info.command()
8✔
541
@pass_ctx
8✔
542
def examples(ctx):
8✔
543
    """Path to Examples."""
544
    examples_path = Path(__file__).parent / "examples"
8✔
545
    print(str(examples_path))
8✔
546

547

548
@info.command()
8✔
549
@opt_path
8✔
550
@pass_ctx
8✔
551
def template_paths(ctx, path):
8✔
552
    """Template Paths."""
553
    makolator = get_makolator(paths=path)
8✔
554
    for template_path in makolator.config.template_paths:
8✔
555
        print(str(template_path))
8✔
556

557

558
@ucdp.command(
8✔
559
    help="""
560
Create Datamodel Skeleton.
561
"""
562
)
563
@click.option("--name", "-n", prompt=True, help="Name of the Module")
8✔
564
@click.option("--library", "-l", prompt=True, help="Name of the Library")
8✔
565
@click.option("--regf/--no-regf", "-r/-R", default=True, help="Make use of a Register File")
8✔
566
@click.option("--descr", "-d", default="", help="Description")
8✔
567
@click.option("--flavour", "-F", type=click.Choice(TYPE_CHOICES, case_sensitive=False), help="Choose a Module Flavour")
8✔
568
@click.option("--tb/--no-tb", "-t/-T", default=None, help="Create testbench for design module")
8✔
569
@click.option("--force", "-f", is_flag=True, help="Overwrite existing files")
8✔
570
@pass_ctx
8✔
571
def create(
8✔
572
    ctx,
573
    name,
574
    library,
575
    regf,
576
    descr,
577
    flavour,
578
    tb,
579
    force,
580
):
581
    """Let The User Type In The Name And Library Of The File."""
582
    if flavour is None:
×
583
        flavour = prompt_flavour()
×
584

585
    info = CreateInfo(name=name, library=library, regf=regf, descr=descr, flavour=flavour)
×
586

NEW
587
    if not info.is_tb:
×
NEW
588
        if tb is None:
×
NEW
589
            answer = click.prompt(
×
590
                "Do you want to create a corresponding testbench? (y)es. (n)o.",
591
                type=click.Choice(["y", "n"]),
592
                default="y",
593
            )
NEW
594
            tb = answer == "y"
×
NEW
595
        if tb:
×
NEW
596
            tbinfo = CreateInfo(name=f"{name}_tb", library=library, regf=regf, descr=descr, flavour=TB_MAP[flavour])
×
NEW
597
            create_(tbinfo, force)
×
NEW
598
    create_(info, force)
×
599

600

601
Type = Literal["AConfigurableMod", "AConfigurableTbMod", "AGenericTbMod", "AMod", "ATailoredMod", "ATbMod"]
8✔
602

603

604
def prompt_flavour() -> Type:
8✔
605
    """Let The User Choose The Type Of The File."""
606
    answer = click.prompt("Do you want to build a (d)esign or (t)estbench?", type=click.Choice(["d", "t"]), default="d")
×
607
    if answer == "d":
×
608
        answer = click.prompt(
×
609
            "Does your design vary more than what `parameter` can cover? (y)es. (n)o.", type=click.Choice(["y", "n"])
610
        )
611
        if answer == "y":
×
612
            answer = click.prompt(
×
613
                "Do you want to use a (c)onfig or (t) shall the parent module tailor the functionality?",
614
                type=click.Choice(["c", "t"]),
615
            )
616
            if answer == "c":
×
617
                flavour_ = "AConfigurableMod"
×
618

619
            else:
620
                flavour_ = "ATailoredMod"
×
621

622
        else:
623
            flavour_ = "AMod"
×
624

625
    else:
626
        answer = click.prompt(
×
627
            "Do you want to build a generic testbench which tests similar modules? (y)es. (n)o.",
628
            type=click.Choice(["y", "n"]),
629
        )
630
        if answer == "y":
×
631
            answer = click.prompt(
×
632
                "Do you want to automatically adapt your testbench to your (g) dut or use a (c)onfig?",
633
                type=click.Choice(["g", "c"]),
634
            )
635
            if answer == "c":
×
636
                flavour_ = "AConfigurableTbMod"
×
637

638
            else:
639
                flavour_ = "AGenericTbMod"
×
640

641
        else:
642
            flavour_ = "ATbMod"
×
643

644
    return flavour_
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc