mail4idle2
Full Member level 4
- Joined
- Oct 20, 2012
- Messages
- 200
- Helped
- 20
- Reputation
- 40
- Reaction score
- 19
- Trophy points
- 1,298
- Activity points
- 2,173
What will happen if I declare wire and port with same name in verilog ?
Please refer to below example for question (clk1 is declared as port and wire )
module test (
clk1,
rstn1,
out1 );
input clk1;
input rstn1;
output out1;
wire clk1;
counter U0_counter (
.clk1 (clk1),
.rstn1 (rstn1),
.out1 (out1) );
endmodule
module counter (
clk1,
rstn1,
out1
);
input clk1;
input rstn1;
output out1;
reg [4:0] counter;
always @ (posedge clk1 or negedge rstn1)
begin
if(~rstn1)
begin
counter <= 5'd30;
end
else
begin
if (counter == 5'd0)
begin
counter <= 5'd30;
end
else
begin
counter <= counter - 2'd2;
end
end
end
assign out1 = counter[0];
endmodule
Please refer to below example for question (clk1 is declared as port and wire )
module test (
clk1,
rstn1,
out1 );
input clk1;
input rstn1;
output out1;
wire clk1;
counter U0_counter (
.clk1 (clk1),
.rstn1 (rstn1),
.out1 (out1) );
endmodule
module counter (
clk1,
rstn1,
out1
);
input clk1;
input rstn1;
output out1;
reg [4:0] counter;
always @ (posedge clk1 or negedge rstn1)
begin
if(~rstn1)
begin
counter <= 5'd30;
end
else
begin
if (counter == 5'd0)
begin
counter <= 5'd30;
end
else
begin
counter <= counter - 2'd2;
end
end
end
assign out1 = counter[0];
endmodule