Prévia do material em texto
Step 1 of 2 5.033E Program for four way, 2-bit transceiver as per context is as follows: module input [2:0] S; input at,bt,ct,dt,et; inout [1:8] reg [1:8] ibus; always@(w or X or y or Z or s) begin if (s[2] == 0) ibus = else case (s[1:0]) 0: ibus = W; 1: ibus = X; 2: ibus = y; 3: ibus = Z; endcase end assign w=((~at & ~et) && (s[2:0] !=4)) ? ibus :8'bz; assign x=((~bt & ~et) && (s[2:0] !=5)) ? ibus :8'bz; assign y=((~ct & ~et) && (s[2:0] !=6)) ? ibus :8'bz; assign z=((~dt & ~et) && (s[2:0] !=7)) ? ibus :8'bz; endmodule Step 2 of 2 If the experienced digital design engineer reviewed the above code, will give comment on logical condition if (s[2] == 0). Because s[2] == 0 can also written as !s[2] which reduce the number of character. Thus the above program can be modified as below, module input [2:0] S; input at,bt,ct,dt,et; inout [1:8] reg [1:8] ibus; always@(w or X or y or Z or s) begin if ibus = {4{s[1:0]}}; else case (S[1:0]) 0: ibus = W; 1: ibus = X; 2: ibus = y; 3: ibus = Z; endcase end assign w=((~at & ~et) && (s[2:0] !=4)) ? ibus :8'bz; assign x=((~bt & ~et) && (s[2:0] !=5)) ? ibus :8'bz; assign y=((~ct & ~et) && (s[2:0] !=6)) ? ibus :8'bz; assign z=((~dt & ~et) && (s[2:0] !=7)) ? ibus :8'bz; endmodule