imagerotate(新)

  • 格式:txt
  • 大小:3.31 KB
  • 文档页数:2
begin
if(START&(~RST))
begin
if(W_OR_R & (~lock_1))
begin
RAMM[number]<=IMAGE_IN;
IMAGE_OUT<=IMAGE_Z;
end
else if ((~(W_OR_R))&(~lock_2))
R_FINISH<=1'b1;
end
else
begin
count_arrange_1<=ROW_ZERO;
count_row_1<=count_row_1+1'b1;
end
end
end
endmodule
reg W_FINISH,R_FINISH;
reg [ROW_LENGTH-1:0] count_row,count_arrange_1;
reg [ARRANGE_LENGTH-1:0] count_arrange,count_row_1;
reg lock_1,lock_2;
reg [ROW_LENGTH+ARRANGE_LENGTH-1:0] number;
input [IMAGE_LENGTH-1:0] IMAGE_IN;
input START,W_OR_R,CLK,RST;
output [IMAGE_LENGTH-1:0] IMAGE_OUT;
output W_FINISH,R_FINISH;
reg [IMAGE_LENGTH-1:0] IMAGE_OUT;
ARRANGE_ZERO=8'b0000_0000,
ROW_LENGTH=8,
ARRANGE_LENGTH=8,
NUMBER_RST=16'b0000_0000_0000_0000,
RAM_LENGTH=65536;
begin
if(RST)
begin
count_arrange_1<=ROW_ZERO;
count_row_1<=ARRANGE_ZERO;
R_FINISH<=1'b0;
lock_2<=1'b0;
end
else
begin
if(START&(~lock_2)&(~(W_OR_R)))
if(count_arrange==ARRANGE_MAX)
begin
if(count_row==ROW_MAX)
begin
lock_1<=1'b1;
count_arrange<=ARRANGE_ZERO;
begin
if(count_arrange_1==ROW_MAX)
begin
begin
lock_2<=1'b1;
count_arrange_1<=ROW_ZERO;
count_row_1<=ARRANGE_ZERO;
end
end
else
begin
count_arrange<=count_arrange+1'b1;
count_row<=count_row;
end
end
end
end
always @(posedge CLK )
//////////////////////////////////////////////////////////////////////////////////////
// FileName: "Imagerotate.v"
// Author : Xiaoqiu-Zhou
// This module is clockwise rotate 90 degree .The arrange may 2^n and row may any.
parameter IMAGE_LENGTH=24,
IMAGE_Z=24'bz,
IMAGE_ZERO=24'b0,
ROW_MAX=8'b1111_1111,
ROW_ZERO=8'b0000_0000,
ARRANGE_MAX=8'b1111_1111,
begin
IMAGE_OUT<=RAMM[number];
RAMM[number]<=IMAGE_ZERO;
end
else
IMAGE_OUT<=IMAGE_Z;
end
else
IMAGE_OUT<=IMAGE_Z;
if(RST)
number=NUMBER_RST;
else
begin
if(W_OR_R)
number=({ARRANGE_ZERO,count_row}<<ARRANGE_LENGTH )+count_arrange;
else
number=({ARRANGE_ZERO,row}<<ARRANGE_LENGTH)+arrange;
//
//////////////////////////////////////////////////////////////////////////////////////
module imagerotate (IMAGE_IN,START,W_OR_R,CLK,RST,IMAGE_OUT,W_FINISH,row_1 or count_arrange_1 or RST or W_OR_R or count_row or count_arrange)
begin
arrange=count_row_1;
row=ROW_MAX+(~count_arrange_1)+1'b1;
count_row<=ROW_ZERO;
count_arrange<=ARRANGE_ZERO;
W_FINISH<=1'b0;
lock_1<=1'b0;
end
else
begin
if(START&(~lock_1)&W_OR_R)
begin
reg [IMAGE_LENGTH-1:0] RAMM [RAM_LENGTH-1:0];
reg [ROW_LENGTH-1:0]row;
reg [ARRANGE_LENGTH-1:0]arrange;
always @(posedge CLK )
begin
if(RST)
begin
end
else
begin
count_arrange_1<=count_arrange_1+1'b1;
count_row_1<=count_row_1;
end
end
end
end
always @(posedge CLK)
count_row<=ROW_ZERO;
W_FINISH<=1'b1;
end
else
begin
count_arrange<=ARRANGE_ZERO;
count_row<=count_row+1'b1;

下载文档原格式

  / 2

相关主题