16位数字相关器verilog程序

来源:百度知道 编辑:UC知道 时间:2024/06/19 12:31:03
一个固定输入数据为EB90H,谢谢了

1. 如果固定数据多的话,可以使用rom 来实现
2. EB90H ,可以使用ASCII码,翻译成 069 066 041 032 104
现在都是数字了 再把这个转成16进制

module correlation (a,out,clk);
parameter b=16'heb90;
input clk;
input[15:0] a;
output[4:0] out;

wire[15:0] temp;
reg[4:0] out;
integer i;

assign temp=a^b;

always @(posedge clk)
begin
out=0;
for(i=0;i<16;i=i+1)
if(temp[i]==0)
out=out+1;
end
endmodule