Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020778
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:16:14+00:00 2026-05-20T10:16:14+00:00

I m trying to simulate a tree type comparator for synthesis. It has two

  • 0

I m trying to simulate a tree type comparator for synthesis. It has two blocks and i used repetitive tasks to achieve it. But my test bench is showing errors . Can anybody try this

 module main_fn (A,B,G,L,E,g,l,e);
  input [31:0] A;
  input [31:0] B; 
  output [61:0]g;
  output [61:0]l;
  output [61:0]e;
  wire G_temp,E_temp,L_temp;
  output G,L,E;

  compare1 cp1_1(A[0],B[0],g[0],l[0],e[0]);
  compare1 cp1_2(A[l],B[l],g[1],l[1],e[1]);
  compare1 cp1_3(A[2],B[2],g[2],l[2],e[2]);
  compare1 cp1_4(A[3],B[3],g[3],l[3],e[3]);
  compare1 cp1_5(A[4],B[4],g[4],l[4],e[4]);
  compare1 cp1_6(A[5],B[5],g[5],l[5],e[5]);
  compare1 cp1_7(A[6],B[6],g[6],l[6],e[6]);
  compare1 cp1_8(A[7],B[7],g[7],l[7],e[7]);
  compare1 cp1_9(A[8],B[8],g[8],l[8],e[8]);
  compare1 cp1_10(A[9],B[9],g[9],l[9],e[9]);
  compare1 cp1_11(A[10],B[10],g[10],l[10],e[10]);
  compare1 cp1_12(A[11],B[11],g[11],l[11],e[11]);
  compare1 cp1_13(A[12],B[12],g[12],l[12],e[12]);
  compare1 cp1_14(A[13],B[13],g[13],l[13],e[13]);
  compare1 cp1_15(A[14],B[14],g[14],l[14],e[14]);
  compare1 cp1_16(A[15],B[15],g[15],l[15],e[15]);
  compare1 cp1_17(A[16],B[16],g[16],l[16],e[16]);
  compare1 cp1_18(A[17],B[17],g[17],l[17],e[17]);
  compare1 cp1_19(A[18],B[18],g[18],l[18],e[18]);
  compare1 cp1_20(A[19],B[19],g[19],l[19],e[19]);
  compare1 cp1_21(A[20],B[20],g[20],l[20],e[20]);
  compare1 cp1_22(A[21],B[21],g[21],l[21],e[21]);
  compare1 cp1_23(A[22],B[22],g[22],l[22],e[22]);
  compare1 cp1_24(A[23],B[23],g[23],l[23],e[23]);
  compare1 cp1_25(A[24],B[24],g[24],l[24],e[24]);
  compare1 cp1_26(A[25],B[25],g[25],l[25],e[25]);
  compare1 cp1_27(A[26],B[26],g[26],l[26],e[26]);
  compare1 cp1_28(A[27],B[27],g[27],l[27],e[27]);
  compare1 cp1_29(A[28],B[28],g[28],l[28],e[28]);
  compare1 cp1_30(A[29],B[29],g[29],l[29],e[29]);
  compare1 cp1_31(A[30],B[30],g[30],l[30],e[30]);
  compare1 cp1_32(A[31],B[31],g[31],l[31],e[31]);

  compare2 cp2_1(g[0],g[1],l[0],l[1],e[0],e[1],g[32],l[32],e[32]);
  compare2 cp2_2(g[2],g[3],l[2],l[3],e[2],e[3],g[33],l[33],e[33]);
  compare2 cp2_3(g[4],g[5],l[4],l[5],e[4],e[5],g[34],l[34],e[34]);
  compare2 cp2_4(g[6],g[7],l[6],l[7],e[6],e[7],g[35],l[35],e[35]);
  compare2 cp2_5(g[8],g[9],l[8],l[9],e[8],e[9],g[36],l[36],e[36]);
  compare2 cp2_6(g[10],g[11],l[10],l[11],e[10],e[11],g[37],l[37],e[37]);
  compare2 cp2_7(g[12],g[13],l[12],l[13],e[12],e[13],g[38],l[38],e[38]);
  compare2 cp2_8(g[14],g[15],l[14],l[15],e[14],e[15],g[39],l[39],e[39]);
  compare2 cp2_9(g[16],g[17],l[16],l[17],e[16],e[17],g[40],l[40],e[40]);
  compare2 cp2_10(g[18],g[19],l[18],l[19],e[18],e[19],g[41],l[41],e[41]);
  compare2 cp2_11(g[20],g[21],l[20],l[21],e[20],e[21],g[42],l[42],e[42]);
  compare2 cp2_12(g[22],g[23],l[22],l[23],e[22],e[23],g[43],l[43],e[43]);
  compare2 cp2_13(g[24],g[25],l[24],l[25],e[24],e[25],g[44],l[44],e[44]);
  compare2 cp2_14(g[26],g[27],l[26],l[27],e[26],e[27],g[45],l[45],e[45]);
  compare2 cp2_15(g[28],g[29],l[28],l[29],e[28],e[29],g[46],l[46],e[46]);
  compare2 cp2_16(g[30],g[31],l[30],l[31],e[30],e[31],g[47],l[47],e[47]);

  compare2 cp3_1(g[32],g[33],l[32],l[33],e[32],e[33],g[48],l[48],e[48]);
  compare2 cp3_2(g[34],g[35],l[34],l[35],e[34],e[35],g[49],l[49],e[49]);
  compare2 cp3_3(g[36],g[37],l[36],l[37],e[36],e[37],g[50],l[50],e[50]);
  compare2 cp3_4(g[38],g[39],l[38],l[39],e[38],e[39],g[51],l[51],e[51]);
  compare2 cp3_5(g[40],g[41],l[40],l[41],e[40],e[41],g[52],l[52],e[52]);
  compare2 cp3_6(g[42],g[43],l[42],l[43],e[42],e[43],g[53],l[53],e[53]);
  compare2 cp3_7(g[44],g[45],l[44],l[45],e[44],e[45],g[54],l[54],e[54]);
  compare2 cp3_8(g[46],g[47],l[46],l[47],e[46],e[47],g[55],l[55],e[55]);

  compare2 cp4_1(g[48],g[49],l[48],l[49],e[48],e[49],g[56],l[56],e[56]);
  compare2 cp4_2(g[50],g[51],l[50],l[51],e[50],e[51],g[57],l[57],e[57]);
  compare2 cp4_3(g[52],g[53],l[52],l[53],e[52],e[53],g[58],l[58],e[58]);
  compare2 cp4_4(g[54],g[55],l[54],l[55],e[54],e[55],g[59],l[59],e[59]);

  compare2 cp5_1(g[56],g[57],l[56],l[57],e[56],e[57],g[60],l[60],e[60]);
  compare2 cp5_2(g[58],g[59],l[58],l[59],e[58],e[59],g[61],l[61],e[61]);

  compare2 cp6(g[60],g[61],l[60],l[61],e[60],e[61],G_temp,L_temp,E_temp);

  assign G=~G_temp;
  assign L=~L_temp;
  assign E=~E_temp;

task compare1(
  input a,b,
  output g,l,e);
  reg w1;
begin
    w1= ~(a&b);
    g= ~(a&w1);
    l= ~(b&w1);
    e= ~(g&l);
end
endtask

task compare2(
  input a0,a1,b0,b1,c0,c1,
  output gg,ll,ee);
  reg p1,p2;
begin
   p1=c1|a0;
   p2=c1|b0;
   gg=p1&a1;
   ll=p2&b1;
   ee=c0|c1;
end
endtask

endmodule 

module testbench;
reg [31:0]A;
reg [31:0]B;
wire [61:0] g,l,e;
wire G,L,E;
main_fn  mf1(A,B,G,L,E,g,l,e);
initial
begin
$monitor(,$time," a0 = %b b0= %b A=%b, B=%b, G=%b, L=%b, E=%b,g=%b,l=%b,e=%b",A[0],B[0],A,B,G,L,E,g,l,e);
#0  A=32'b01010101010101010101010101010101;B=32'b10101010101010101010101010101010;
#100  A=32'b10101010101010101010101010101010;B=32'b01010101010101010101010101010101;
#200  A=32'b01010101010101010101010101010101;B=32'b01010101010101010101010101010101;
end
endmodule

And my test bench is giving the following output

run -all
#                     0 a0 = 1 b0= 0 A=01010101010101010101010101010101, B=10101010101010101010101010101010, G=0, L=1, E=0,g=11111111111111111111111111111x101010101010101010101010101010x0,l=00000000000000000000000000000x010101010101010101010101010101x1,e=111111111111111111111111111111111111111111111111111111111111x1
#                   100 a0 = 0 b0= 1 A=10101010101010101010101010101010, B=01010101010101010101010101010101, G=1, L=0, E=0,g=00000000000000000000000000000x010101010101010101010101010101x1,l=11111111111111111111111111111x101010101010101010101010101010x0,e=111111111111111111111111111111111111111111111111111111111111x1
#                   300 a0 = 1 b0= 1 A=01010101010101010101010101010101, B=01010101010101010101010101010101, G=x, L=x, E=x,g=1x111x1111111x111111111111111x111111111111111111111111111111x1,l=1x111x1111111x111111111111111x111111111111111111111111111111x1,e=0x000x0000000x000000000000000x000000000000000000000000000000x0

Thanx in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:16:15+00:00Added an answer on May 20, 2026 at 10:16 am

    Change (lower-case L’s):

      compare1 cp1_2(A[l],B[l],g[1],l[1],e[1]);
    

    to (1’s):

      compare1 cp1_2(A[1],B[1],g[1],l[1],e[1]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to fashion a solution which will simulate App_Offline.htm for remote access but
I'm learning UML by trying to simulate how a car service garage works with
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I am trying to simulate keyboard shortcuts such as (Ctrl + A, Ctrl +
I am trying to simulate a scenario where connection to the server of one
I'm trying to simulate a real-time network where nodes are consumers and producers of
I'm trying to simulate an actual tab key press in JavaScript. I don't want
I am trying to simulate a problem we have with a particular domain ID
I'm trying to simulate the InstallURL property of a VS.net install MSI... I've got
I'm trying to simulate a click on an anchor tag using jQuery. I've been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.