appu1985
Member level 2
Code:
module system(clk,mode,x,p,pim);
parameter elements = 10; //This is the number of processing elements we want to have it in our design.
input clk;
input [1:0]mode;
input [7:0]x;
input [3:0]p;
output [3:0]pim;
wire [elements:0] conti;
wire [elements:0] contx;
wire [elements:0] contp;
wire [elements:0] contpsw;
wire [elements:0] contpsy;
wire [7:0]tempi;
wire [7:0]tempx;
wire [3:0]tempp;
wire [7:0]temppsw;
wire [15:0]temppsy;
genvar n;
reg [15:0]count;
reg [15:0]arrayy [15:0];
reg [15:0]sumy;
reg [15:0]temp;
reg [15:0]min;
reg [3:0]index;
integer i;
//Below is the instantiation of the Processing Elements to be used. for processing
always @(posedge clk)
count <= count + 1;
assign contx[0] = x;
assign conti[0] =count;
//assign contpsw[0]=0;
//assign contpsy[0]=0;
assign contp[0]= p;
generate for ( n=0;n<elements;n=n+1)
begin : pelements
pe3 process(clk,conti[n],contx[n],contp[n],contpsw[n],contpsy[n],mode,conti[n+1],contx[n+1],contp[n+1],contpsw[n+1],contpsy[n+1]);
end
endgenerate
assign tempi = conti[elements];
assign tempx = contx[elements];
assign tempp = contp[elements];
assign temppsw = contpsw[elements];
assign temppsy = contpsy[elements];
always @(posedge clk)
begin
if(mode == 2'b11)
begin
sumy <= sumy + temppsy;
if(contp[elements] != contp[elements-1])
begin
arrayy[tempp] <= sumy;
end
end
end
always @(posedge clk)
begin
if(tempp == 15)
begin
index <= 0;
min <= arrayy[index];
for (i=1;i<16;i=i+1)
begin
if(min > arrayy[i])
begin
min <= arrayy[i];
index <= i;
//Search for min in the arrayy and then identify the index of it and display the output
end
end
end
end
assign pim = index;
endmodule
In the above code I am trying to implement 10 elemenst which are connected one after the another now the output of the last element is stored in a array when the size is reached it is stored in an array y now we search for the minimum value in it but the code is synthesizing to something arbid pls have a look