24 std::stringstream
function;
27 u32 lut_size = input_pins.size();
32 log_debug(
"verilator",
"valid LUT, got LUT component");
36 log_error(
"verilator",
"cannot get LUTComponent, aborting...");
37 return function.str();
40 if (output_pins.size() > 1)
42 log_error(
"verilator",
"unsupported reached: currently only supporting LUTs with one output, split them into two and set the LUT_INIT string correctly :) ! aborting...");
43 return function.str();
46 std::reverse(input_pins.begin(), input_pins.end());
47 function <<
"wire [" << lut_size - 1 <<
":0] lut_lookup = {";
48 for (
const auto input_pin : input_pins)
50 function << input_pin->get_name() <<
", ";
52 function.seekp(-2,
function.cur);
53 function <<
"};" << std::endl;
57 if (init_component ==
nullptr)
59 log_error(
"verilator",
"Could not get init component for gate type {}!", gt->
get_name());
62 for (
const auto& output_pin : output_pins)
64 function <<
"assign " << output_pin->get_name() <<
" = " << init_component->
get_init_identifiers().front() <<
"[lut_lookup];" << std::endl;
67 return function.str();
std::vector< GatePin * > get_output_pins() const
const std::string & get_name() const
std::vector< GatePin * > get_input_pins() const
T * get_component_as(const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
static bool is_class_of(const GateTypeComponent *component)
const std::vector< std::string > & get_init_identifiers() const
#define log_error(channel,...)
#define log_debug(channel,...)
std::string get_function_for_lut(const GateType *gt)