5 NetlistSimulator::SimulationGateCombinational::SimulationGateCombinational(
const Gate* gate) : SimulationGate(gate)
7 std::unordered_map<std::string, BooleanFunction> functions = gate->get_boolean_functions();
9 m_output_pins = gate->get_type()->get_output_pins();
11 for (
const GatePin* pin : m_output_pins)
13 const Net* out_net = gate->get_fan_out_net(pin);
14 m_output_nets.push_back(out_net);
17 BooleanFunction& func = functions.at(pin->get_name());
20 auto vars = func.get_variable_names();
22 for (
const GatePin* other_pin : m_output_pins)
24 if (
const std::string& other_pin_name = other_pin->get_name(); std::find(vars.begin(), vars.end(), other_pin_name) != vars.end())
26 func = func.substitute(other_pin_name, functions.at(other_pin_name)).get();
35 m_functions.emplace(out_net, func);
39 bool NetlistSimulator::SimulationGateCombinational::simulate(
const Simulation& simulation,
const WaveEvent& event, std::map<std::pair<const Net*, u64>, BooleanFunction::Value>& new_events)
46 for (
auto out_net : m_output_nets)
48 BooleanFunction::Value result = m_functions[out_net].evaluate(m_input_values).get();
50 new_events[std::make_pair(out_net, event.time + delay)] = result;