Apr 11, 2015 #1 M Mahammad Member level 3 Joined Jul 8, 2011 Messages 56 Helped 1 Reputation 2 Reaction score 1 Trophy points 1,288 Activity points 1,632 Code Verilog - [expand]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 module rippl( input [63:0] a, input [63:0] b, input cin, output [63:0] s, output cout ); wire temp[63:0]; assign temp[0]=cin; genvar i; always @(*) for(i=0;i<64;i=i+1) begin s[i]<=(a[i]^(b[i]^temp[i])); temp[i+1]<=(((a[i]&b[i])|(b[i]&temp[i]))|(temp[i]&a[i])); end assign cout=temp[63]; end endmodule Last edited by a moderator: Apr 12, 2015
Code Verilog - [expand]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 module rippl( input [63:0] a, input [63:0] b, input cin, output [63:0] s, output cout ); wire temp[63:0]; assign temp[0]=cin; genvar i; always @(*) for(i=0;i<64;i=i+1) begin s[i]<=(a[i]^(b[i]^temp[i])); temp[i+1]<=(((a[i]&b[i])|(b[i]&temp[i]))|(temp[i]&a[i])); end assign cout=temp[63]; end endmodule
Apr 11, 2015 #2 S std_match Advanced Member level 4 Joined Jul 9, 2010 Messages 1,331 Helped 465 Reputation 930 Reaction score 458 Trophy points 1,363 Location Sweden Activity points 10,366 You will avoid a lot of problems if you use blocking assignments "=" in combinatorial always blocks and non-blocking assignments "<=" in clocked always blocks until you understand when to break this rule.
You will avoid a lot of problems if you use blocking assignments "=" in combinatorial always blocks and non-blocking assignments "<=" in clocked always blocks until you understand when to break this rule.
Apr 11, 2015 #3 F fouwad Full Member level 4 Joined Nov 29, 2009 Messages 199 Helped 19 Reputation 38 Reaction score 17 Trophy points 1,298 Location Pakistan Activity points 2,466 what exactly is the error, need some explanation
Apr 11, 2015 #4 V vGoodtimes Advanced Member level 4 Joined Feb 16, 2015 Messages 1,089 Helped 307 Reputation 614 Reaction score 303 Trophy points 83 Activity points 8,730 temp is too small. The generate will assign to temp[63+1].
Apr 13, 2015 #5 ads-ee Super Moderator Staff member Joined Sep 10, 2013 Messages 7,944 Helped 1,823 Reputation 3,656 Reaction score 1,808 Trophy points 1,393 Location USA Activity points 60,208 vGoodtimes said: temp is too small. The generate will assign to temp[63+1]. Click to expand... besides that, it should be doing the following assign for cout to get the carry output of the add. Code: assign cout = temp[64];
vGoodtimes said: temp is too small. The generate will assign to temp[63+1]. Click to expand... besides that, it should be doing the following assign for cout to get the carry output of the add. Code: assign cout = temp[64];