Reputation: 51
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.
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?
Upvotes: 1
Views: 1243
Reputation: 1693
'bz
expression you used grawis (`
) instead of apostrophe
('
).;
).data_out
is type of reg
instead of input
(depending on image).data_in
is type of reg
instead of output
(depending on image).assign
inside begin end
.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
Upvotes: 1