From e08e29c8b4a37587c1097f85c86402f7da5771c5 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 30 Jun 2008 16:35:29 +0100 Subject: [PATCH] Add UFUNC LPM type --- tgt-vhdl/lpm.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tgt-vhdl/lpm.cc b/tgt-vhdl/lpm.cc index 6ce6d04a6..50b8dfb5f 100644 --- a/tgt-vhdl/lpm.cc +++ b/tgt-vhdl/lpm.cc @@ -88,6 +88,27 @@ int draw_part_select_lpm(vhdl_arch *arch, ivl_lpm_t lpm) return 0; } +int draw_ufunc_lpm(vhdl_arch *arch, ivl_lpm_t lpm) +{ + vhdl_fcall *fcall = new vhdl_fcall(ivl_lpm_basename(lpm), NULL); + + for (unsigned i = 0; i < ivl_lpm_size(lpm); i++) { + vhdl_var_ref *ref = nexus_to_var_ref(arch->get_scope(), ivl_lpm_data(lpm, i)); + if (NULL == ref) + return 1; + + fcall->add_expr(ref); + } + + vhdl_var_ref *out = nexus_to_var_ref(arch->get_scope(), ivl_lpm_q(lpm, 0)); + if (NULL == out) + return 1; + + arch->add_stmt(new vhdl_cassign_stmt(out, fcall)); + + return 0; +} + int draw_lpm(vhdl_arch *arch, ivl_lpm_t lpm) { switch (ivl_lpm_type(lpm)) { @@ -99,6 +120,8 @@ int draw_lpm(vhdl_arch *arch, ivl_lpm_t lpm) return draw_binop_lpm(arch, lpm, VHDL_BINOP_MULT); case IVL_LPM_PART_VP: return draw_part_select_lpm(arch, lpm); + case IVL_LPM_UFUNC: + return draw_ufunc_lpm(arch, lpm); default: error("Unsupported LPM type: %d", ivl_lpm_type(lpm)); return 1;