|
【文件名】:0699@52RD_JPEG.rar
【格 式】:rar
【大 小】:40K
【简 介】:
【目 录】:
[UseMoney=3]
[/UseMoney]
module dct(//input
nrst,clk,
dcten,idcten,
din,
//output
transin,
octcntr,cntr,wen,
addr,dout
);
input nrst,clk;
input dcten,idcten;
input [`bw-1:0] din;
output transin;
output [3:0] octcntr;
output [3:0] cntr;
output wen;
output [5:0] addr;
output [`bw-1:0] dout;
//output [2*`bw-1:0] idctout;
wire [3:0] octcntr;
wire [`bw-1:0] dctout;
wire [2*`bw-1:0] idctout;
wire [`bw-1:0] dout=dctout;
wire [3:0] cntr;
dctctl dctctl(
//input
.nrst (nrst),
.clk (clk),
.dcten (dcten),
.idcten (idcten),
//output
.transin(transin),
.octcntr(octcntr),
.cntr (cntr),
.wen (wen),
.addr (addr));
dct_1d dct_1d(
//input
.nrst (nrst),
.clk (clk),
.dcten (dcten),
.idcten (idcten),
.din (din),
.cntr (cntr),
//output
.dctout (dctout),
.idctout(idctout));
endmodule
// post processing for IDCT
reg [`bw+2:0] fodd_d;
wire [`bw-1:0] b1=a5;//fodd_d;
wire [`bw-1:0] b3=a4;//scc2_o;
wire [`bw-1:0] m1=b1+b3;
wire [`bw-1:0] m2=b1-b3;
wire [`bw-1:0] m1_2=(m1[`bw-1]==1)?{2'b11,m1[`bw-1:2]}:{2'b0,m1[`bw-1:2]};
wire [`bw-1:0] m1_3=(m1[`bw-1]==1)?{{3{1'b1}},m1[`bw-1:3]}:{3'b0,m1[`bw-1:3]};
wire [`bw-1:0] m1_5=(m1[`bw-1]==1)?{{5{1'b1}},m1[`bw-1:5]}:{5'b0,m1[`bw-1:5]};
wire [`bw-1:0] m1_7=(m1[`bw-1]==1)?{{7{1'b1}},m1[`bw-1:7]}:{7'b0,m1[`bw-1:7]};
wire [`bw-1:0] m2_2=(m2[`bw-1]==1)?{2'b11,m2[`bw-1:2]}:{2'b0,m2[`bw-1:2]};
wire [`bw-1:0] m2_3=(m2[`bw-1]==1)?{{3{1'b1}},m2[`bw-1:3]}:{3'b0,m2[`bw-1:3]};
wire [`bw-1:0] m2_5=(m2[`bw-1]==1)?{{5{1'b1}},m2[`bw-1:5]}:{5'b0,m2[`bw-1:5]};
wire [`bw-1:0] m2_7=(m2[`bw-1]==1)?{{7{1'b1}},m2[`bw-1:7]}:{7'b0,m2[`bw-1:7]};
wire [`bw-1:0] ae1 =(dcten&f0_en)? a0:idcten?m1:0;
wire [`bw-1:0] ae2 =(dcten&f1_en)? a1:idcten?m2:0;
wire [`bw-1:0] ae3 =(dcten&f0_en)?~a2:idcten?m1_5:0;
wire [`bw-1:0] ae4 =(dcten&f1_en)?~a3:idcten?m2_5:0;
wire [`bw-1:0] ae5 =(dcten&f0_en)? a4:idcten?m1_2:0;
wire [`bw-1:0] ae6 =(dcten&f1_en)? a5:idcten?m2_2:0;
wire [`bw-1:0] ae7 =(dcten&f0_en)?~a6:idcten?m1_3:0;
wire [`bw-1:0] ae8 =(dcten&f1_en)?~a7:idcten?m2_3:0;
wire [`bw-1:0] sgn1= dcten?{10'b0,2'b10}:idcten? m1_7:0;
wire [`bw-1:0] sgn2= dcten?{10'b0,2'b10}:idcten? m2_7:0;
//当2D-DCT做完时,做QUANTIZE
//qen 就是 quantize enable, qen=1時做Quantize
wire qenstart=(transin==1)&(octcntr==0)&(cntr==8);
wire qenstop =(transin==0)&(octcntr==15)&(cntr==8);
reg qen;
always @(posedge clk or negedge nrst)
if (~nrst) qen<=0;
else if (qenstart) qen<=1;
else if (qenstop) qen<=0;
reg [5:0] qwptr;
always @(posedge clk or negedge nrst)
if (~nrst) qwptr<=0;
else if (qwptr==63) qwptr<=qwptr;
else qwptr<=qwptr+1;
wire [2:0] ocntr_top=(&octcntr==1)?7:octcntr-1;
assign qrptr={ocntr_top,3'b0}+(cntr-1);
wire qram64_wen=~dcten;
wire [5:0] qram64_addr=dcten? (qen?qrptr:0) : qwptr;
wire [7:0] zzout;
//=======================================================
// 做IDCT时,数据从Transpose buffer读入DCT module时候的
// 顺序必须是FX(2)->FX(4)->FX(6)->FX(8)->
// FX(3)->FX(7)->FX(1)->FX(5)
//=======================================================
// 做DCT的顺序是FX(1)->FX(5)->FX(3)->FX(7)->
// FX(2)->FX(4)->FX(8)->FX(6)
wire [5:0] addr;
wire [`bw-1:0] dout;
wire [15:0] transout;
wire [15:0] dctdin=(dout[`bw-1]==1)?{4'b1111,dout}:{4'b0,dout};
wire [11:0] din= transin?transout : dinran;
//=======================================================
// multiplier 利用乘法替代 Quantization的除法
//wire [5:0] dqptr;
//assign dctout=qen?dout:0;
//wire [`bw+7:0] dctdiv;
//
//wire [7:0] dqout= dctdiv[17:10];
//wire [5:0] dq_addr= ~qen? dqptr: //見见 ./doc/程式解說程序解释.bmp
// qram64_addr;
wire [5:0] dqptr;
assign dctout=qen?dout:0;
wire [`bw+7:0] dctdiv;
wire [7:0] dqout= dctdiv[17:10];
wire [5:0] dq_addr= ~qen? dqptr: //見 ./doc/程式解說.bmp
qram64_addr; |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|