yupina-chan
Member level 2
- Joined
- Nov 27, 2013
- Messages
- 51
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 397
hi. i have made a module for rgb to hsv conversion. i also made the testbench. it compiles with no error but in modelsim, it stops halfway and it says:
"Instantiation of 'histogram' failed. The design unit was not found."
no idea where that histogram come from or what this statement means. below is my code for the module. how can i go about this? i really need to make this work. thanks in advance.
i used '%' and '/'. does it have something to do with these? by the way, i am using altera cyclone ii. i based my computations from a book and have also tested in matlab which worked. please enlighten me.
"Instantiation of 'histogram' failed. The design unit was not found."
no idea where that histogram come from or what this statement means. below is my code for the module. how can i go about this? i really need to make this work. thanks in advance.
i used '%' and '/'. does it have something to do with these? by the way, i am using altera cyclone ii. i based my computations from a book and have also tested in matlab which worked. please enlighten me.
Code:
module rgb2hsv(//from SDRAM
iRed,
iGreen,
iBlue,
//output
oHue,
oSat,
oVal,
//control signal
iCLK,
iRST_N
);
//from SDRAM
input [7:0] iRed;
input [7:0] iGreen;
input [7:0] iBlue;
//output
output reg [7:0] oHue;
output reg [7:0] oSat;
output reg [7:0] oVal;
// Control Signal
input iCLK;
input iRST_N;
reg [7:0] maxim;
reg [7:0] minim;
wire [7:0] dif;
wire [7:0] a;
//calculate max
always @ (posedge iCLK or negedge iRST_N)
begin
if(!iRST_N)
begin
maxim <= 0;
end
else
begin
if (iRed >= iGreen && iRed >= iBlue)
begin
maxim <= iRed;
end
else if (iGreen >= iRed && iGreen >= iBlue)
begin
maxim <= iGreen;
end
else if (iBlue >= iGreen && iBlue >= iRed)
begin
maxim <= iBlue;
end
end
end
//calculate min
always @ (posedge iCLK or negedge iRST_N)
begin
if(!iRST_N)
begin
minim <= 0;
end
else
begin
if (iRed <= iGreen && iRed <= iBlue)
begin
minim <= iRed;
end
else if (iGreen <= iRed && iGreen <= iBlue)
begin
minim <= iGreen;
end
else if (iBlue <= iGreen && iBlue <= iRed)
begin
minim <= iBlue;
end
end
end
//calculate max-min
assign dif = maxim - minim;
assign a = ((iGreen - iBlue) * 60)/dif;
//compute for hue
always @ (posedge iCLK or negedge iRST_N)
begin
if(!iRST_N)
begin
oHue <= 0;
end
else
begin
if (iRed >= iGreen && iRed >= iBlue)
begin
oHue <= a % 360;
end
else if (iGreen >= iRed && iGreen >= iBlue)
begin
oHue <= (((iBlue - iRed) * 60)/dif) + 120;
end
else if (iBlue >= iRed && iBlue >= iGreen)
begin
oHue <=(((iRed-iGreen) * 60)/dif) + 240;
end
else
begin
oHue <= 0;
end
end
end
//compute for value
always @ (posedge iCLK or negedge iRST_N)
begin
if(!iRST_N)
begin
oVal <= 0;
end
else
begin
oVal <= maxim;
end
end
//compute for saturation
always @ (posedge iCLK or negedge iRST_N)
begin
if(!iRST_N)
begin
oSat <= 0;
end
else
begin
if (maxim == 0)
begin
oSat <= 0;
end
else
begin
oSat <= dif/maxim;
end
end
end
endmodule