data/full_repos/permissive/123218339/neighborSinkInOtherCluster.v
data/verilator_xmls/64c83a13-fc36-4af7-a9f3-aea29ed252e7.xml
module neighborSinkInOtherCluster(clock, nrst, start, address, data_in, MY_CLUSTER_ID, forAggregation, done);
	input clock, nrst, start;
	input [`WORD_WIDTH-1:0] data_in, MY_CLUSTER_ID;
    output forAggregation, done;
    output [`WORD_WIDTH-1:0] address;


    reg forAggregation_buf, done_buf;
    reg [`WORD_WIDTH-1:0] address_count, i, j;
    reg [`WORD_WIDTH-1:0] neighborID, clusterID, knownSinks;
    reg [1:0] state;
     
    always @ (posedge clock) begin
        if (!nrst) begin
            forAggregation_buf <= 0;
            done_buf <= 0;
            address_count <= 16'h48;
            state <= 0;
            i <= 0;
            j <= 0;
        end
        else begin
            if (start && !done_buf) begin

                case (state)
                    2'd0: begin

                        neighborID = data_in;
                        state = 2'd1;
                        address_count = 16'hC8 + 2*i;
                    end

                    2'd1: begin

                        clusterID = data_in;
                        state = 2'd2;
                        address_count = 16'h8 + 2*j;
                    end

                    2'd2: begin

                        knownSinks = data_in;



                        $display("%d,%d,%d,%d,%d", neighborID, clusterID, knownSinks, i, j);
                        if ((neighborID == knownSinks) && (clusterID != MY_CLUSTER_ID)) begin
                            forAggregation_buf = 1;
                            done_buf = 1;

                        end

                        j = j + 1;
                        address_count = 16'h8 + 2*j;

                        if (j == 16) begin
                            j = 0;
                            i = i + 1;
                            state = 2'd0;
                            address_count = 16'h48 + 2*i;
                        end

                        if (i == 64) begin
                            done_buf = 1;

                        end
                    end
                endcase
            end
        end        
    end
    
    assign done = done_buf;
    assign address = address_count;
    assign forAggregation = forAggregation_buf;
endmodule
module neighborSinkInOtherCluster(clock, nrst, start, address, data_in, MY_CLUSTER_ID, forAggregation, done);

	input clock, nrst, start;
	input [`WORD_WIDTH-1:0] data_in, MY_CLUSTER_ID;
    output forAggregation, done;
    output [`WORD_WIDTH-1:0] address;


    reg forAggregation_buf, done_buf;
    reg [`WORD_WIDTH-1:0] address_count, i, j;
    reg [`WORD_WIDTH-1:0] neighborID, clusterID, knownSinks;
    reg [1:0] state;
     
    always @ (posedge clock) begin
        if (!nrst) begin
            forAggregation_buf <= 0;
            done_buf <= 0;
            address_count <= 16'h48;
            state <= 0;
            i <= 0;
            j <= 0;
        end
        else begin
            if (start && !done_buf) begin

                case (state)
                    2'd0: begin

                        neighborID = data_in;
                        state = 2'd1;
                        address_count = 16'hC8 + 2*i;
                    end

                    2'd1: begin

                        clusterID = data_in;
                        state = 2'd2;
                        address_count = 16'h8 + 2*j;
                    end

                    2'd2: begin

                        knownSinks = data_in;



                        $display("%d,%d,%d,%d,%d", neighborID, clusterID, knownSinks, i, j);
                        if ((neighborID == knownSinks) && (clusterID != MY_CLUSTER_ID)) begin
                            forAggregation_buf = 1;
                            done_buf = 1;

                        end

                        j = j + 1;
                        address_count = 16'h8 + 2*j;

                        if (j == 16) begin
                            j = 0;
                            i = i + 1;
                            state = 2'd0;
                            address_count = 16'h48 + 2*i;
                        end

                        if (i == 64) begin
                            done_buf = 1;

                        end
                    end
                endcase
            end
        end        
    end
    
    assign done = done_buf;
    assign address = address_count;
    assign forAggregation = forAggregation_buf;
endmodule