1

Program for IO Buffer. All ports are single bit as shown in the below block diagram. When op_en is high, data_out will be driving io_port. When op_en islow, io_port is tri-stated. Data_in will always be connected to io_port.

enter image description here

I tried below code.

module IOBuff(op_en,data_out,io_port,data_in);
input op_en;
inout io_port;
reg data_out;
reg data_in;
begin
assign io_port = op_en ? data_out : `bz
end
endmodule

I am new to verilog and tried above code but it's not complete and also how can we check whether our code is correct or not?

P.goutham
  • 51
  • 6
  • HINT: Look at your error messages. I see obvious port definition errors, typos on your assign statement, and a missing output driver. Two of those error types are compiling errors and will be reported in your log file – Greg Jul 02 '21 at 14:56
  • @Greg He will not see other errors because he used grawis instead of apostrophe. – ToTamire Jul 03 '21 at 13:04

1 Answers1

1
  1. In 'bz expression you used grawis (`) instead of apostrophe (').
  2. You don't finish assign expression with comma (;).
  3. Your data_out is type of reg instead of input (depending on image).
  4. Your data_in is type of reg instead of output (depending on image).
  5. You should not place assign inside begin end.
  6. You have unused data_in signal.
module IOBuff(op_en, data_out, io_port, data_in);

    input op_en;
    inout io_port;
    input data_out;
    output data_in;

    assign io_port = op_en ? data_out : 'bz;

endmodule
ToTamire
  • 1,425
  • 1
  • 13
  • 23