From 091bbd4d9c96ea31e7c5c2ef08191aaee4b214e3 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Thu, 26 Sep 2019 22:53:07 -0600 Subject: [PATCH] start refactoring the num_config_bits for circuit model --- vpr7_x2p/vpr/SRC/device/mux_utils.cpp | 105 +++++++++++++++++- vpr7_x2p/vpr/SRC/device/mux_utils.h | 3 +- .../SRC/fpga_x2p/verilog/verilog_routing.c | 14 +-- 3 files changed, 105 insertions(+), 17 deletions(-) diff --git a/vpr7_x2p/vpr/SRC/device/mux_utils.cpp b/vpr7_x2p/vpr/SRC/device/mux_utils.cpp index dc153fcb9..9ac264997 100644 --- a/vpr7_x2p/vpr/SRC/device/mux_utils.cpp +++ b/vpr7_x2p/vpr/SRC/device/mux_utils.cpp @@ -271,18 +271,111 @@ size_t find_mux_num_reserved_config_bits(const CircuitLibrary& circuit_lib, } /************************************************** - * Find the number of configuration bits for a multiplexer + * Find the number of configuration bits for a CMOS multiplexer * In general, the number of configuration bits is * the number of memory bits for a mux_graph - * However, when local decoders are used, this should be changed! + * However, when local decoders are used, + * the number of configuration bits are reduced to log2(X) *************************************************/ -size_t find_mux_num_config_bits(const CircuitLibrary& circuit_lib, - const CircuitModelId& mux_model, - const MuxGraph& mux_graph) { +static +size_t find_cmos_mux_num_config_bits(const CircuitLibrary& circuit_lib, + const CircuitModelId& mux_model, + const MuxGraph& mux_graph, + const e_sram_orgz& sram_orgz_type) { + size_t num_config_bits = 0; + switch (sram_orgz_type) { + case SPICE_SRAM_MEMORY_BANK: + case SPICE_SRAM_SCAN_CHAIN: + case SPICE_SRAM_STANDALONE: + num_config_bits = mux_graph.num_memory_bits(); + break; + default: + vpr_printf(TIO_MESSAGE_ERROR, + "(FILE:%s,LINE[%d])Invalid type of SRAM organization!\n", + __FILE__, __LINE__); + exit(1); + } + if (true == circuit_lib.mux_use_local_encoder(mux_model)) { + num_config_bits = find_mux_local_decoder_addr_size(mux_graph.num_memory_bits()); + } + + return num_config_bits; +} + +/************************************************** + * Find the number of configuration bits for a RRAM multiplexer + * In general, the number of configuration bits is + * the number of levels for a mux_graph + * This is due to only the last BL/WL of the multiplexer is + * independent from each other + * However, when local decoders are used, + * the number of configuration bits should be consider all the + * shared(reserved) configuration bits and independent bits + *************************************************/ +static +size_t find_rram_mux_num_config_bits(const CircuitLibrary& circuit_lib, + const CircuitModelId& mux_model, + const MuxGraph& mux_graph, + const e_sram_orgz& sram_orgz_type) { + size_t num_config_bits = 0; + switch (sram_orgz_type) { + case SPICE_SRAM_MEMORY_BANK: + /* In memory bank, by intensively share the Bit/Word Lines, + * we only need 1 additional BL and WL for each MUX level. + */ + num_config_bits = mux_graph.num_levels(); + break; + case SPICE_SRAM_SCAN_CHAIN: + case SPICE_SRAM_STANDALONE: + /* Currently we DO NOT SUPPORT THESE, given an invalid number */ + num_config_bits = size_t(-1); + break; + default: + vpr_printf(TIO_MESSAGE_ERROR, + "(FILE:%s,LINE[%d])Invalid type of SRAM organization!\n", + __FILE__, __LINE__); + exit(1); + } + + if (true == circuit_lib.mux_use_local_encoder(mux_model)) { + /* TODO: this is a to-do work for ReRAM-based multiplexers and FPGAs + * The number of states of a local decoder only depends on how many + * memory bits that the multiplexer will have + * This may NOT be correct!!! + */ return find_mux_local_decoder_addr_size(mux_graph.num_memory_bits()); } - return mux_graph.num_memory_bits(); + return num_config_bits; } +/************************************************** + * Find the number of configuration bits for + * a routing multiplexer + * Two cases are considered here. + * They are placed in different branches (sub-functions) + * in order to be easy in extending to new technology! + *************************************************/ +size_t find_mux_num_config_bits(const CircuitLibrary& circuit_lib, + const CircuitModelId& mux_model, + const MuxGraph& mux_graph, + const e_sram_orgz& sram_orgz_type) { + size_t num_config_bits = size_t(-1); + + switch (circuit_lib.design_tech_type(mux_model)) { + case SPICE_MODEL_DESIGN_CMOS: + num_config_bits = find_rram_mux_num_config_bits(circuit_lib, mux_model, mux_graph, sram_orgz_type); + break; + case SPICE_MODEL_DESIGN_RRAM: + num_config_bits = find_rram_mux_num_config_bits(circuit_lib, mux_model, mux_graph, sram_orgz_type); + break; + default: + vpr_printf(TIO_MESSAGE_ERROR, + "(FILE:%s,LINE[%d])Invalid design_technology of MUX(name: %s)\n", + __FILE__, __LINE__, circuit_lib.model_name(mux_model).c_str()); + exit(1); + } + + return num_config_bits; +} diff --git a/vpr7_x2p/vpr/SRC/device/mux_utils.h b/vpr7_x2p/vpr/SRC/device/mux_utils.h index ee92cce49..9fa1f12ca 100644 --- a/vpr7_x2p/vpr/SRC/device/mux_utils.h +++ b/vpr7_x2p/vpr/SRC/device/mux_utils.h @@ -43,6 +43,7 @@ size_t find_mux_num_reserved_config_bits(const CircuitLibrary& circuit_lib, size_t find_mux_num_config_bits(const CircuitLibrary& circuit_lib, const CircuitModelId& mux_model, - const MuxGraph& mux_graph); + const MuxGraph& mux_graph, + const e_sram_orgz& sram_orgz_type); #endif diff --git a/vpr7_x2p/vpr/SRC/fpga_x2p/verilog/verilog_routing.c b/vpr7_x2p/vpr/SRC/fpga_x2p/verilog/verilog_routing.c index 6aa7ccb91..5499c61d8 100644 --- a/vpr7_x2p/vpr/SRC/fpga_x2p/verilog/verilog_routing.c +++ b/vpr7_x2p/vpr/SRC/fpga_x2p/verilog/verilog_routing.c @@ -2378,17 +2378,11 @@ void print_verilog_unique_switch_box_mux(ModuleManager& module_manager, /* Connect input ports to bus */ fp << generate_verilog_local_wire(inbus_port, mux_input_ports); - /* TODO: Find the number of reserved configuration bits for the routing multiplexer - num_mux_reserved_conf_bits = count_num_reserved_conf_bits_one_spice_model(verilog_model, - cur_sram_orgz_info->type, - mux_size); - */ + /* Find the number of reserved configuration bits for the routing multiplexer */ + size_t mux_num_reserved_config_bits = find_mux_num_reserved_config_bits(circuit_lib, mux_model, mux_graph); - /* TODO: Find the number of configuration bits for the routing multiplexer - num_mux_conf_bits = count_num_conf_bits_one_spice_model(verilog_model, - cur_sram_orgz_info->type, - mux_size); - */ + /* Find the number of configuration bits for the routing multiplexer */ + size_t mux_num_config_bits = find_mux_num_config_bits(circuit_lib, mux_model, mux_graph, cur_sram_orgz_info->type); /* Print the configuration port bus */ /* TODO: Print the configuration bus for the routing multiplexers