-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathexamples.py
158 lines (137 loc) · 4.79 KB
/
examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
from typing import List
from os import environ
from pathlib import Path
from .project import Project
ROOT = Path(__file__).parent.parent
PRJ = Project(ROOT)
def Run(
board: str,
design: str,
top: str,
id: str,
board_srcs: List[str],
design_srcs: List[str],
verilog_srcs: List[str],
mem_srcs: List[str],
posargs: List[str],
) -> List[str]:
"""
Create command to call the make entrypoint 'setups/osflow/common.mk' for executing 'posargs' targets.
"""
cmd = [
"make",
"-C",
"setups/osflow",
"-f",
"common.mk",
"BOARD='{}'".format(board),
"DESIGN='{}'".format(design),
"BOARD_SRC='{}'".format(" ".join(board_srcs)),
"TOP='{}'".format(top),
"ID='{}'".format(id),
"DESIGN_SRC='{}'".format(" ".join(design_srcs)),
"NEORV32_MEM_SRC='{}'".format(" ".join(mem_srcs)),
]
if verilog_srcs is not None:
cmd.append("NEORV32_VERILOG_SRC='{}'".format(" ".join(verilog_srcs)))
cmd += posargs if posargs != [] else ["clean", "bit"]
return cmd
def Example(board: str, design: str, posargs: str) -> str:
"""
Call the 'Run' function to get the make command of a given example (Board and Design) for executing 'posargs' targets.
"""
if board not in PRJ.Boards:
raise Exception("Unknown board {}".format(board))
DesignSources = next(
(item for item in PRJ.Filesets.Designs if item.Name == design), None
)
if DesignSources == None:
raise Exception("Unknown design {}".format(design))
boardtop = "neorv32_{}_BoardTop_{}".format(board, design)
if not (ROOT / "setups/osflow" / PRJ.BoardsTops / "{}.vhd".format(boardtop)).exists():
raise Exception("BoardTop file {} does not exist!".format(boardtop))
# FIXME It should be possible to pass the command as a list, i.e., without converting it to a single string
return " ".join(
Run(
board=board,
design=design,
top=boardtop,
id=design,
board_srcs=["{}/{}.vhd".format(PRJ.BoardsTops, boardtop)],
design_srcs=DesignSources.VHDL,
verilog_srcs=DesignSources.Verilog,
mem_srcs=PRJ.GetMemorySources(board, design),
posargs=posargs,
)
)
# TODO Add a task to be executed after Example for moving the bitstream from setups/osflow/*.bit to somewhere else
# (maybe setups/examples or setups/examples/out)
#
# bitstream = "neorv32_{}{}_{}.bit".format(
# board,
# "_{}".format(PRJ.Board_Revisions[board]) if board in PRJ.Board_Revisions else "",
# design
# )
def GenerateExamplesJobMatrix():
print(
"::set-output name=matrix::"
+ str(
[
{
"board": "UPduino",
"design": "MinimalBoot",
"bitstream": "neorv32_UPduino_v3_MinimalBoot.bit",
},
{
"board": "UPduino",
"design": "UP5KDemo",
"bitstream": "neorv32_UPduino_v3_UP5KDemo.bit",
},
{
"board": "Fomu",
"design": "Minimal",
"bitstream": "neorv32_Fomu_pvt_Minimal.bit",
},
{
"board": "Fomu",
"design": "MinimalBoot",
"bitstream": "neorv32_Fomu_pvt_MinimalBoot.bit",
},
{
"board": "Fomu",
"design": "MixedLanguage",
"bitstream": "neorv32_Fomu_pvt_MixedLanguage.bit",
},
{
"board": "Fomu",
"design": "UP5KDemo",
"bitstream": "neorv32_Fomu_pvt_UP5KDemo.bit",
},
{
"board": "iCESugar",
"design": "Minimal",
"bitstream": "neorv32_iCESugar_Minimal.bit",
},
{
"board": "iCESugar",
"design": "MinimalBoot",
"bitstream": "neorv32_iCESugar_MinimalBoot.bit",
},
{
"board": "OrangeCrab",
"design": "MinimalBoot",
"bitstream": "neorv32_OrangeCrab_r02-25F_MinimalBoot.bit",
},
{
"board": "AlhambraII",
"design": "MinimalBoot",
"bitstream": "neorv32_AlhambraII_MinimalBoot.bit",
},
{
"board": "ULX3S",
"design": "MinimalBoot",
"bitstream": "neorv32_ULX3S_MinimalBoot.bit",
},
]
)
)