写了一个直方图均衡化的程序,但是不能综合,不知道是哪里出了问题,请大神指点
时间:10-02
整理:3721RD
点击:
module hist(clk,rst,im_input,im_output);
input clk;
input rst;
input [7:0] im_input;
output [7:0] im_output;
reg [7:0] im_output;
reg [14:0] hist_cnt [0:255]; //灰度计数,存入RAM
reg [14:0] hist_acc [0:255]; //灰度累加
reg [7:0] mem [0:16383]; // 存储像素值
reg [7:0] reshape[0:255]; //重新定义的灰度
reg[24:0] acul_reg;
reg [7:0] out_reg;
reg hist_cnt_en,hist_acc_en,cal_en,cal_over;
reg [14:0] i;
reg [8:0] j;
reg [8:0] k;
reg [14:0] l;
integer index;
parameter rate=10'b11_1111_1011;
always @(posedge clk or negedge rst)
begin
if(!rst)
begin
for(index=0; index<9'd256; index=index+1)
begin
hist_cnt[index]<=0;
hist_acc[index]<=0;
end
end
end
always @ (posedge clk or negedge rst)
begin
if(!rst)
begin
i<=0;
j<=1;
k<=0;
l<=0;
hist_cnt_en<=1;
hist_acc_en<=0;
cal_en<=0;
cal_over<=0;
end
else if(hist_cnt_en==1)
begin
mem[i]<=im_input;
hist_cnt[im_input]<=hist_cnt[im_input]+1;
i<=i+1;
if(i==16384)
begin
hist_cnt_en<=0;
hist_acc_en<=1;
cal_en<=0;
cal_over<=0;
hist_acc[0]<=hist_cnt[0];
end
end
else if(hist_acc_en<=1)
begin
hist_acc[j]<=hist_acc[j-1]+hist_cnt[j];
j<=j+1;
if(j==256)
begin
hist_cnt_en<=0;
hist_acc_en<=0;
cal_en<=1;
cal_over<=0;
end
end
else if(cal_en==1)
begin
acul_reg<=hist_acc[k]*rate;
reshape[k]<=acul_reg[23:16];
k<=k+1;
if(k==256)
begin
hist_cnt_en<=0;
hist_acc_en<=0;
cal_en<=0;
cal_over<=1;
end
end
else if(cal_over==1)
begin
out_reg<=reshape[mem[l]];
im_output<=out_reg;
l<=l+1;
if(l==16384)
begin
hist_cnt_en<=1;
hist_acc_en<=0;
cal_en<=0;
cal_over<=0;
end
end
end
endmodule
综合时出现问题:Map:116 - The design is empty. No processing will be done.
ERROR:Map:52 - Problem encountered processing RPMs.
感觉不知道是哪里出了问题
input clk;
input rst;
input [7:0] im_input;
output [7:0] im_output;
reg [7:0] im_output;
reg [14:0] hist_cnt [0:255]; //灰度计数,存入RAM
reg [14:0] hist_acc [0:255]; //灰度累加
reg [7:0] mem [0:16383]; // 存储像素值
reg [7:0] reshape[0:255]; //重新定义的灰度
reg[24:0] acul_reg;
reg [7:0] out_reg;
reg hist_cnt_en,hist_acc_en,cal_en,cal_over;
reg [14:0] i;
reg [8:0] j;
reg [8:0] k;
reg [14:0] l;
integer index;
parameter rate=10'b11_1111_1011;
always @(posedge clk or negedge rst)
begin
if(!rst)
begin
for(index=0; index<9'd256; index=index+1)
begin
hist_cnt[index]<=0;
hist_acc[index]<=0;
end
end
end
always @ (posedge clk or negedge rst)
begin
if(!rst)
begin
i<=0;
j<=1;
k<=0;
l<=0;
hist_cnt_en<=1;
hist_acc_en<=0;
cal_en<=0;
cal_over<=0;
end
else if(hist_cnt_en==1)
begin
mem[i]<=im_input;
hist_cnt[im_input]<=hist_cnt[im_input]+1;
i<=i+1;
if(i==16384)
begin
hist_cnt_en<=0;
hist_acc_en<=1;
cal_en<=0;
cal_over<=0;
hist_acc[0]<=hist_cnt[0];
end
end
else if(hist_acc_en<=1)
begin
hist_acc[j]<=hist_acc[j-1]+hist_cnt[j];
j<=j+1;
if(j==256)
begin
hist_cnt_en<=0;
hist_acc_en<=0;
cal_en<=1;
cal_over<=0;
end
end
else if(cal_en==1)
begin
acul_reg<=hist_acc[k]*rate;
reshape[k]<=acul_reg[23:16];
k<=k+1;
if(k==256)
begin
hist_cnt_en<=0;
hist_acc_en<=0;
cal_en<=0;
cal_over<=1;
end
end
else if(cal_over==1)
begin
out_reg<=reshape[mem[l]];
im_output<=out_reg;
l<=l+1;
if(l==16384)
begin
hist_cnt_en<=1;
hist_acc_en<=0;
cal_en<=0;
cal_over<=0;
end
end
end
endmodule
综合时出现问题:Map:116 - The design is empty. No processing will be done.
ERROR:Map:52 - Problem encountered processing RPMs.
感觉不知道是哪里出了问题
这个写法是典型的软件思维,要理解可综合的verilog是描述语言,描述的是硬件模块的功能和连接关系,在写之前的时候就要知道电路的样子,而不是写完后让工具看看能不能综合。
out_reg<=reshape[mem[l]]; 这样的语句,需要多少MUX或者比较器才能实现,考虑过吗?
典型软件工程师的写法啊,呵呵。
不能在不同的进程中对同一变量赋值,数组的序号不能为变量。
for循环要用计数器来实现 不能用软件思维串行方式来描述硬件
多多学习别人的代码怎么写的,再开始RTL吧,不然写出来的都是坑
软件工程师其实可以试试C转Verilog,cadence和mentor都有这样的工具,比自己学习Verilog RTL要靠谱
可以用ip核啊,不然太浪费资源,而且for循环是不可综合的语句
