From d7736d7eba5cf35398972de687cad11e2b420653 Mon Sep 17 00:00:00 2001 From: Johann Klammer Date: Fri, 11 Mar 2016 21:46:31 +0100 Subject: [PATCH] latch for vvp output --- tgt-vvp/draw_net_input.c | 1 + tgt-vvp/vvp_scope.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tgt-vvp/draw_net_input.c b/tgt-vvp/draw_net_input.c index e2f94fb20..d8ce40d88 100644 --- a/tgt-vvp/draw_net_input.c +++ b/tgt-vvp/draw_net_input.c @@ -436,6 +436,7 @@ static char* draw_net_input_drive(ivl_nexus_t nex, ivl_nexus_ptr_t nptr) if (lpm) switch (ivl_lpm_type(lpm)) { case IVL_LPM_FF: + case IVL_LPM_LATCH: case IVL_LPM_ABS: case IVL_LPM_ADD: case IVL_LPM_ARRAY: diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 9bd197df6..53b56dbc6 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -1830,6 +1830,31 @@ static void draw_lpm_ff(ivl_lpm_t net) fprintf(vvp_out, ";\n"); } +/* + * Emit a LATCH primitive. This uses the following syntax: + * + * .latch , ; + */ +static void draw_lpm_latch(ivl_lpm_t net) +{ + ivl_nexus_t nex; + + unsigned width = ivl_lpm_width(net); + fprintf(vvp_out, "L_%p .latch %u ", net, width); + + nex = ivl_lpm_data(net,0); + assert(nex); + fprintf(vvp_out, "%s", draw_net_input(nex)); + assert(width_of_nexus(nex) == width); + + nex = ivl_lpm_enable(net); + assert(nex); + assert(width_of_nexus(nex) == 1); + fprintf(vvp_out, ", %s", draw_net_input(nex)); + + fprintf(vvp_out, ";\n"); +} + static void draw_lpm_shiftl(ivl_lpm_t net) { unsigned width = ivl_lpm_width(net); @@ -2160,6 +2185,10 @@ static void draw_lpm_in_scope(ivl_lpm_t net) draw_lpm_ff(net); return; + case IVL_LPM_LATCH: + draw_lpm_latch(net); + return; + case IVL_LPM_CMP_EEQ: case IVL_LPM_CMP_EQ: case IVL_LPM_CMP_EQX: