艾之轨迹吧 关注:9贴子:80
  • 0回复贴,共1

这个控制逻辑居然要我写了这么多行

只看楼主收藏回复

module next_address_control (address,lev,line_read_finish,line_read_start,
row_write_start,row_write_finish,read_finish,write_finish,clk);
input row_write_start,line_read_start;
input clk;
input lev;
output line_read_finish,row_write_finish,read_finish,write_finish;
output [17:0]address;
reg [17:0]address,address_reg;
reg [8:0]count1,count2,count4,count5;
reg count3;
reg line_read_finish,row_write_finish,read_finish,write_finish; initial
begin
count1=0;
count2=0;
count3=0;
address_reg=0;
address=0;
line_read_finish=0;
row_write_finish=0;
end always@(posedge clk)
begin
if((line_read_start==1)&&(row_write_start==0)&&(lev==1))
begin
address=address_reg+count1;
count1=count1+1;
if ((count1==512)&&(count2!=512))
begin
count2=count2+1;
count1=0;
address_reg=address_reg+512;
line_read_finish=1;
/*after Controller receiving this signal,it will set line_read_start=0*/
end
else if ((count1==512)&&(count2==512))
begin
count2=0;
count1=0;
address_reg=0;
read_finish=1;
/*after Controller receiving this signal,it will set line_read_start=0*/
end
end
else if((row_write_start==1)&&(line_read_start==0)&&(lev==1))
begin
if(!count3)
begin
address=address_reg+256<<9;
end
else if(count3)
begin
address=address_reg;
address_reg=address_reg+1;
count4=count4+1;
end
count3=count3+1;
if ((count4==512)&&(count5!=256))
begin
count5=count5+1;
count4=0;
row_write_finish=1;
end
else if ((count4==512)&&(count5==256))
begin
count4=0;
count5=0;
write_finish=1;
end
end if((line_read_start==1)&&(row_write_start==0)&&(lev==2))
begin
address=address_reg+count1;
count1=count1+1;
if ((count1==256)&&(count2!=256))
begin
count2=count2+1;
count1=0;
address_reg=address_reg+512;
line_read_finish=1;
/*after Controller receiving this signal,it will set line_read_start=0*/
end
else if ((count1==256)&&(count2==256))
begin
count2=0;
count1=0;
address_reg=0;
read_finish=1;
/*after Controller receiving this signal,it will set line_read_start=0*/
end
end
else if((row_write_start==1)&&(line_read_start==0)&&(lev==2))
begin
if(!count3)
begin
address=address_reg+128<<9;
end
else if(count3)
begin
address=address_reg;
address_reg=address_reg+1;
count4=count4+1;
end
count3=count3+1;
if ((count4==256)&&(count5!=128))
begin
count5=count5+1;
count4=0;
row_write_finish=1;
end
else if ((count4==256)&&(count5==128))
begin
count4=0;
count5=0;
write_finish=1;
end
end
end endmodule


1楼2012-04-20 17:32回复