I having trouble with finding the smallest values of X and xfind and Y and yfind in `Costcalculator xfind (X,xcost); Costcalculator yfind (Y,ycost);
in code below. can someone comment please. For some reason I couldn't import the whole code. It just recognizes these lines as codes. Sorry if it is not clear.
always @(posedge clk) // sequential circuit
begin
Costcalculator xfind (X,xcost);
Costcalculator yfind (Y,ycost);
if(reset)
begin
i=0;
R<=0;
xcost<=0;
ycost<=0;
mode0<=0;
mode1<=0;
mode2<=0;
mode3<=0;
mode4<=0;
mode5<=0;
mode6<=0;
end //if end
else
begin
for (i=1; i<43; i=i+1)
begin
R<=xcost+ycost;
costholder <= SAD+(lambda*R); // Here we calculate the cost of a sub-blocks As the clock
if (i<17)
mode0<=costholder+mode0;
else if(i>16 && i<25)
mode1<=costholder+mode1;
else if(i>24 && i<33)
mode2<=costholder+mode2;
else if(i==33 || i==34 || i==35 || i==36 )
mode3<=costholder+mode3;
else if(i==37 || i==38)
mode4<=costholder+mode4;
else if(i==39 || i==40)
mode5<=costholder+mode5;
else if(i==41)
mode6<=costholder+mode6;
end //for end
end //else end
end //always end
Module Costcalculator:
//************************************************************
module Costcalculator (motionvector, cost); // X AND Y COST CALCULATOR
input [4:0]motionvector;
output [2:0]cost;
reg [2:0]cos;
wire [3:0] vector;
assign vector = {motionvector[3:0] };
always @* begin
case (vector) 0 : cos=0;
1,2 : cos=1;
3,4,5,6 : cos=2;
7,8,9,10,11,12,13,14 : cos=3;
15 : cos=4;
endcase
end
assign cost = cos;
endmodule
//************************************************************
Constcalculatoris a module. You can not instantiate a module in a procedural block.