2020-02-12 18:53:23 -06:00
|
|
|
/********************************************************************
|
|
|
|
* This file includes the main function to build module graphs
|
|
|
|
* for the FPGA fabric
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
/* Headers from vtrutil library */
|
|
|
|
#include "vtr_assert.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
#include "vtr_time.h"
|
|
|
|
|
2020-07-06 17:42:33 -05:00
|
|
|
/* Headers from openfpgashell library */
|
|
|
|
#include "command_exit_codes.h"
|
|
|
|
|
2020-02-12 18:53:23 -06:00
|
|
|
#include "build_essential_modules.h"
|
2020-02-12 19:28:50 -06:00
|
|
|
#include "build_decoder_modules.h"
|
2020-02-12 20:45:14 -06:00
|
|
|
#include "build_mux_modules.h"
|
2020-02-12 20:52:41 -06:00
|
|
|
#include "build_lut_modules.h"
|
2020-02-12 20:57:15 -06:00
|
|
|
#include "build_wire_modules.h"
|
2020-02-12 21:06:38 -06:00
|
|
|
#include "build_memory_modules.h"
|
2020-02-13 16:27:16 -06:00
|
|
|
#include "build_grid_modules.h"
|
2020-02-13 18:35:29 -06:00
|
|
|
#include "build_routing_modules.h"
|
2020-02-15 15:13:32 -06:00
|
|
|
#include "build_top_module.h"
|
2020-02-12 18:53:23 -06:00
|
|
|
#include "build_device_module.h"
|
|
|
|
|
|
|
|
/* begin namespace openfpga */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* The main function to be called for building module graphs
|
|
|
|
* for a FPGA fabric
|
|
|
|
*******************************************************************/
|
2020-07-06 17:42:33 -05:00
|
|
|
int build_device_module_graph(ModuleManager& module_manager,
|
|
|
|
IoLocationMap& io_location_map,
|
|
|
|
DecoderLibrary& decoder_lib,
|
|
|
|
const OpenfpgaContext& openfpga_ctx,
|
|
|
|
const DeviceContext& vpr_device_ctx,
|
|
|
|
const bool& frame_view,
|
|
|
|
const bool& compress_routing,
|
|
|
|
const bool& duplicate_grid_pin,
|
|
|
|
const FabricKey& fabric_key,
|
|
|
|
const bool& generate_random_fabric_key,
|
|
|
|
const bool& verbose) {
|
2020-02-12 18:53:23 -06:00
|
|
|
vtr::ScopedStartFinishTimer timer("Build fabric module graph");
|
|
|
|
|
2020-07-06 17:42:33 -05:00
|
|
|
int status = CMD_EXEC_SUCCESS;
|
2020-02-12 18:53:23 -06:00
|
|
|
|
|
|
|
CircuitModelId sram_model = openfpga_ctx.arch().config_protocol.memory_model();
|
|
|
|
VTR_ASSERT(true == openfpga_ctx.arch().circuit_lib.valid_model_id(sram_model));
|
|
|
|
|
|
|
|
/* Add constant generator modules: VDD and GND */
|
|
|
|
build_constant_generator_modules(module_manager);
|
|
|
|
|
|
|
|
/* Register all the user-defined modules in the module manager
|
|
|
|
* This should be done prior to other steps in this function,
|
|
|
|
* because they will be instanciated by other primitive modules
|
|
|
|
*/
|
|
|
|
build_user_defined_modules(module_manager, openfpga_ctx.arch().circuit_lib);
|
|
|
|
|
|
|
|
/* Build elmentary modules */
|
|
|
|
build_essential_modules(module_manager, openfpga_ctx.arch().circuit_lib);
|
|
|
|
|
|
|
|
/* Build local encoders for multiplexers, this MUST be called before multiplexer building */
|
2020-02-12 19:28:50 -06:00
|
|
|
build_mux_local_decoder_modules(module_manager, openfpga_ctx.mux_lib(),
|
|
|
|
openfpga_ctx.arch().circuit_lib);
|
2020-02-12 18:53:23 -06:00
|
|
|
|
|
|
|
/* Build multiplexer modules */
|
2020-02-12 20:45:14 -06:00
|
|
|
build_mux_modules(module_manager, openfpga_ctx.mux_lib(), openfpga_ctx.arch().circuit_lib);
|
2020-02-12 18:53:23 -06:00
|
|
|
|
|
|
|
/* Build LUT modules */
|
2020-02-12 20:52:41 -06:00
|
|
|
build_lut_modules(module_manager, openfpga_ctx.arch().circuit_lib);
|
2020-02-12 18:53:23 -06:00
|
|
|
|
|
|
|
/* Build wire modules */
|
2020-02-12 20:57:15 -06:00
|
|
|
build_wire_modules(module_manager, openfpga_ctx.arch().circuit_lib);
|
2020-02-12 18:53:23 -06:00
|
|
|
|
|
|
|
/* Build memory modules */
|
2020-05-25 23:15:16 -05:00
|
|
|
build_memory_modules(module_manager,
|
|
|
|
decoder_lib,
|
|
|
|
openfpga_ctx.mux_lib(),
|
2020-02-12 21:06:38 -06:00
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
openfpga_ctx.arch().config_protocol.type());
|
2020-02-12 18:53:23 -06:00
|
|
|
|
|
|
|
/* Build grid and programmable block modules */
|
2020-05-26 19:55:55 -05:00
|
|
|
build_grid_modules(module_manager,
|
|
|
|
decoder_lib,
|
|
|
|
vpr_device_ctx,
|
2020-02-13 16:27:16 -06:00
|
|
|
openfpga_ctx.vpr_device_annotation(),
|
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
openfpga_ctx.mux_lib(),
|
|
|
|
openfpga_ctx.arch().config_protocol.type(),
|
2020-02-13 16:38:26 -06:00
|
|
|
sram_model, duplicate_grid_pin, verbose);
|
2020-02-12 18:53:23 -06:00
|
|
|
|
2020-02-13 18:35:29 -06:00
|
|
|
if (true == compress_routing) {
|
|
|
|
build_unique_routing_modules(module_manager,
|
2020-05-26 19:55:55 -05:00
|
|
|
decoder_lib,
|
2020-02-13 18:35:29 -06:00
|
|
|
vpr_device_ctx,
|
|
|
|
openfpga_ctx.vpr_device_annotation(),
|
|
|
|
openfpga_ctx.device_rr_gsb(),
|
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
openfpga_ctx.arch().config_protocol.type(),
|
|
|
|
sram_model, verbose);
|
|
|
|
} else {
|
|
|
|
VTR_ASSERT_SAFE(false == compress_routing);
|
|
|
|
build_flatten_routing_modules(module_manager,
|
2020-05-26 19:55:55 -05:00
|
|
|
decoder_lib,
|
2020-02-13 18:35:29 -06:00
|
|
|
vpr_device_ctx,
|
|
|
|
openfpga_ctx.vpr_device_annotation(),
|
|
|
|
openfpga_ctx.device_rr_gsb(),
|
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
openfpga_ctx.arch().config_protocol.type(),
|
|
|
|
sram_model, verbose);
|
|
|
|
}
|
2020-02-12 18:53:23 -06:00
|
|
|
|
|
|
|
/* Build FPGA fabric top-level module */
|
2020-07-06 17:42:33 -05:00
|
|
|
status = build_top_module(module_manager,
|
|
|
|
io_location_map,
|
|
|
|
decoder_lib,
|
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
vpr_device_ctx.grid,
|
|
|
|
vpr_device_ctx.rr_graph,
|
|
|
|
openfpga_ctx.device_rr_gsb(),
|
|
|
|
openfpga_ctx.tile_direct(),
|
|
|
|
openfpga_ctx.arch().arch_direct,
|
|
|
|
openfpga_ctx.arch().config_protocol.type(),
|
|
|
|
sram_model,
|
|
|
|
frame_view, compress_routing, duplicate_grid_pin,
|
|
|
|
fabric_key, generate_random_fabric_key);
|
|
|
|
|
|
|
|
if (CMD_EXEC_FATAL_ERROR == status) {
|
|
|
|
return status;
|
|
|
|
}
|
2020-02-12 18:53:23 -06:00
|
|
|
|
|
|
|
/* Now a critical correction has to be done!
|
|
|
|
* In the module construction, we always use prefix of ports because they are binded
|
|
|
|
* to the ports in architecture description (logic blocks etc.)
|
|
|
|
* To interface with standard cell, we should
|
|
|
|
* rename the ports of primitive modules using lib_name instead of prefix
|
|
|
|
* (which have no children and are probably linked to a standard cell!)
|
|
|
|
*/
|
2020-02-15 15:13:32 -06:00
|
|
|
rename_primitive_module_port_names(module_manager, openfpga_ctx.arch().circuit_lib);
|
2020-02-12 18:53:23 -06:00
|
|
|
|
2020-07-06 17:42:33 -05:00
|
|
|
return status;
|
2020-02-12 18:53:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* end namespace openfpga */
|