top.v 489 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
module tristate (en, i, o);
    input en;
    input i;    
    output [1:0] o;
    
    wire [1:0] io;

`ifndef BUG    
	assign 	io[0] = (en)? i : 1'bZ;
		
    assign 	io[1] = (i)? en : 1'bZ;
		
    assign o = io;
`else
	assign 	io[0] = (en)? ~i : 1'bZ;
		
    assign 	io[1] = (i)? ~en : 1'bZ;
		
    assign o = ~io;
`endif
endmodule


module top (
input en,
input a,
inout [1:0] b,
output [1:0] c
);

tristate u_tri (
        .en (en ),
        .i (a ),
        .o (c )
    );

endmodule