⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complementary.v

📁 若干VHDL语言的源代码
💻 V
字号:
`include "Def_StructureParameter.v"

module complementary(out_Result,
			in_Operand);
			
output [`WordWidth-1:0] out_Result;
reg [`WordWidth-1:0] out_Result;

input [`WordWidth-1:0] in_Operand;

reg [`WordWidth-1:0] flag;

integer ssycnt;

always @(in_Operand)
begin
	flag=`WordZero;
	out_Result[0]=in_Operand[0];
	if(in_Operand[0]==1'b1)
		flag[0]=1'b1;
	for(ssycnt=1;ssycnt<`WordWidth;ssycnt=ssycnt+1)
	begin
		if(flag[ssycnt-1]==1'b1)
		begin
			//i have see a 1,now all will bw invert
			out_Result[ssycnt]=~in_Operand[ssycnt];
			flag[ssycnt]=1'b1;
		end
		else
		begin
			//i have not see a 1
			if(in_Operand[ssycnt]==1'b1)
			begin
				//now see a 1
				flag[ssycnt]=1'b1;
			end
			else
			begin
				flag[ssycnt]=1'b0;
			end
			out_Result[ssycnt]=in_Operand[ssycnt];
		end
	end
end

endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -