From 7a5dd1bc0293b56b3e8f61dc505184c6748c3857 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Wed, 24 Feb 2021 10:36:48 -0700 Subject: [PATCH] [Tools] Patch circuit library for dummy circuit models without any ports --- libopenfpga/libarchopenfpga/src/circuit_library.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libopenfpga/libarchopenfpga/src/circuit_library.cpp b/libopenfpga/libarchopenfpga/src/circuit_library.cpp index f56b94199..537a436bc 100644 --- a/libopenfpga/libarchopenfpga/src/circuit_library.cpp +++ b/libopenfpga/libarchopenfpga/src/circuit_library.cpp @@ -1214,6 +1214,16 @@ CircuitModelId CircuitLibrary::add_model(const enum e_circuit_model_type& type) /* Build the fast look-up for circuit models */ build_model_lookup(); + /* Add a placeholder in the fast look-up for model port + * This is to avoid memory holes when a circuit model + * does not have any ports. + * As a result, the fast look-up may not even create an entry + * for this model id, which cause fast look-up abort when there is + * a query on the model + */ + model_port_lookup_.resize(model_ids_.size()); + model_port_lookup_[model_id].resize(NUM_CIRCUIT_MODEL_PORT_TYPES); + return model_id; }