// Test file for getting power numbers for different cases // Vermix stimulus file. // Default verimix stimulus. // You are required to report individual power numbers and // the average power numbers for all the cases // *********ASSUMPTIONS***************** // X and Y are the two inputs // S is the output of the adder // Cout is the carry out of the adder // testsum is the test output for check purposes. // // If you used Cin, please set it to 1'b0 in the // initializations part. // declaring testsum reg[32:0] testsum; initial begin // initializations. $display("Starting ... "); Cin = 1'b0; X[31:0] = 32'b00000000000000000000000000000000; Y[31:0] = 32'b00000000000000000000000000000000; #20 // CASE 1. ripple the carry to the first bit. // should be a low power case. Y[31:0] = 32'b00000000000000000000000000000001; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); // CASE 2. worst case for some circuits. // Propagating Cin to Cout // x = 0xFFFFFFFF, Y = 0x00000001 X[31:0]=32'hffffffff; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); // CASE 3. setting all bits of output to 1. // X = 0xaaaaaaaa,Y=0x55555555 and Cin=0. X[31:0] = 32'b10101010101010101010101010101010; Y[31:0] = 32'b01010101010101010101010101010101; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 3.5 - get things back to 0 X[31:0] = 32'b00000000000000000000000000000000; Y[31:0] = 32'b00000000000000000000000000000000; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); // CASE 4. all ones on X and Y // X = 0xffffffff and Y =0xffffffff and Cin=0 X[31:0] = 32'hffffffff; Y[31:0] = 32'hffffffff; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); // CASE 5. Inverting bits at output X[31:0] = 32'h00000001; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); // On to random checks.... // CASE 6 X[31:0] = 32'hf20af20a; Y[31:0] = 32'h00200020; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 7. X[31:0] = 32'h88888888; Y[31:0] = 32'h01000100; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 8. X[31:0] = 32'h55555555; Y[31:0] = 32'h11119999; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 9 X[31:0] = 32'h08000001; Y[31:0] = 32'h7ffffffe; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 10 X[31:0] = 32'h55555555; Y[31:0] = 32'h808a808a; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 11 X[31:0] = 32'h12345678; Y[31:0] = 32'h87654321; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 12 X[31:0] = 32'hF0F05959; Y[31:0] = 32'h1F1F9595; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 13 X[31:0] = 32'h0ECE5830; Y[31:0] = 32'h00C56830; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 14 X[31:0] = 32'h38475620; Y[31:0] = 32'h46239837; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 15 X[31:0] = 32'hbcdabdcf; Y[31:0] = 32'habefcdba; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); //CASE 16 X[31:0] = 32'h1b3a7f9c; Y[31:0] = 32'ha3f5c8b3; #20 testsum = X + Y; $display("X = %d, Y = %d, S = %d, Cout = %d", X, Y, S, Cout); if (S != testsum[31:0]) $display("ERROR: S should be %d, is %d instead", testsum[31:0], S); if (Cout != testsum[32]) $display("ERROR: Cout should be %d, is %d instead", testsum[32], Cout); $display("Tests finished...."); end