Professional Documents
Culture Documents
`define bw 12
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
.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
Search codes
`timescale 1ns/10ps
`define bw 12
module dct_1d(//input
nrst,clk,
dcten,idcten,
din,cntr,
//output
dctout,idctout //¦h¾l
);
input nrst,clk;
input dcten,idcten;
input [`bw-1:0] din;
input [3:0] cntr;
//========================================================
// ¦b dct mode®É
// need to do reordering pre-processing
//========================================================
wire scc2en =(dcten)? ((cntr==1) | (cntr==2)):
(idcten)?((cntr==5) | (cntr==6)):0 ;
wire scc2en_d =(dcten)? ((cntr==2) | (cntr==3)):
(idcten)? ((cntr==6) | (cntr==7)):0 ;
wire a0en=(cntr==1);
wire a1en=(cntr==2);
wire a2en=(cntr==5);
wire a3en=(cntr==3);
wire a4en=(cntr==8);
wire a5en=(cntr==7);
wire a6en=(cntr==4);
wire a7en=(cntr==6);
wire sub1en=dcten?a0en:idcten?a2en:0;
wire sub2en=dcten?a1en:idcten?a7en:0;
wire sub3en=dcten?a3en:idcten?a5en:0;
wire sub4en=dcten?a6en:idcten?a4en:0;
wire scc4en=dcten?(a0en|a1en|a3en|a6en):
idcten?(a2en|a7en|a5en|a4en):0;
wire scc4en_d=dcten?(a1en|a3en|a6en|a2en|a7en|a5en):
idcten?(a2en|a7en|a5en|a4en|a0en|a1en|a3en):0;
//========================================================
//skew circular convolution 4x4
//========================================================
scc4 scc4(
//input
.nrst (nrst),
.clk (clk),
.dcten (dcten),
.idcten (idcten),
.scc4en (scc4en),
.scc4en_d (scc4en_d),
.a0en (a0en),
.a1en (a1en),
.a2en (a2en),
.a3en (a3en),
.a4en (a4en),
.a5en (a5en),
.a6en (a6en),
.a7en (a7en),
.sub1en (sub1en),
.sub2en (sub2en),
.sub3en (sub3en),
.sub4en (sub4en),
.di (scc4_in),
.a0 (a0),
.a1 (a1),
.a2 (a2),
.a3 (a3),
.a4 (a4),
.a5 (a5),
.a6 (a6),
.a7 (a7),
//output
.do (scc4_o));
//========================================================
//skew circular convolution 2x2
//========================================================
wire [`bw+2:0] f0,f1;
wire f0_en=(cntr==1);
wire f1_en=(cntr==2);
wire f01en=f0_en|f1_en;
//========================================================
// 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]};
scc2 scc2(
//input
.nrst (nrst),
.clk (clk),
.scc2en (scc2en),
.scc2en_d (scc2en_d),
.di (scc2_in),
//output
.do (scc2_o));
//========================================================
// while in dct mode
// need to do post-processing
//========================================================
wire [`bw+1:0] feven1,feven2;
//========================================================
// DCT ³Ì«áµwÅé¿é¥Xªº¶¶§Ç¬O
// 1->5->3->7->2->4->8->6 or say
// 0->4->2->6->1->3->7->5
wire [`bw-1:0] dctout=(a0en|a1en)? csa053:
(a3en|a6en)? scc2_o:
a5en ?~scc4_o+1:scc4_o;
//========================================================
// IDCT POST Processing
// see fidct.m file
// t(1)=s11+s2(1);
// t(2)=s12+s2(2);
// t(3)=s13+s2(3);
// t(4)=s14+s2(4);
// t(5)=s14-s2(4);
// t(6)=s13-s2(3);
// t(7)=s12-s2(2);
// t(8)=s11-s2(1);
endmodule