Suppose I have the following instantiation
first_mux_input=top.middle.down[i];
second_mux_input=top.middle.down[i+1];
assign down = (select[i])? first_mux_input:second_mux_input;
supposing there are a lot of muxes and their outputs go to the inputs to muxes that are placed below them.
I'm using the variable "down" before I define it. is this legal since verilog compiles all the lines subsequently and not by order(in this case)?
thanks
It depends on your synthesizer. I have worked only with Xilinx. In my case Xilinx accepts this type definition for simulation. But for synthesis you need to define a wire/reg before instantiation.