Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] rgb to hsv conversion simulation

Status
Not open for further replies.

yupina-chan

Member level 2
Member level 2
Joined
Nov 27, 2013
Messages
51
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Visit site
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.

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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top