From 3bdb50da290e1ef68da8a6941ad1cf6c6d580f09 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 9 Aug 2019 21:00:10 +0100 Subject: [PATCH] Schedule UDP initial 0/1 assignments to occur during time 0. This allows any always processes that are sensitive to the UDP output to start first. This fixes a time 0 race that was found in a Lattice Semiconductor simulation library (reported on iverilog-devel). If the initial value is 'x', propagate the value to the UDP output before the start of simulation, to avoid unwanted update events on the z -> x transition on downstream nets. --- vvp/udp.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vvp/udp.cc b/vvp/udp.cc index b311debd4..d5775fcc7 100644 --- a/vvp/udp.cc +++ b/vvp/udp.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2005-2019 Stephen Williams (steve@icarus.com) * * (This is a rewrite of code that was ... * Copyright (c) 2001 Stephan Boettcher ) @@ -907,7 +907,12 @@ vvp_udp_fun_core::vvp_udp_fun_core(vvp_net_t*net, vvp_udp_s*def) current_.mask1 = 0; current_.maskx = ~ ((-1UL) << port_count()); + // If the initial value is 0 or 1, schedule the initial assignment + // normally, so that any sensitive always processes can be started + // first. if (cur_out_ != BIT4_X) + schedule_generic(this, 0, false); + else schedule_functor(this); }