forked from casper-astro/mlib_devel
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathjasper_frontend.m
102 lines (81 loc) · 3.3 KB
/
jasper_frontend.m
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
function build_cmd = jasper_frontend(model)
if nargin > 0
load_system(model);
end
sys = bdroot;
modelpath = get_param(sys, 'filename');
[modeldir, modelname, ~] = fileparts(modelpath);
builddir = [modeldir '/' modelname];
fprintf('Starting jasper for model: %s\n', modelname);
fprintf('Build directory: %s\n', builddir);
if exist(builddir, 'dir') ~= 7
mkdir(modeldir, modelname);
end
disp('Checking Mezzanine block sites');
hmc_blks = find_system(gcs, 'SearchDepth', 10, 'LookUnderMasks', 'all', 'Tag', 'xps:hmc');
mez_sites = get_param(hmc_blks, 'mez');
if length(mez_sites) ~= length(unique(mez_sites))
sitestr = '';
for ctr = 1 : length(mez_sites)
sitestr = sprintf('%s\n\t%s - %s', sitestr, hmc_blks{ctr}, mez_sites{ctr});
end
error('ERROR: Mezzanine blocks set to use same sites:\n%s', sitestr);
end
disp('Updating diagram');
set_param(sys, 'SimulationCommand', 'update');
disp('Generating peripherals file');
gen_block_file(builddir, [builddir '/jasper.per'])
% Generate the design_info.tab file, which is used to populate the fpg
% header file
mssge.xps_path = builddir;
gen_xps_add_design_info(sys, mssge, '/');
% read the git repo info and write this information to "git_info.tab" for
% the fpg file header
gitinfo_id=fopen([builddir '/git_info.tab'], 'w');
git_write_info(gitinfo_id, sys);
fclose(gitinfo_id);
jasper_python = [getenv('MLIB_DEVEL_PATH') '/jasper_library/exec_flow.py'];
% run the jasper flow but skip
% 1) peripheral file generation (this script does this already)
% 2) design_info.tab file generation (this script does this already)
% 3) git_info.tab file generation (this script does this already)
% 4) frontend compile (this script starts system generator itself below)
% 5) backend compile (the user should launch this afterwards from outside
% matlab)
disp('Launching jasper flow middleware');
% rv = system([jasper_python ' -m' modelpath ' -c' builddir ' --skipyb --skipfe --skipbe']);
rv = system(['python ' jasper_python ' -m' modelpath ' -c' builddir '']);
if rv ~= 0
fprintf('ERROR: see %s/jasper.log for details\n', builddir);
return;
end
disp('Launching System Generator compile');
update_model = 0;
xsg_result = start_sysgen_compile(modelpath, builddir, update_model);
if xsg_result ~= 0
error('XSG generation failed!')
end
% figure out what the version of python being used by the toolflow is
[status, result] = system('which python');
if status ~= 0
python_path = 'python';
else
python_path = strtrim(result);
end
% if vivado is to be used
build_cmd = '';
if strcmp(getenv('JASPER_BACKEND'), 'vivado')
build_cmd = [python_path ' ' jasper_python ' -m ' modelpath ' --middleware --backend --software'];
elseif strcmp(getenv('JASPER_BACKEND'), 'vitis')
build_cmd = [python_path ' ' jasper_python ' -m ' modelpath ' --middleware --backend --software --vitis'];
elseif strcmp(getenv('JASPER_BACKEND'), 'ise')
build_cmd = [python_path ' ' jasper_python ' -m ' modelpath ' --middleware --backend --software --be ise'];
end
disp('************************************');
disp('* Front End compile complete *');
disp('************************************');
disp('');
disp('To complete your compile, run the following command in a terminal.');
disp('Remember to source `startsg` with an appropriate `startsg.local` environment first!');
disp(build_cmd);
% end