2016-09-30 3 views
0

나는 초보자 요 Verilog이며, SW [0]과 같은 표준 포트에 내 모듈 중 하나의 포트를 할당하는 것과 관련하여 문제가 발생했습니다.Verilog 어떻게 포트 배열을 연결

가정하자 I가 두 개의 모듈

module top(SW, LEDR); 
input [3:0]SW; 
output [3:0]LEDR; 

bottom b0 (
**.in(SW[3:0]); // I am planning to associate SW[0] to in[0], SW[1] to in[1] etc.** 
.out(LEDR[0]); 
); 
endmodule 
module bottom(in[3:0], out); 
input [3:0]in; 
output out; 
assign out = in[0] | in[1] | in[2]; endmodule 

.IN (SW [3 : 0]); // SW [0]을 [0], SW [1] 등등에 연관시킬 계획입니다. 내가 한 것은 잘못되었고 Verilog는 컴파일 할 수 없었습니다. 어떤 조언을 해주시겠습니까?

답변

1

포트 연결에 대한 세미콜론 구문이 잘못되었습니다. 각 포트는 쉼표로 구분하십시오 (끝에는 아무 것도 입력하지 마십시오). 또한 bottom 모듈의 포트 목록에서 [3:0]을 제거하십시오.

module bottom(in, out); 
input [3:0]in; 
output out; 
assign out = in[0] | in[1] | in[2]; 
endmodule 

module top(SW, LEDR); 
input [3:0]SW; 
output [3:0]LEDR; 

bottom b0 (
.in(SW[3:0]), 
.out(LEDR[0]) 
); 
endmodule 
+0

시뮬레이트하기 위해 ModelSim을 사용하려고했는데 다음과 같은 메시지가 표시되었습니다. "모듈에 이름이없는 포트가있을 때 포트를 이름으로 연결할 수 없습니다." – TSP

+0

내 대답이 업데이트되었습니다. – toolic

1

이 포트 선언과 포트 연결에 대한 구문이

module top(
      input [3:0] SW, 
      output [3:0]LEDR 
      ); 
    bottom b0 (
      .in(SW), 
      .out(LEDR[0]) 
      ); 
endmodule 

module bottom(
       input [3:0] in, 
       output out 
      ); 
assign out = {<<{in}}; // bit-reverse 
endmodule 

에주의를 위해 작동합니다 수 있습니다.