From da95da933ba7f55924bdd0f18b57e59eac41473d Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 17 Apr 2021 15:04:26 -0600 Subject: [PATCH 1/8] [Test] Add pin constraint file to map reset to correct FPGA pins --- .../k4_series/k4n4_fracff/config/pin_constraints.xml | 7 +++++++ .../basic_tests/k4_series/k4n4_fracff/config/task.conf | 1 + 2 files changed, 8 insertions(+) create mode 100644 openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/pin_constraints.xml diff --git a/openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/pin_constraints.xml b/openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/pin_constraints.xml new file mode 100644 index 000000000..abcf209f6 --- /dev/null +++ b/openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/pin_constraints.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/task.conf b/openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/task.conf index 58be5a2bb..07e326a1e 100644 --- a/openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/task.conf +++ b/openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/task.conf @@ -19,6 +19,7 @@ fpga_flow=yosys_vpr openfpga_shell_template=${PATH:OPENFPGA_PATH}/openfpga_flow/openfpga_shell_scripts/example_without_ace_script.openfpga openfpga_arch_file=${PATH:OPENFPGA_PATH}/openfpga_flow/openfpga_arch/k4_frac_N4_fracff_40nm_cc_openfpga.xml openfpga_sim_setting_file=${PATH:OPENFPGA_PATH}/openfpga_flow/openfpga_simulation_settings/fixed_sim_openfpga.xml +openfpga_pin_constraints_file=${PATH:OPENFPGA_PATH}/openfpga_flow/tasks/basic_tests/k4_series/k4n4_fracff/config/pin_constraints.xml # Yosys script parameters yosys_cell_sim_verilog=${PATH:OPENFPGA_PATH}/openfpga_flow/openfpga_yosys_techlib/openfpga_dff_sim.v yosys_dff_map_verilog=${PATH:OPENFPGA_PATH}/openfpga_flow/openfpga_yosys_techlib/openfpga_dff_map.v From 7018073e28194c684aab5b0e93bcc15960996090 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 17 Apr 2021 15:04:51 -0600 Subject: [PATCH 2/8] [Script] Update openfpga shell script w/o ace usage to adapt pin constraint files --- .../openfpga_shell_scripts/example_without_ace_script.openfpga | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfpga_flow/openfpga_shell_scripts/example_without_ace_script.openfpga b/openfpga_flow/openfpga_shell_scripts/example_without_ace_script.openfpga index f694b3c03..3c1be9114 100644 --- a/openfpga_flow/openfpga_shell_scripts/example_without_ace_script.openfpga +++ b/openfpga_flow/openfpga_shell_scripts/example_without_ace_script.openfpga @@ -55,7 +55,7 @@ write_fabric_verilog --file ./SRC --explicit_port_mapping --include_timing --pri # - Enable top-level testbench which is a full verification including programming circuit and core logic of FPGA # - Enable pre-configured top-level testbench which is a fast verification skipping programming phase # - Simulation ini file is optional and is needed only when you need to interface different HDL simulators using openfpga flow-run scripts -write_verilog_testbench --file ./SRC --reference_benchmark_file_path ${REFERENCE_VERILOG_TESTBENCH} --print_top_testbench --print_preconfig_top_testbench --print_simulation_ini ./SimulationDeck/simulation_deck.ini --include_signal_init --support_icarus_simulator +write_verilog_testbench --file ./SRC --reference_benchmark_file_path ${REFERENCE_VERILOG_TESTBENCH} --print_top_testbench --print_preconfig_top_testbench --print_simulation_ini ./SimulationDeck/simulation_deck.ini --include_signal_init --support_icarus_simulator --pin_constraints_file ${OPENFPGA_PIN_CONSTRAINTS_FILE} # Write the SDC files for PnR backend # - Turn on every options here From 6e1b58f8a66353c5aba4d2945088711d12cc5022 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 17 Apr 2021 15:05:22 -0600 Subject: [PATCH 3/8] [Tool] Update FPGA-Verilog testbench generator to accept pin constraints to non-clock global ports --- .../verilog_preconfig_top_module.cpp | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp b/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp index 542eadc2e..d55a59834 100644 --- a/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp +++ b/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp @@ -173,8 +173,32 @@ int print_verilog_preconfig_top_module_connect_global_ports(std::fstream &fp, } /* For other ports, give an default value */ - std::vector default_values(module_global_port.get_width(), fabric_global_ports.global_port_default_value(global_port_id)); - print_verilog_wire_constant_values(fp, module_global_port, default_values); + for (size_t pin_id = 0; pin_id < module_global_port.pins().size(); ++pin_id) { + BasicPort module_global_pin(module_global_port.get_name(), + module_global_port.pins()[pin_id], + module_global_port.pins()[pin_id]); + + /* If the global port name is in the pin constraints, we should wire it to the constrained pin */ + std::string constrained_net_name = std::string(PIN_CONSTRAINT_OPEN_NET); + for (const PinConstraintId& pin_constraint : pin_constraints.pin_constraints()) { + if (module_global_pin == pin_constraints.pin(pin_constraint)) { + constrained_net_name = pin_constraints.net(pin_constraint); + break; + } + } + + /* - If constrained to a given net in the benchmark, we connect the global pin to the net + * - If constrained to an open net in the benchmark, we assign it to a default value + */ + if (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) { + BasicPort benchmark_pin(constrained_net_name + std::string(FORMAL_VERIFICATION_TOP_MODULE_PORT_POSTFIX), 1); + print_verilog_wire_connection(fp, module_global_pin, benchmark_pin, false); + } else { + VTR_ASSERT_SAFE(std::string(PIN_CONSTRAINT_OPEN_NET) == constrained_net_name); + std::vector default_values(module_global_pin.get_width(), fabric_global_ports.global_port_default_value(global_port_id)); + print_verilog_wire_constant_values(fp, module_global_pin, default_values); + } + } } print_verilog_comment(fp, std::string("----- End Connect Global ports of FPGA top module -----")); From da619fabe7114eadee3c240d29cf8686ac244d52 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 17 Apr 2021 17:19:34 -0600 Subject: [PATCH 4/8] [Tool] FPGA-Verilog testbench generator accepts pin constraints in full testbench --- .../fpga_verilog/verilog_top_testbench.cpp | 56 +++++++++++++++---- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/openfpga/src/fpga_verilog/verilog_top_testbench.cpp b/openfpga/src/fpga_verilog/verilog_top_testbench.cpp index 08b7cd2e8..cc7b9fb98 100644 --- a/openfpga/src/fpga_verilog/verilog_top_testbench.cpp +++ b/openfpga/src/fpga_verilog/verilog_top_testbench.cpp @@ -264,6 +264,7 @@ static void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, const ModuleManager& module_manager, const ModuleId& top_module, + const PinConstraints& pin_constraints, const FabricGlobalPortInfo& fabric_global_port_info, const SimulationSetting& simulation_parameters, const bool& active_global_prog_reset, @@ -373,18 +374,48 @@ void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, stimuli_reset_port.set_name(std::string(TOP_TB_RESET_PORT_NAME)); stimuli_reset_port.set_width(1); } - /* Wire the port to the input stimuli: - * The wiring will be inverted if the default value of the global port is 1 - * Otherwise, the wiring will not be inverted! - */ - if (true == activate) { - print_verilog_wire_connection(fp, module_manager.module_port(top_module, module_global_port), - stimuli_reset_port, - 1 == fabric_global_port_info.global_port_default_value(fabric_global_port)); - } else { - VTR_ASSERT_SAFE(false == activate); - print_verilog_wire_constant_values(fp, module_manager.module_port(top_module, module_global_port), - std::vector(1, fabric_global_port_info.global_port_default_value(fabric_global_port))); + + BasicPort module_global_port_info = module_manager.module_port(top_module, module_global_port); + + for (size_t pin_id = 0; pin_id < module_global_port_info.pins().size(); ++pin_id) { + BasicPort module_global_pin(module_global_port_info.get_name(), + module_global_port_info.pins()[pin_id], + module_global_port_info.pins()[pin_id]); + + /* Regular reset port can be mapped by a net from user design */ + if (false == fabric_global_port_info.global_port_is_prog(fabric_global_port)) { + /* If the global port name is in the pin constraints, we should wire it to the constrained pin */ + std::string constrained_net_name = std::string(PIN_CONSTRAINT_OPEN_NET); + for (const PinConstraintId& pin_constraint : pin_constraints.pin_constraints()) { + if (module_global_pin == pin_constraints.pin(pin_constraint)) { + constrained_net_name = pin_constraints.net(pin_constraint); + break; + } + } + + /* - If constrained to a given net in the benchmark, we connect the global pin to the net */ + if (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) { + BasicPort benchmark_pin(constrained_net_name, 1); + print_verilog_wire_connection(fp, module_global_pin, + benchmark_pin, + false); + continue; /* Finish the net assignment for this reset pin */ + } + } + + /* Wire the port to the input stimuli: + * The wiring will be inverted if the default value of the global port is 1 + * Otherwise, the wiring will not be inverted! + */ + if (true == activate) { + print_verilog_wire_connection(fp, module_global_pin, + stimuli_reset_port, + 1 == fabric_global_port_info.global_port_default_value(fabric_global_port)); + } else { + VTR_ASSERT_SAFE(false == activate); + print_verilog_wire_constant_values(fp, module_global_pin, + std::vector(1, fabric_global_port_info.global_port_default_value(fabric_global_port))); + } } } @@ -1994,6 +2025,7 @@ void print_verilog_top_testbench(const ModuleManager& module_manager, /* Generate stimuli for global ports or connect them to existed signals */ print_verilog_top_testbench_global_ports_stimuli(fp, module_manager, top_module, + pin_constraints, global_ports, simulation_parameters, active_global_prog_reset, From d95a1e277695d930f45a64347389a655dd26a568 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 17 Apr 2021 17:31:55 -0600 Subject: [PATCH 5/8] [Tool] Encapulate search function in PinConstraint data structure --- libopenfpga/libpcf/src/pin_constraints.cpp | 11 +++++++++++ libopenfpga/libpcf/src/pin_constraints.h | 5 +++++ .../verilog_preconfig_top_module.cpp | 16 ++-------------- .../src/fpga_verilog/verilog_top_testbench.cpp | 8 +------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/libopenfpga/libpcf/src/pin_constraints.cpp b/libopenfpga/libpcf/src/pin_constraints.cpp index 4f7a701a7..e48d8bf57 100644 --- a/libopenfpga/libpcf/src/pin_constraints.cpp +++ b/libopenfpga/libpcf/src/pin_constraints.cpp @@ -38,6 +38,17 @@ std::string PinConstraints::net(const PinConstraintId& pin_constraint_id) const return pin_constraint_nets_[pin_constraint_id]; } +std::string PinConstraints::pin_net(const openfpga::BasicPort& pin) const { + std::string constrained_net_name = std::string(PIN_CONSTRAINT_OPEN_NET); + for (const PinConstraintId& pin_constraint : pin_constraints()) { + if (pin == pin_constraint_pins_[pin_constraint]) { + constrained_net_name = net(pin_constraint); + break; + } + } + return constrained_net_name; +} + bool PinConstraints::empty() const { return 0 == pin_constraint_ids_.size(); } diff --git a/libopenfpga/libpcf/src/pin_constraints.h b/libopenfpga/libpcf/src/pin_constraints.h index 8b3a977c0..e0ef7fe3f 100644 --- a/libopenfpga/libpcf/src/pin_constraints.h +++ b/libopenfpga/libpcf/src/pin_constraints.h @@ -52,6 +52,11 @@ class PinConstraints { /* Get the net to be constrained */ std::string net(const PinConstraintId& pin_constraint_id) const; + /* Find the net that is constrained on a pin + * TODO: this function will only return the first net found in the constraint list + */ + std::string pin_net(const openfpga::BasicPort& pin) const; + /* Check if there are any pin constraints */ bool empty() const; diff --git a/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp b/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp index d55a59834..e861e0748 100644 --- a/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp +++ b/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp @@ -135,13 +135,7 @@ int print_verilog_preconfig_top_module_connect_global_ports(std::fstream &fp, BasicPort module_clock_pin(module_global_port.get_name(), module_global_port.pins()[pin_id], module_global_port.pins()[pin_id]); /* If the clock port name is in the pin constraints, we should wire it to the constrained pin */ - std::string constrained_net_name; - for (const PinConstraintId& pin_constraint : pin_constraints.pin_constraints()) { - if (module_clock_pin == pin_constraints.pin(pin_constraint)) { - constrained_net_name = pin_constraints.net(pin_constraint); - break; - } - } + std::string constrained_net_name = pin_constraints.pin_net(module_clock_pin); /* If constrained to an open net or there is no clock in the benchmark, we assign it to a default value */ if ( (std::string(PIN_CONSTRAINT_OPEN_NET) == constrained_net_name) @@ -179,13 +173,7 @@ int print_verilog_preconfig_top_module_connect_global_ports(std::fstream &fp, module_global_port.pins()[pin_id]); /* If the global port name is in the pin constraints, we should wire it to the constrained pin */ - std::string constrained_net_name = std::string(PIN_CONSTRAINT_OPEN_NET); - for (const PinConstraintId& pin_constraint : pin_constraints.pin_constraints()) { - if (module_global_pin == pin_constraints.pin(pin_constraint)) { - constrained_net_name = pin_constraints.net(pin_constraint); - break; - } - } + std::string constrained_net_name = pin_constraints.pin_net(module_global_pin); /* - If constrained to a given net in the benchmark, we connect the global pin to the net * - If constrained to an open net in the benchmark, we assign it to a default value diff --git a/openfpga/src/fpga_verilog/verilog_top_testbench.cpp b/openfpga/src/fpga_verilog/verilog_top_testbench.cpp index cc7b9fb98..7ac222ce6 100644 --- a/openfpga/src/fpga_verilog/verilog_top_testbench.cpp +++ b/openfpga/src/fpga_verilog/verilog_top_testbench.cpp @@ -385,13 +385,7 @@ void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, /* Regular reset port can be mapped by a net from user design */ if (false == fabric_global_port_info.global_port_is_prog(fabric_global_port)) { /* If the global port name is in the pin constraints, we should wire it to the constrained pin */ - std::string constrained_net_name = std::string(PIN_CONSTRAINT_OPEN_NET); - for (const PinConstraintId& pin_constraint : pin_constraints.pin_constraints()) { - if (module_global_pin == pin_constraints.pin(pin_constraint)) { - constrained_net_name = pin_constraints.net(pin_constraint); - break; - } - } + std::string constrained_net_name = pin_constraints.pin_net(module_global_pin); /* - If constrained to a given net in the benchmark, we connect the global pin to the net */ if (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) { From 02ca51d84bae2d57426b968793eb3047bc5a6f2f Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 17 Apr 2021 17:45:50 -0600 Subject: [PATCH 6/8] [Tool] Reorganize functions in full testbench generator to avoid big-chunk codes --- .../fpga_verilog/verilog_top_testbench.cpp | 117 ++++++++++++++++-- 1 file changed, 106 insertions(+), 11 deletions(-) diff --git a/openfpga/src/fpga_verilog/verilog_top_testbench.cpp b/openfpga/src/fpga_verilog/verilog_top_testbench.cpp index 7ac222ce6..11f3777f2 100644 --- a/openfpga/src/fpga_verilog/verilog_top_testbench.cpp +++ b/openfpga/src/fpga_verilog/verilog_top_testbench.cpp @@ -258,22 +258,17 @@ void print_verilog_top_testbench_config_protocol_port(std::fstream& fp, } /******************************************************************** - * Wire the global ports of FPGA fabric to local wires + * Wire the global clock ports of FPGA fabric to local wires *******************************************************************/ static -void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, - const ModuleManager& module_manager, - const ModuleId& top_module, - const PinConstraints& pin_constraints, - const FabricGlobalPortInfo& fabric_global_port_info, - const SimulationSetting& simulation_parameters, - const bool& active_global_prog_reset, - const bool& active_global_prog_set) { +void print_verilog_top_testbench_global_clock_ports_stimuli(std::fstream& fp, + const ModuleManager& module_manager, + const ModuleId& top_module, + const FabricGlobalPortInfo& fabric_global_port_info, + const SimulationSetting& simulation_parameters) { /* Validate the file stream */ valid_file_stream(fp); - print_verilog_comment(fp, std::string("----- Begin connecting global ports of FPGA fabric to stimuli -----")); - /* Connect global clock ports to operating or programming clock signal */ for (const FabricGlobalPortId& fabric_global_port : fabric_global_port_info.global_ports()) { if (false == fabric_global_port_info.global_port_is_clock(fabric_global_port)) { @@ -318,6 +313,18 @@ void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, 1 == fabric_global_port_info.global_port_default_value(fabric_global_port)); } } +} + +/******************************************************************** + * Wire the global config done ports of FPGA fabric to local wires + *******************************************************************/ +static +void print_verilog_top_testbench_global_config_done_ports_stimuli(std::fstream& fp, + const ModuleManager& module_manager, + const ModuleId& top_module, + const FabricGlobalPortInfo& fabric_global_port_info) { + /* Validate the file stream */ + valid_file_stream(fp); /* Connect global configuration done ports to configuration done signal */ for (const FabricGlobalPortId& fabric_global_port : fabric_global_port_info.global_ports()) { @@ -342,6 +349,20 @@ void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, stimuli_config_done_port, 1 == fabric_global_port_info.global_port_default_value(fabric_global_port)); } +} + +/******************************************************************** + * Wire the global reset ports of FPGA fabric to local wires + *******************************************************************/ +static +void print_verilog_top_testbench_global_reset_ports_stimuli(std::fstream& fp, + const ModuleManager& module_manager, + const ModuleId& top_module, + const PinConstraints& pin_constraints, + const FabricGlobalPortInfo& fabric_global_port_info, + const bool& active_global_prog_reset) { + /* Validate the file stream */ + valid_file_stream(fp); /* Connect global reset ports to operating or programming reset signal */ for (const FabricGlobalPortId& fabric_global_port : fabric_global_port_info.global_ports()) { @@ -412,6 +433,19 @@ void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, } } } +} + +/******************************************************************** + * Wire the global set ports of FPGA fabric to local wires + *******************************************************************/ +static +void print_verilog_top_testbench_global_set_ports_stimuli(std::fstream& fp, + const ModuleManager& module_manager, + const ModuleId& top_module, + const FabricGlobalPortInfo& fabric_global_port_info, + const bool& active_global_prog_set) { + /* Validate the file stream */ + valid_file_stream(fp); /* Connect global set ports to operating or programming set signal */ for (const FabricGlobalPortId& fabric_global_port : fabric_global_port_info.global_ports()) { @@ -463,6 +497,18 @@ void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, std::vector(1, fabric_global_port_info.global_port_default_value(fabric_global_port))); } } +} + +/******************************************************************** + * Wire the regular global ports of FPGA fabric to local wires + *******************************************************************/ +static +void print_verilog_top_testbench_regular_global_ports_stimuli(std::fstream& fp, + const ModuleManager& module_manager, + const ModuleId& top_module, + const FabricGlobalPortInfo& fabric_global_port_info) { + /* Validate the file stream */ + valid_file_stream(fp); /* For the rest of global ports, wire them to constant signals */ for (const FabricGlobalPortId& fabric_global_port : fabric_global_port_info.global_ports()) { @@ -503,6 +549,55 @@ void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, std::vector default_values(module_port.get_width(), fabric_global_port_info.global_port_default_value(fabric_global_port)); print_verilog_wire_constant_values(fp, module_port, default_values); } +} + +/******************************************************************** + * Wire the global ports of FPGA fabric to local wires + *******************************************************************/ +static +void print_verilog_top_testbench_global_ports_stimuli(std::fstream& fp, + const ModuleManager& module_manager, + const ModuleId& top_module, + const PinConstraints& pin_constraints, + const FabricGlobalPortInfo& fabric_global_port_info, + const SimulationSetting& simulation_parameters, + const bool& active_global_prog_reset, + const bool& active_global_prog_set) { + /* Validate the file stream */ + valid_file_stream(fp); + + print_verilog_comment(fp, std::string("----- Begin connecting global ports of FPGA fabric to stimuli -----")); + + print_verilog_top_testbench_global_clock_ports_stimuli(fp, + module_manager, + top_module, + fabric_global_port_info, + simulation_parameters); + + print_verilog_top_testbench_global_config_done_ports_stimuli(fp, + module_manager, + top_module, + fabric_global_port_info); + + + print_verilog_top_testbench_global_reset_ports_stimuli(fp, + module_manager, + top_module, + pin_constraints, + fabric_global_port_info, + active_global_prog_reset); + + print_verilog_top_testbench_global_set_ports_stimuli(fp, + module_manager, + top_module, + fabric_global_port_info, + active_global_prog_set); + + + print_verilog_top_testbench_regular_global_ports_stimuli(fp, + module_manager, + top_module, + fabric_global_port_info); print_verilog_comment(fp, std::string("----- End connecting global ports of FPGA fabric to stimuli -----")); } From 253422e7b7e848a97285656cc1964e57cf03bef5 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 17 Apr 2021 19:27:03 -0600 Subject: [PATCH 7/8] [Tool] Bugfix due to refactoring --- openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp b/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp index e861e0748..a5647638a 100644 --- a/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp +++ b/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp @@ -137,16 +137,15 @@ int print_verilog_preconfig_top_module_connect_global_ports(std::fstream &fp, /* If the clock port name is in the pin constraints, we should wire it to the constrained pin */ std::string constrained_net_name = pin_constraints.pin_net(module_clock_pin); - /* If constrained to an open net or there is no clock in the benchmark, we assign it to a default value */ - if ( (std::string(PIN_CONSTRAINT_OPEN_NET) == constrained_net_name) - || (true == benchmark_clock_port_names.empty())) { + /* If there is no clock in the benchmark, we assign it to a default value */ + if (true == benchmark_clock_port_names.empty()) { std::vector default_values(1, fabric_global_ports.global_port_default_value(global_port_id)); print_verilog_wire_constant_values(fp, module_clock_pin, default_values); continue; } std::string clock_name_to_connect; - if (!constrained_net_name.empty()) { + if (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) { clock_name_to_connect = constrained_net_name; } else { /* Otherwise, we must have a clear one-to-one clock net corresponding!!! */ From 6e9b24f9bf0473910fce97033da550825b27e267 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Sat, 17 Apr 2021 19:56:30 -0600 Subject: [PATCH 8/8] [Tool] Patch the invalid pin constraint net name --- libopenfpga/libpcf/src/pin_constraints.cpp | 2 +- .../src/fpga_verilog/verilog_preconfig_top_module.cpp | 10 ++++++---- openfpga/src/fpga_verilog/verilog_top_testbench.cpp | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libopenfpga/libpcf/src/pin_constraints.cpp b/libopenfpga/libpcf/src/pin_constraints.cpp index e48d8bf57..24d7571b7 100644 --- a/libopenfpga/libpcf/src/pin_constraints.cpp +++ b/libopenfpga/libpcf/src/pin_constraints.cpp @@ -39,7 +39,7 @@ std::string PinConstraints::net(const PinConstraintId& pin_constraint_id) const } std::string PinConstraints::pin_net(const openfpga::BasicPort& pin) const { - std::string constrained_net_name = std::string(PIN_CONSTRAINT_OPEN_NET); + std::string constrained_net_name; for (const PinConstraintId& pin_constraint : pin_constraints()) { if (pin == pin_constraint_pins_[pin_constraint]) { constrained_net_name = net(pin_constraint); diff --git a/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp b/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp index a5647638a..25b1abe5f 100644 --- a/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp +++ b/openfpga/src/fpga_verilog/verilog_preconfig_top_module.cpp @@ -137,15 +137,16 @@ int print_verilog_preconfig_top_module_connect_global_ports(std::fstream &fp, /* If the clock port name is in the pin constraints, we should wire it to the constrained pin */ std::string constrained_net_name = pin_constraints.pin_net(module_clock_pin); - /* If there is no clock in the benchmark, we assign it to a default value */ - if (true == benchmark_clock_port_names.empty()) { + /* If constrained to an open net or there is no clock in the benchmark, we assign it to a default value */ + if ( (std::string(PIN_CONSTRAINT_OPEN_NET) == constrained_net_name) + || (true == benchmark_clock_port_names.empty())) { std::vector default_values(1, fabric_global_ports.global_port_default_value(global_port_id)); print_verilog_wire_constant_values(fp, module_clock_pin, default_values); continue; } std::string clock_name_to_connect; - if (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) { + if (!constrained_net_name.empty()) { clock_name_to_connect = constrained_net_name; } else { /* Otherwise, we must have a clear one-to-one clock net corresponding!!! */ @@ -177,7 +178,8 @@ int print_verilog_preconfig_top_module_connect_global_ports(std::fstream &fp, /* - If constrained to a given net in the benchmark, we connect the global pin to the net * - If constrained to an open net in the benchmark, we assign it to a default value */ - if (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) { + if ( (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) + && (!constrained_net_name.empty())) { BasicPort benchmark_pin(constrained_net_name + std::string(FORMAL_VERIFICATION_TOP_MODULE_PORT_POSTFIX), 1); print_verilog_wire_connection(fp, module_global_pin, benchmark_pin, false); } else { diff --git a/openfpga/src/fpga_verilog/verilog_top_testbench.cpp b/openfpga/src/fpga_verilog/verilog_top_testbench.cpp index 11f3777f2..7a233de1a 100644 --- a/openfpga/src/fpga_verilog/verilog_top_testbench.cpp +++ b/openfpga/src/fpga_verilog/verilog_top_testbench.cpp @@ -409,7 +409,8 @@ void print_verilog_top_testbench_global_reset_ports_stimuli(std::fstream& fp, std::string constrained_net_name = pin_constraints.pin_net(module_global_pin); /* - If constrained to a given net in the benchmark, we connect the global pin to the net */ - if (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) { + if ( (std::string(PIN_CONSTRAINT_OPEN_NET) != constrained_net_name) + && (!constrained_net_name.empty())) { BasicPort benchmark_pin(constrained_net_name, 1); print_verilog_wire_connection(fp, module_global_pin, benchmark_pin,