Multiplexing Output Signals in Verilog
// Using macrocell logic for a conventional multiplexer:
always@(A or SEL or B or C or D)
begin
// Using 3-state outputs to multiplex registers fast
case(SEL)
00:
muxout=A;
01:
muxout=B;
10:
muxout=C;
11:
muxout=D;
endcase
end
always@(posedge CLK)
begin
assign DOUT_A = (SEL ==0)?REG_A:1'bz; REG_A = DATA_A;
end
REG_B =DATA_B;
assign DOUT_B = (SEL ==1)?REG_B:1'bz;