Verilog를 처음 사용했습니다. 여기까지 내가 지금까지 해왔고 4 비트 CLA가 작동합니다. 그러나 16 비트 (4 비트 CLA의 인스턴스 사용)는 그렇지 않습니다. 문제는 확실히 블록 전파 (BP
)와 블록 생성 (BG
)의 Cout_itermed
(중간 캐리) 값을 설정하는 데 있습니다. 이 문제를 해결하기 위해 모듈 carries
을 만들었습니다.4 비트 캐리 룩 어 헤드 (CLA)에서 16 비트 가산기 - 블록에서 생성 됨 생성 및 전파
는 출력 파형이 (더 웨이브 도시하지 않음)로 나타난다 :
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_4bit
Cout
의 출력을 상기 제 1 및 carries
Cout_itermed
모듈의 출력을 상기 제 2 -
이 문제가 있습니까? 그것이 아주 기본적인 질문이라면 미안하지만 몇 시간 동안 놀았지만 제대로 작동하지는 않습니다. –
몇 가지 가능한 변경 사항을 편집하십시오. – wilcroft