[OpenFPGA Tool] Streamline codes in openfpga arch parser
This commit is contained in:
parent
94a1324f05
commit
94047037c5
|
@ -26,52 +26,10 @@
|
|||
*******************************************************************/
|
||||
static
|
||||
e_circuit_model_type string_to_circuit_model_type(const std::string& type_string) {
|
||||
if (std::string("chan_wire") == type_string) {
|
||||
return CIRCUIT_MODEL_CHAN_WIRE;
|
||||
}
|
||||
|
||||
if (std::string("wire") == type_string) {
|
||||
return CIRCUIT_MODEL_WIRE;
|
||||
}
|
||||
|
||||
if (std::string("mux") == type_string) {
|
||||
return CIRCUIT_MODEL_MUX;
|
||||
}
|
||||
|
||||
if (std::string("lut") == type_string) {
|
||||
return CIRCUIT_MODEL_LUT;
|
||||
}
|
||||
|
||||
if (std::string("ff") == type_string) {
|
||||
return CIRCUIT_MODEL_FF;
|
||||
}
|
||||
|
||||
if (std::string("sram") == type_string) {
|
||||
return CIRCUIT_MODEL_SRAM;
|
||||
}
|
||||
|
||||
if (std::string("hard_logic") == type_string) {
|
||||
return CIRCUIT_MODEL_HARDLOGIC;
|
||||
}
|
||||
|
||||
if (std::string("ccff") == type_string) {
|
||||
return CIRCUIT_MODEL_CCFF;
|
||||
}
|
||||
|
||||
if (std::string("iopad") == type_string) {
|
||||
return CIRCUIT_MODEL_IOPAD;
|
||||
}
|
||||
|
||||
if (std::string("inv_buf") == type_string) {
|
||||
return CIRCUIT_MODEL_INVBUF;
|
||||
}
|
||||
|
||||
if (std::string("pass_gate") == type_string) {
|
||||
return CIRCUIT_MODEL_PASSGATE;
|
||||
}
|
||||
|
||||
if (std::string("gate") == type_string) {
|
||||
return CIRCUIT_MODEL_GATE;
|
||||
for (size_t itype = 0; itype < NUM_CIRCUIT_MODEL_TYPES; ++itype) {
|
||||
if (std::string(CIRCUIT_MODEL_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_circuit_model_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reach here, we have an invalid value, error out */
|
||||
|
@ -83,12 +41,10 @@ e_circuit_model_type string_to_circuit_model_type(const std::string& type_string
|
|||
*******************************************************************/
|
||||
static
|
||||
e_circuit_model_design_tech string_to_design_tech_type(const std::string& type_string) {
|
||||
if (std::string("cmos") == type_string) {
|
||||
return CIRCUIT_MODEL_DESIGN_CMOS;
|
||||
}
|
||||
|
||||
if (std::string("rram") == type_string) {
|
||||
return CIRCUIT_MODEL_DESIGN_RRAM;
|
||||
for (size_t itype = 0; itype < NUM_CIRCUIT_MODEL_DESIGN_TECH_TYPES; ++itype) {
|
||||
if (std::string(CIRCUIT_MODEL_DESIGN_TECH_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_circuit_model_design_tech>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_CIRCUIT_MODEL_DESIGN_TECH_TYPES;
|
||||
|
@ -99,12 +55,10 @@ e_circuit_model_design_tech string_to_design_tech_type(const std::string& type_s
|
|||
*******************************************************************/
|
||||
static
|
||||
e_circuit_model_buffer_type string_to_buffer_type(const std::string& type_string) {
|
||||
if (std::string("inverter") == type_string) {
|
||||
return CIRCUIT_MODEL_BUF_INV;
|
||||
}
|
||||
|
||||
if (std::string("buffer") == type_string) {
|
||||
return CIRCUIT_MODEL_BUF_BUF;
|
||||
for (size_t itype = 0; itype < NUM_CIRCUIT_MODEL_BUF_TYPES; ++itype) {
|
||||
if (std::string(CIRCUIT_MODEL_BUFFER_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_circuit_model_buffer_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_CIRCUIT_MODEL_BUF_TYPES;
|
||||
|
@ -115,12 +69,10 @@ e_circuit_model_buffer_type string_to_buffer_type(const std::string& type_string
|
|||
*******************************************************************/
|
||||
static
|
||||
e_circuit_model_pass_gate_logic_type string_to_passgate_type(const std::string& type_string) {
|
||||
if (std::string("transmission_gate") == type_string) {
|
||||
return CIRCUIT_MODEL_PASS_GATE_TRANSMISSION;
|
||||
}
|
||||
|
||||
if (std::string("pass_transistor") == type_string) {
|
||||
return CIRCUIT_MODEL_PASS_GATE_TRANSISTOR;
|
||||
for (size_t itype = 0; itype < NUM_CIRCUIT_MODEL_PASS_GATE_TYPES; ++itype) {
|
||||
if (std::string(CIRCUIT_MODEL_PASSGATE_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_circuit_model_pass_gate_logic_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_CIRCUIT_MODEL_PASS_GATE_TYPES;
|
||||
|
@ -131,16 +83,10 @@ e_circuit_model_pass_gate_logic_type string_to_passgate_type(const std::string&
|
|||
*******************************************************************/
|
||||
static
|
||||
e_circuit_model_structure string_to_mux_structure_type(const std::string& type_string) {
|
||||
if (std::string("tree") == type_string) {
|
||||
return CIRCUIT_MODEL_STRUCTURE_TREE;
|
||||
}
|
||||
|
||||
if (std::string("one_level") == type_string) {
|
||||
return CIRCUIT_MODEL_STRUCTURE_ONELEVEL;
|
||||
}
|
||||
|
||||
if (std::string("multi_level") == type_string) {
|
||||
return CIRCUIT_MODEL_STRUCTURE_MULTILEVEL;
|
||||
for (size_t itype = 0; itype < NUM_CIRCUIT_MODEL_STRUCTURE_TYPES; ++itype) {
|
||||
if (std::string(CIRCUIT_MODEL_STRUCTURE_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_circuit_model_structure>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_CIRCUIT_MODEL_STRUCTURE_TYPES;
|
||||
|
@ -151,16 +97,10 @@ e_circuit_model_structure string_to_mux_structure_type(const std::string& type_s
|
|||
*******************************************************************/
|
||||
static
|
||||
e_circuit_model_gate_type string_to_gate_type(const std::string& type_string) {
|
||||
if (std::string("AND") == type_string) {
|
||||
return CIRCUIT_MODEL_GATE_AND;
|
||||
}
|
||||
|
||||
if (std::string("OR") == type_string) {
|
||||
return CIRCUIT_MODEL_GATE_OR;
|
||||
}
|
||||
|
||||
if (std::string("MUX2") == type_string) {
|
||||
return CIRCUIT_MODEL_GATE_MUX2;
|
||||
for (size_t itype = 0; itype < NUM_CIRCUIT_MODEL_GATE_TYPES; ++itype) {
|
||||
if (std::string(CIRCUIT_MODEL_GATE_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_circuit_model_gate_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_CIRCUIT_MODEL_GATE_TYPES;
|
||||
|
@ -171,40 +111,10 @@ e_circuit_model_gate_type string_to_gate_type(const std::string& type_string) {
|
|||
*******************************************************************/
|
||||
static
|
||||
e_circuit_model_port_type string_to_circuit_model_port_type(const std::string& type_string) {
|
||||
if (std::string("input") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_INPUT;
|
||||
}
|
||||
|
||||
if (std::string("output") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_OUTPUT;
|
||||
}
|
||||
|
||||
if (std::string("clock") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_CLOCK;
|
||||
}
|
||||
|
||||
if (std::string("sram") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_SRAM;
|
||||
}
|
||||
|
||||
if (std::string("bl") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_BL;
|
||||
}
|
||||
|
||||
if (std::string("wl") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_WL;
|
||||
}
|
||||
|
||||
if (std::string("blb") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_BLB;
|
||||
}
|
||||
|
||||
if (std::string("wlb") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_WLB;
|
||||
}
|
||||
|
||||
if (std::string("inout") == type_string) {
|
||||
return CIRCUIT_MODEL_PORT_INOUT;
|
||||
for (size_t itype = 0; itype < NUM_CIRCUIT_MODEL_PORT_TYPES; ++itype) {
|
||||
if (std::string(CIRCUIT_MODEL_PORT_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_circuit_model_port_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_CIRCUIT_MODEL_PORT_TYPES;
|
||||
|
@ -215,12 +125,10 @@ e_circuit_model_port_type string_to_circuit_model_port_type(const std::string& t
|
|||
*******************************************************************/
|
||||
static
|
||||
e_wire_model_type string_to_wire_model_type(const std::string& type_string) {
|
||||
if (std::string("pi") == type_string) {
|
||||
return WIRE_MODEL_PI;
|
||||
}
|
||||
|
||||
if (std::string("t") == type_string) {
|
||||
return WIRE_MODEL_T;
|
||||
for (size_t itype = 0; itype < NUM_WIRE_MODEL_TYPES; ++itype) {
|
||||
if (std::string(WIRE_MODEL_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_wire_model_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_WIRE_MODEL_TYPES;
|
||||
|
@ -231,12 +139,10 @@ e_wire_model_type string_to_wire_model_type(const std::string& type_string) {
|
|||
*******************************************************************/
|
||||
static
|
||||
e_circuit_model_delay_type string_to_circuit_model_delay_type(const std::string& type_string) {
|
||||
if (std::string("rise") == type_string) {
|
||||
return CIRCUIT_MODEL_DELAY_RISE;
|
||||
}
|
||||
|
||||
if (std::string("fall") == type_string) {
|
||||
return CIRCUIT_MODEL_DELAY_FALL;
|
||||
for (size_t itype = 0; itype < NUM_CIRCUIT_MODEL_DELAY_TYPES; ++itype) {
|
||||
if (std::string(CIRCUIT_MODEL_DELAY_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_circuit_model_delay_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_CIRCUIT_MODEL_DELAY_TYPES;
|
||||
|
|
|
@ -23,20 +23,11 @@
|
|||
*******************************************************************/
|
||||
static
|
||||
e_config_protocol_type string_to_config_protocol_type(const std::string& type_string) {
|
||||
if (std::string("standalone") == type_string) {
|
||||
return CONFIG_MEM_STANDALONE;
|
||||
}
|
||||
|
||||
if (std::string("scan_chain") == type_string) {
|
||||
return CONFIG_MEM_SCAN_CHAIN;
|
||||
}
|
||||
|
||||
if (std::string("memory_bank") == type_string) {
|
||||
return CONFIG_MEM_MEMORY_BANK;
|
||||
}
|
||||
|
||||
if (std::string("frame_based") == type_string) {
|
||||
return CONFIG_MEM_FRAME_BASED;
|
||||
|
||||
for (size_t itype = 0; itype < NUM_CONFIG_PROTOCOL_TYPES; ++itype) {
|
||||
if (std::string(CONFIG_PROTOCOL_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_config_protocol_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_CONFIG_PROTOCOL_TYPES;
|
||||
|
|
|
@ -23,12 +23,10 @@
|
|||
*******************************************************************/
|
||||
static
|
||||
e_sim_accuracy_type string_to_sim_accuracy_type(const std::string& type_string) {
|
||||
if (std::string("frac") == type_string) {
|
||||
return SIM_ACCURACY_FRAC;
|
||||
}
|
||||
|
||||
if (std::string("abs") == type_string) {
|
||||
return SIM_ACCURACY_ABS;
|
||||
for (size_t itype = 0; itype < NUM_SIM_ACCURACY_TYPES; ++itype) {
|
||||
if (std::string(SIM_ACCURACY_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_sim_accuracy_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_SIM_ACCURACY_TYPES;
|
||||
|
|
|
@ -23,12 +23,10 @@
|
|||
*******************************************************************/
|
||||
static
|
||||
e_tech_lib_model_type string_to_device_model_type(const std::string& type_string) {
|
||||
if (std::string("transistor") == type_string) {
|
||||
return TECH_LIB_MODEL_TRANSISTOR;
|
||||
}
|
||||
|
||||
if (std::string("rram") == type_string) {
|
||||
return TECH_LIB_MODEL_RRAM;
|
||||
for (size_t itype = 0; itype < NUM_TECH_LIB_MODEL_TYPES; ++itype) {
|
||||
if (std::string(TECH_LIB_MODEL_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_tech_lib_model_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_TECH_LIB_MODEL_TYPES;
|
||||
|
@ -39,12 +37,10 @@ e_tech_lib_model_type string_to_device_model_type(const std::string& type_string
|
|||
*******************************************************************/
|
||||
static
|
||||
e_tech_lib_type string_to_tech_lib_type(const std::string& type_string) {
|
||||
if (std::string("industry") == type_string) {
|
||||
return TECH_LIB_INDUSTRY;
|
||||
}
|
||||
|
||||
if (std::string("academia") == type_string) {
|
||||
return TECH_LIB_ACADEMIA;
|
||||
for (size_t itype = 0; itype < NUM_TECH_LIB_TYPES; ++itype) {
|
||||
if (std::string(TECH_LIB_TYPE_STRING[itype]) == type_string) {
|
||||
return static_cast<e_tech_lib_type>(itype);
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_TECH_LIB_TYPES;
|
||||
|
|
Loading…
Reference in New Issue