Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a System Verilog code to implement wallace tree reduction for a 5x5 multiplier #1

Open
cuber2116 opened this issue Oct 17, 2024 · 27 comments

Comments

@cuber2116
Copy link
Collaborator

cuber2116 commented Oct 17, 2024

A structure for the 5x5 wallace tree multiplier has been provided in diagram.md in Wallace5x5 folder.
Write a code for wallace_tree_reduction.sv in Wallace5x5 folder.
Implementing adder+Working Test bench = 350 points

@cuber2116 cuber2116 changed the title Write wallace tree reduction code 5x5 multiplier Write a System Verilog code to implement a wallace tree reduction code 5x5 multiplier Oct 17, 2024
@cuber2116 cuber2116 changed the title Write a System Verilog code to implement a wallace tree reduction code 5x5 multiplier Write a System Verilog code to implement a wallace tree reduction for a 5x5 multiplier Oct 17, 2024
@cuber2116 cuber2116 changed the title Write a System Verilog code to implement a wallace tree reduction for a 5x5 multiplier Write a System Verilog code to implement wallace tree reduction for a 5x5 multiplier Oct 17, 2024
@gaganbrwj
Copy link

can you please assign me this

@Web-dev-learner1
Copy link

Can you assign this to me?

@cuber2116
Copy link
Collaborator Author

!assign @gaganbrwj 60m

@cuber2116
Copy link
Collaborator Author

!assign @gaganbrwj 90

@gaganbrwj
Copy link

okay i am done with the code of .sv files i should code the testbench files now

module wallace_tree_reduction (
input logic [4:0] a, // 5-bit input a
input logic [4:0] b, // 5-bit input b
output logic [9:0] product // 10-bit product
);

logic [4:0][4:0] partial_products; // 5 partial products (5x5)

// Step 1: Generate partial products
genvar i, j;
generate
    for (i = 0; i < 5; i++) begin
        for (j = 0; j < 5; j++) begin
            assign partial_products[i][j] = a[i] & b[j];
        end
    end
endgenerate

// Step 2: Wallace tree reduction using full and half adders
logic [9:0] sum_stage1, carry_stage1;
logic [9:0] sum_stage2, carry_stage2;
logic [9:0] final_sum, final_carry;

// First stage of reduction
// (Add intermediate logic for full adders and half adders, summing the partial products)
// This is the core of Wallace tree logic where you will reduce the rows using adders.
// Use full_adder and half_adder for different bits.

// Stage 1 reduction (example logic, expand for the full multiplier)
half_adder ha1(partial_products[0][1], partial_products[1][0], sum_stage1[1], carry_stage1[1]);
full_adder fa1(partial_products[0][2], partial_products[1][1], partial_products[2][0], sum_stage1[2], carry_stage1[2]);

// Stage 2 and so on for the entire tree...

// Step 3: Final addition of sums and carry
assign product = final_sum + (final_carry << 1);

endmodule

// Full adder module
module full_adder(
input logic a, b, cin,
output logic sum, cout
);
assign sum = a ^ b ^ cin;
assign cout = (a & b) | (b & cin) | (cin & a);
endmodule

// Half adder module
module half_adder(
input logic a, b,
output logic sum, cout
);
assign sum = a ^ b;
assign cout = a & b;
endmodule

@cuber2116
Copy link
Collaborator Author

!assign @gaganbrwj

@cuber2116
Copy link
Collaborator Author

@gaganbrwj open a PR

@gaganbrwj
Copy link

huh? this is the code to implement wallace tree reduction for a 5x5 multiplier
and thts wht i was assigned

@gaganbrwj
Copy link

i have now written testbench files also to it

@cuber2116
Copy link
Collaborator Author

@gaganbrwj the bot didn't assign it to you because you were assigned some other issue initially

@cuber2116
Copy link
Collaborator Author

!assign @gaganbrwj

@cuber2116
Copy link
Collaborator Author

Now it's been assigned @gaganbrwj please open PR, don't submit the code here

@gaganbrwj
Copy link

okay am i assigned to this issue now ?

@cuber2116
Copy link
Collaborator Author

Yes

@bunsamosa-bot
Copy link

bunsamosa-bot bot commented Oct 18, 2024

Hey @cuber2116! The timer for the @gaganbrwj to work on the issue has finished, deassign and assign a new contributor or extend the current timer. Contact maintainer leads if inactive @DedLad @polarhive @achyuthcodes30

@gaganbrwj
Copy link

Now it's been assigned @gaganbrwj please open PR, don't submit the code here

okay got it

@cuber2116
Copy link
Collaborator Author

@gaganbrwj did you finish?

@gaganbrwj
Copy link

the codes are ready but there are errors and i am pulling the request now

@cuber2116
Copy link
Collaborator Author

!assign @gaganbrwj 30

@cuber2116
Copy link
Collaborator Author

@gaganbrwj you have 30 more mins

@gaganbrwj
Copy link

i am so sorry theres problem in pulling request
give me 15 more min maybe ill be able to do it

@cuber2116
Copy link
Collaborator Author

!assign @gaganbrwj 20

@gaganbrwj
Copy link

assign me some more time please

@cuber2116
Copy link
Collaborator Author

!assign @gaganbrwj 60

@kavin81
Copy link

kavin81 commented Oct 18, 2024

@cuber2116 can you assign me ?

@cuber2116
Copy link
Collaborator Author

!assign @kavin81 90

@cuber2116
Copy link
Collaborator Author

@kavin81 I think you've been assigned to a different issue so please make sure that they deassign you first so that I can assign this to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants