It looks like you always copy readdata to writedata , but populate LSB with en if certain special conditions are met. I also assume that the for loop you have is in the always block and that you are going to build combo logic.
The for loop, as you wrote it, doesn't make much sense to me in terms of hardware. The for loop is used to build logic arrays, and since in this case you will have at least 3 logical cones trying to set values ββon the entire writedata bus. (If it generates anything at all, it will be some kind of weird priority structure).
However, probably the range chooses what your compiler complains about, i.e. writedata[2-i:0] , not writedata[3-i] = en[i]; (anything with : in the choice of party). If you want to do something along these lines, you can use the "indexed parts" ( +: or -: , but in this case there are better solutions.
I would rewrite it as follows - assuming that I understood correctly :)
always @( /*whatever*/ ) begin // default assignment writedata = readdata; // overwrite some bits in writedata for special cases for(i=0; i<3; i++) begin if( changed[i] & !done_q[i] ) writedata[3-i] = en[i]; end end
In this code, I set writedata to readdata , and then adjust the resulting writedata value if special cases are in the game. The for loop creates 3 logical cones, one for each bit in writedata[3:1] . I would double check if the bitmap is what you intend - the mappings en[2:0] to writedata[1:3] .
Marty source share