Compare commits
No commits in common. "4203deb15bff0c931faa36241149308e80c528bd" and "1f53f7e90f2a9ec97aca64d31df4e7cd86bc69c8" have entirely different histories.
4203deb15b
...
1f53f7e90f
|
@ -32,17 +32,6 @@ int main(int argc, char **argv) {
|
|||
add_case.assert_eq("no Fzero", valu->Fzero, 0x0);
|
||||
}
|
||||
|
||||
{
|
||||
Tester add_case(&add_t, "0x5555+0x5555");
|
||||
valu->op = 0b000;
|
||||
valu->A = 0x5555;
|
||||
valu->B = 0x5555;
|
||||
valu->eval();
|
||||
add_case.assert_eq("O == 0xaaaa", valu->O, 0xaaaa);
|
||||
add_case.assert_eq("no overflow", valu->Fflow, 0x0);
|
||||
add_case.assert_eq("no Fzero", valu->Fzero, 0x0);
|
||||
}
|
||||
|
||||
{
|
||||
Tester add_case(&add_t, "0xffffffff+0x1");
|
||||
valu->op = 0b000;
|
||||
|
|
|
@ -24,6 +24,6 @@ carry_select_block#(6) B3 (A[23:18], B[23:18], Cout_17, O[23:18], Cout_23);
|
|||
wire Cout_29;
|
||||
carry_select_block#(6) B4 (A[29:24], B[29:24], Cout_23, O[29:24], Cout_29);
|
||||
|
||||
carry_select_block#(2) B5 (A[31:30], B[31:30], Cout_29, O[31:30], Cout);
|
||||
carry_select_block#(2) B6 (A[31:30], B[31:30], Cout_29, O[31:30], Cout);
|
||||
|
||||
endmodule
|
||||
|
|
|
@ -10,18 +10,30 @@ module carry_select_block#(
|
|||
|
||||
// Case for Cin = 0
|
||||
wire [N-1:0] O_C0;
|
||||
wire [N-1:0] O_C1;
|
||||
wire [N:1] carry0;
|
||||
wire [N:1] carry1;
|
||||
wire Cout_C0;
|
||||
|
||||
fa fa00(A[0], B[0], 0, O_C0[0], carry0[1]);
|
||||
fa fa10(A[0], B[0], 1, O_C1[0], carry1[1]);
|
||||
begin
|
||||
wire [N-1:1] carry;
|
||||
fa fa0(A[0], B[0], 0, O_C0[0], carry[1]);
|
||||
genvar i; for (i = 1; i <= N - 1; i = i + 1) begin
|
||||
fa fa0i(A[i], B[i], carry0[i], O_C0[i], carry0[i+1]);
|
||||
fa fa1i(A[i], B[i], carry1[i], O_C1[i], carry1[i+1]);
|
||||
fa fai(A[i], B[i], carry[i], O_C0[i], carry[i+1]);
|
||||
end
|
||||
assign Cout_C0 = carry[N-1];
|
||||
end
|
||||
|
||||
// Case for Cin = 1
|
||||
wire [N-1:0] O_C1;
|
||||
wire Cout_C1;
|
||||
begin
|
||||
wire [N-1:1] carry;
|
||||
fa fa0(A[0], B[0], 1, O_C1[0], carry[1]);
|
||||
genvar i; for (i = 1; i <= N - 1; i = i + 1) begin
|
||||
fa fai(A[i], B[i], carry[i], O_C1[i], carry[i+1]);
|
||||
end
|
||||
assign Cout_C1 = carry[N-1];
|
||||
end
|
||||
|
||||
assign O = Cin == 0 ? O_C0 : O_C1;
|
||||
assign Cout = Cin == 0 ? carry0[N] : carry1[N];
|
||||
assign Cout = Cin == 0 ? Cout_C0 : Cout_C1;
|
||||
|
||||
endmodule
|
||||
|
|
Loading…
Reference in New Issue
Block a user