In the below module, ideally cnt, width & start should be inout port, instead of output port.
But I tried with those ports as output ports and still I am able to run it without any error. So can inout and output ports be used interchangeably in Verilog?
If no, then what is the exact criteria, where inout port must be used (output port can't be used in that case)?
module (clk, rst, cnt, start, width, signal);
input clk, rst, signal;
output reg [11:0] cnt, width;
output reg start;
always @(posedge clk or negedge rst)
begin
if(~rst)
begin
cnt <= 0;
start = 0;
width <= 'h271;
end
else
begin
if(signal)
begin
width <= (start) ? width : 'h271;
start = 1;
end
cnt <= (start) ? (cnt + 1) : cnt;
end
end
endmodule
Note - I know, that with inout ports, I need to modify the code, as inout ports can't be of reg type. But I am here asking about just type of ports only.