Skip to content

Commit f3ff956

Browse files
georgkrylovjeanlego
authored andcommitted
ODIN_II: enabling complex synthesis through command line arguments.
This commit enables mixing hard and soft logic implementation as part of the flow by defining a global reference to the mixing optimization con- troller and doing changes to partial mapping stage to defer mapping of hard multipliers. The commit also introduces command line arguments and their default values, enabling to use the optimization. Signed-off-by: Georgiy Krylov <[email protected]>
1 parent a304b42 commit f3ff956

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

ODIN_II/SRC/include/odin_globals.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "odin_types.h"
55
#include "string_cache.h"
66
#include "read_xml_arch_file.h"
7+
#include "HardSoftLogicMixer.hpp"
78

89
extern t_logical_block_type* type_descriptors;
910

@@ -46,4 +47,9 @@ extern netlist_t* blif_netlist;
4647
/* Global variable for read_blif function call */
4748
extern netlist_t* read_blif_netlist;
4849

50+
/* logic optimization mixer, once ODIN is classy, could remove that
51+
* and pass as member variable
52+
*/
53+
extern HardSoftLogicMixer* mixer;
54+
4955
#endif

ODIN_II/SRC/include/odin_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ struct global_args_t {
141141
argparse::ArgValue<int> sim_random_seed;
142142

143143
argparse::ArgValue<bool> interactive_simulation;
144+
145+
// Arguments for mixing hard and soft logic
146+
argparse::ArgValue<int> exact_mults;
147+
argparse::ArgValue<float> mults_ratio;
144148
};
145149

146150
/**

ODIN_II/SRC/odin_ii.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include "vtr_util.h"
6262
#include "vtr_path.h"
6363
#include "vtr_memory.h"
64+
#include "HardSoftLogicMixer.hpp"
6465

6566
#define DEFAULT_OUTPUT "."
6667

@@ -73,6 +74,7 @@ std::vector<t_logical_block_type> logical_block_types;
7374
short physical_lut_size = -1;
7475
int block_tag = -1;
7576
ids default_net_type = WIRE;
77+
HardSoftLogicMixer* mixer;
7678

7779
enum ODIN_ERROR_CODE {
7880
SUCCESS,
@@ -165,6 +167,7 @@ static ODIN_ERROR_CODE synthesize_verilog() {
165167
/* point where we convert netlist to FPGA or other hardware target compatible format */
166168
printf("Performing Partial Map to target device\n");
167169
partial_map_top(verilog_netlist);
170+
mixer->perform_optimizations(verilog_netlist);
168171

169172
/* Find any unused logic in the netlist and remove it */
170173
remove_unused_logic(verilog_netlist);
@@ -217,7 +220,7 @@ netlist_t* start_odin_ii(int argc, char** argv) {
217220
printf("Odin failed to initialize %s with exit code%d\n", vtr_error.what(), ERROR_INITIALIZATION);
218221
exit(ERROR_INITIALIZATION);
219222
}
220-
223+
mixer = new HardSoftLogicMixer();
221224
try {
222225
/* Set up the global arguments to their default. */
223226
set_default_config();
@@ -322,7 +325,7 @@ netlist_t* start_odin_ii(int argc, char** argv) {
322325
printf("\n");
323326
printf("Odin ran with exit status: %d\n", SUCCESS);
324327
fflush(stdout);
325-
328+
delete mixer;
326329
return odin_netlist;
327330
}
328331

@@ -548,6 +551,18 @@ void get_options(int argc, char** argv) {
548551
.nargs('+')
549552
.metavar("PINS_TO_MONITOR");
550553

554+
auto& mixing_opt_grp = parser.add_argument_group("mixing hard and soft logic optimization");
555+
556+
mixing_opt_grp.add_argument(global_args.exact_mults, "--exact_mults")
557+
.help("To enable mixing hard block and soft logic implementation of adders")
558+
.default_value("-1")
559+
.action(argparse::Action::STORE);
560+
561+
mixing_opt_grp.add_argument(global_args.mults_ratio, "--mults_ratio")
562+
.help("To enable mixing hard block and soft logic implementation of adders")
563+
.default_value("-1.0")
564+
.action(argparse::Action::STORE);
565+
551566
parser.parse_args(argc, argv);
552567

553568
//Check required options
@@ -607,6 +622,13 @@ void get_options(int argc, char** argv) {
607622
if (global_args.permissive.value()) {
608623
warning_message(PARSE_ARGS, unknown_location, "%s", "Permissive flag is ON. Undefined behaviour may occur\n");
609624
}
625+
if (global_args.mults_ratio >= 0.0 && global_args.mults_ratio <= 1.0) {
626+
delete mixer->_opts[MULTIPLY];
627+
mixer->_opts[MULTIPLY] = new MultsOpt(global_args.mults_ratio);
628+
} else if (global_args.exact_mults >= 0) {
629+
delete mixer->_opts[MULTIPLY];
630+
mixer->_opts[MULTIPLY] = new MultsOpt(global_args.exact_mults);
631+
}
610632
}
611633

612634
/*---------------------------------------------------------------------------

ODIN_II/SRC/partial_map.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,7 @@ void partial_map_node(nnode_t* node, short traverse_number, netlist_t* netlist)
221221
instantiate_multi_port_mux(node, traverse_number, netlist);
222222
break;
223223
case MULTIPLY: {
224-
int mult_size = std::max<int>(node->input_port_sizes[0], node->input_port_sizes[1]);
225-
if (hard_multipliers && mult_size >= min_mult) {
226-
instantiate_hard_multiplier(node, traverse_number, netlist);
227-
} else if (!hard_adders) {
228-
instantiate_simple_soft_multiplier(node, traverse_number, netlist);
229-
}
224+
mixer->partial_map_node(node, traverse_number, netlist);
230225
break;
231226
}
232227
case MEMORY: {

0 commit comments

Comments
 (0)