Skip to content

Commit a94b66d

Browse files
committed
Reorganized Autogen
vhdl folder has been renamed ipcore quartus folder has been moved from the vhdl/ipcore folder to the root directory of the repo Files not directly related vhdl/ipcore folder have been moved to the root Matlab wrappers of Python functions have been removed autogen_quartus no longer uses the DataplaneConfig class, instead it uses WorkflowConfig which is essentially a cut down version that only parses information used by the Quartus workflow. It does still use the same configuration file though in practice. All Python calls that currently have a command-line option are now called from Autogen via a system call using that interface
1 parent 5c21e72 commit a94b66d

30 files changed

+42
-154
lines changed
File renamed without changes.

vhdl/autogen_quartus.py renamed to autogen_quartus.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
import logging
44

5-
from dataplane_config import DataplaneConfig
5+
from quartus.workflow_config import WorkflowConfig
66
from quartus.quartus_workflow import execute_quartus_workflow
77

88

@@ -11,9 +11,9 @@ def main(inputFilename, working_dir, log_to_file=False):
1111
working_dir += "/"
1212
logger = init_logging(logging.INFO, log_to_file)
1313
try:
14-
dataplane_config = DataplaneConfig.parse_json(inputFilename)
14+
config = WorkflowConfig.parse_json(inputFilename)
1515
execute_quartus_workflow(
16-
dataplane_config.target_system, dataplane_config.custom_components, dataplane_config.clock_rate, working_dir)
16+
config.target_system, config.custom_components, config.clock_rate, working_dir)
1717
finally:
1818
logger.info("exit")
1919

device_drivers/genDeviceDriver.m

-30
This file was deleted.

device_drivers/genMakefile.m

-28
This file was deleted.
File renamed without changes.

vhdl/create_hw_tcl.py renamed to ipcore/create_hw_tcl.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ def parseargs():
266266
"""
267267
parser = argparse.ArgumentParser(
268268
description="Generates a Platform Design/Qsys component as _hw.tcl file")
269-
parser.add_argument('-j', '--json',
269+
parser.add_argument('-c', '--config',
270270
help="JSON file containing autogen configuration")
271271
parser.add_argument('-w', '--working-dir',
272-
help="Working directory to generate the Platform Design/Qsys component in")
272+
help="Working directory to generate the Platform Designer component in")
273273
parser.add_argument('-o', '--output-filename',
274274
help="Name of the output file, recommended to end in '_hw.tcl'")
275275
args = parser.parse_args()
276-
return (args.json, args.output_filename, args.working_dir)
276+
return (args.config, args.output_filename, args.working_dir)
277277

278278

279279
if __name__ == "__main__":

vhdl/dataplane_config.py renamed to ipcore/dataplane_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self):
3333

3434
self.compatible_flag = "Fill me in"
3535
self.group = "Fill me in"
36-
self.vendor = "fe"
36+
self.vendor = "al"
3737
self.target_system = ""
3838

3939
self.clock_rate = 0
File renamed without changes.
File renamed without changes.

vhdl/vgenAvalonWrapper.py renamed to ipcore/vgenAvalonWrapper.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,15 @@ def convert_default_value(value, datatype):
373373
def parseargs():
374374
parser = argparse.ArgumentParser(description=\
375375
"Generate VHDL code for Avalon streaming and memory-mapped interfaces.")
376-
parser.add_argument('infile',
376+
parser.add_argument('-c','--config_file',
377377
help="json file containing the interface and register specifications")
378378
parser.add_argument('-v', '--verbose', action='store_true',
379379
help="verbose output")
380380
parser.add_argument('-p', '--print', action='store_true', dest='print_output',
381381
help="print out the generated vhdl code")
382-
parser.add_argument('outfile', help="the name of the output vhdl file")
382+
parser.add_argument('-o', '--outfile', help="the name of the output vhdl file")
383383
args = parser.parse_args()
384-
return (args.infile, args.outfile, args.verbose, args.print_output)
384+
return (args.config_file, args.outfile, args.verbose, args.print_output)
385385

386386

387387
# TODO: make a default filename?
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

quartus/workflow_config.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
import math
3+
import os
4+
5+
class WorkflowConfig:
6+
def __init__(self):
7+
self.custom_components = []
8+
self.target_system = ""
9+
self.clock_rate = 0
10+
self.working_dir = ""
11+
12+
13+
@staticmethod
14+
def parse_json(inputFilename):
15+
with open(inputFilename, "r") as file:
16+
in_str = file.read()
17+
json_dict = json.loads(in_str)
18+
config = WorkflowConfig()
19+
20+
config.clock_rate = json_dict.get('clocks') and json_dict.get('clocks')['system_frequency_Hz']
21+
config.target_system = json_dict.get("target_system")
22+
config.custom_components = json_dict.get("custom_components") or [json_dict.get('model_name')]
23+
config.working_dir = json_dict.get("working_dir")
24+
return config
File renamed without changes.

vhdl/vgen_process_simulink_model.m renamed to vgen_process_simulink_model.m

+8-13
Original file line numberDiff line numberDiff line change
@@ -82,32 +82,30 @@
8282

8383
%% Generate the Avalon VHDL wrapper for the VHDL code generated by the HDL Coder
8484
disp('vgen: Creating Avalon VDHL wrapper.')
85-
infile = [avalon.entity '.json'];
85+
config_file = [avalon.entity '.json'];
8686
outfile = [hdlpath filesep avalon.entity '_avalon.vhd'];
87-
vgenAvalonWrapper(infile, outfile, false, false);
87+
system("python " + mp.ipcore_codegen_path + filesep + "vgenAvalonWrapper.py -c " + config_file + " -o " + outfile);
8888
disp([' created vhdl file: ' outfile])
8989

9090
%% Generate the .tcl script to be used by Platform Designer in Quartus
9191
disp('vgen: Creating .tcl script for Platform Designer.')
92-
config_file = [avalon.entity '.json'];
9392
% NOTE: platform designer only adds components if they have the _hw.tcl suffix
9493
outfile = [hdlpath filesep avalon.entity '_avalon_hw.tcl'];
9594
disp(['file ' config_file ' out ' outfile ' path ' hdlpath])
96-
vgenHwTcl(config_file, outfile, hdlpath)
97-
95+
system("python " + mp.ipcore_codegen_path + filesep + "create_hw_tcl.py -c " + config_file + " -w " + hdlpath + " -o " + outfile );
9896
disp([' created tcl file: ' outfile])
9997

10098
disp('vgen: Executing Quartus workflow')
10199
if ispc; second_cmd = "&"; else; second_cmd = ";"; end
102100
working_dir = hdlpath + "/quartus/";
103-
quartus_workflow_cmd = "python " + mp.vhdl_codegen_path + "/autogen_quartus.py -j " + config_file ...
101+
102+
quartus_workflow_cmd = "python " + mp.codegen_path + "/autogen_quartus.py -j " + config_file ...
104103
+ " -w " + working_dir + " -l " + second_cmd + " exit &";
105-
disp(quartus_workflow_cmd)
106104
system(quartus_workflow_cmd);
107105

106+
% Stream the Quartus workflow log and display it to the user
108107
fid = fopen("autogen_quartus.log");
109108
if fid>0
110-
% loop until end of file is reached
111109
while 1
112110
% read the current line
113111
where = ftell(fid);
@@ -122,22 +120,20 @@
122120
disp(line)
123121
end
124122
end
125-
% close the file
126123
fclose(fid);
127124
end
128125

129-
%disp("r: ---------------------------------------------------\n" + r)
130126
disp('Executed Quartus workflow')
131127

132128
%% Generate the device driver code
133129
disp('Creating device driver.')
134130
outfile = [hdlpath filesep mp.model_name '.c'];
135-
genDeviceDriver(infile, outfile)
131+
py.JsonToDriver.JsonToDriver(config_file, outfile)
136132
disp([' created device driver: ' outfile])
137133

138134
%% Generate kernel module build files
139135
disp('Creating Makefile and Kbuild.')
140-
genMakefile([hdlpath filesep], mp.model_name)
136+
system("python " + mp.driver_codegen_path + filesep + "gen_makefile.py " + [hdlpath filesep] + " " + mp.model_name);
141137
disp([' created Makefile: ' [hdlpath filesep 'Makefile']])
142138
disp([' created Kbuild: ' [hdlpath filesep 'Kbuild']])
143139

@@ -159,7 +155,6 @@
159155
end
160156

161157
% TODO: this file now generates C code, but "vgen" make it seem like it is just VHDL still. This should be changed, and the repository should be reorganized a bit.
162-
% This file shouldn't live in the vhdl folder anymore.
163158
%% Build Device Tree blob
164159
project_revision = mp.model_name + "_" + mp.target_system;
165160
sopcinfo_file = hdlpath + "/quartus/" + mp.target_system + '_system.sopcinfo';

vhdl/vgenAvalonWrapper.m

-36
This file was deleted.

vhdl/vgenHwTcl.m

-37
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)