2016-10-05 8 views
1

Verilog를 처음 사용했습니다. 여기까지 내가 지금까지 해왔고 4 비트 CLA가 작동합니다. 그러나 16 비트 (4 비트 CLA의 인스턴스 사용)는 그렇지 않습니다. 문제는 확실히 블록 전파 (BP)와 블록 생성 (BG)의 Cout_itermed (중간 캐리) 값을 설정하는 데 있습니다. 이 문제를 해결하기 위해 모듈 carries을 만들었습니다.4 비트 캐리 룩 어 헤드 (CLA)에서 16 비트 가산기 - 블록에서 생성 됨 생성 및 전파

자일링스 ISE에

는 출력 파형이 (더 웨이브 도시하지 않음)로 나타난다 :

Xilinx ISE

module CLA_4bit(
     output [3:0] S, 
     output Cout, PG, GG, 
     input [3:0] A, B, 
     input Cin 
     ); 

     wire [3:0] G,P,C; 

     assign G = A & B; //Generate 
     assign P = A^B; //Propagate 

     assign C[0] = Cin; 
     assign C[1] = G[0] | (P[0] & C[0]); 
     assign C[2] = G[1] | (P[1] & G[0]) | (P[1] & P[0] & C[0]); 
     assign C[3] = G[2] | (P[2] & G[1]) | (P[2] & P[1] & G[0]) | (P[2] & P[1] & P[0] & C[0]); 

     assign Cout = G[3] | (P[3] & G[2]) | (P[3] & P[2] & G[1]) | (P[3] & P[2] & P[1] & G[0]) |(P[3] & P[2] & P[1] & P[0] & C[0]); 
     assign S = P^C; 

     assign PG = P[3] & P[2] & P[1] & P[0]; // block generate 
     assign GG = G[3] | (P[3] & G[2]) | (P[3] & P[2] & G[1]) | (P[3] & P[2] & P[1] & G[0]); // block propagate 
endmodule 

module CLA_16bit(
     output reg [15:0] S, 
     output reg Cout, 
     input [15:0] A, B, 
     input Cin 
     ); 

     reg [3:0] BP, BG; 

     reg [3:0] Cout_itermed; 

     carries my_carries(BP, GP, Cin, Cout_itermed, Cout); 

     CLA_4bit cla0(S[3:0], Cout_itermed[0], BP[0], BG[0], A[3:0], B[3:0], Cin); 

     CLA_4bit cla1(S[7:4], Cout_itermed[1], BP[1], BG[1], A[7:4], B[7:4], Cout_itermed[0]); 

     CLA_4bit cla2(S[11:8], Cout_itermed[2], BP[2], BG[2], A[11:8], B[11:8], Cout_itermed[1]); 

     CLA_4bit cla3(S[15:12], Cout_itermed[3], BP[3], BG[3], A[15:12], B[15:12], Cout_itermed[2]); 

     Cout = Cout_itermed[3]; 
endmodule 

module carries (
     input [3:0] BP, 
     input [3:0] BG, 
     input Cin, 
     output reg [3:0] Cout_itermed, 
     output reg Cout 
     ); 

     assign Cout_itermed[0] = BG[0] | (BP[0] & Cin); 
     assign Cout_itermed[1] = BG[1] | (BP[1] & Cout_itermed[0]); 
     assign Cout_itermed[2] = BG[2] | (BP[2] & Cout_itermed[1]); 

     assign Cout = Cout_itermed[3]; 

endmodule 

파형 내가의 테스트 벤치를 실행할 때 표시 (정확하게) 수행 4 비트 CLA. 누구든지 carries 또는 CLA_16bit 모듈에 문제가있는 위치를 설명 할 수 있습니까? CLA_4bitCout의 출력을 상기 제 1 및 carriesCout_itermed 모듈의 출력을 상기 제 2 -

답변

1

Cout_itermed 두 드라이버를 갖는다. (이 두 드라이버 CLA_16bitcarries 동일한 신호 Cout_itermed[3]를 끝나게 비록)

동일 CLA_16bitCout에 적용된다.

Verilog에서 물리적 인 회로를 묘사하고 있으며, 같은 와이어에 두 개의 소스 (드라이버)를 연결해서는 안됩니다. 이것이 바로 단락 회로입니다.

다음은 https://en.wikipedia.org/wiki/Lookahead_carry_unit#16-bit_adder을 기반으로합니다. CLA_16bit에있는 Cout 포트에서 Cout_itermed[x]을 제거하기 만하면됩니다 (포트를 그대로 둘 수 있습니다). 로직을 이동하여 Cout_itermed[3] (즉, BG[3] | (BP[3]&Cout_itermed[2]))을 carries 모듈로 이동해야합니다.

+0

이 문제가 있습니까? 그것이 아주 기본적인 질문이라면 미안하지만 몇 시간 동안 놀았지만 제대로 작동하지는 않습니다. –

+0

몇 가지 가능한 변경 사항을 편집하십시오. – wilcroft