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

📄 fncdemo.v

📁 一些自己编写的verilog代码
💻 V
字号:
// 'function' example

// Synthesizable module for a bit counter
// (accepts an 8-bit input, and reports the number of input bits
// that are set to 1)

module BitCounter (inbyte, numones);

input [7:0] inbyte;
output [3:0] numones;

reg [3:0] numones;


	// Create the output bus using a function call

always @ (inbyte)
	numones <= CountTheOnes( inbyte );


	// Declare the function

function [3:0] CountTheOnes;

	input [7:0] value;

	integer k, acc;

	begin
		acc = 0;
		for (k=0; k<8; k=k+1)
			if (value[k])
				acc = acc + 1;

		CountTheOnes = acc;
	end
endfunction

endmodule

⌨️ 快捷键说明

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