Line 6... |
Line 6... |
// Belong to :
|
// Belong to :
|
// Author : H.Ishihara
|
// Author : H.Ishihara
|
// E-Mail : hidemi@sweetcafe.jp
|
// E-Mail : hidemi@sweetcafe.jp
|
// HomePage : http://www.sweetcafe.jp/
|
// HomePage : http://www.sweetcafe.jp/
|
// Date : 2006/10/01
|
// Date : 2006/10/01
|
// Rev. : 1.1
|
// Rev. : 2.00
|
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
// Rev. Date Description
|
// Rev. Date Description
|
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
// 1.01 2006/10/01 1st Release
|
// 1.01 2006/10/01 1st Release
|
// 1.02 2006/10/04 remove a WriteData,WriteDataA,WriteDataB wires.
|
// 1.02 2006/10/04 remove a WriteData,WriteDataA,WriteDataB wires.
|
//---------------------------------------------------------------------------
|
// 2.00 2007/03/25 Replace to RAM from D-FF
|
// $Id:
|
|
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
`timescale 1ps / 1ps
|
`timescale 1ps / 1ps
|
|
|
module jpeg_ycbcr_mem
|
module jpeg_ycbcr_mem(
|
(
|
rst,
|
clk,
|
clk,
|
|
|
|
DataInit,
|
|
|
DataInEnable,
|
DataInEnable,
|
DataInColor,
|
DataInColor,
|
DataInPage,
|
DataInPage,
|
DataInCount,
|
DataInCount,
|
Data0In,
|
Data0In,
|
Data1In,
|
Data1In,
|
|
|
|
DataOutEnable,
|
DataOutAddress,
|
DataOutAddress,
|
|
DataOutRead,
|
DataOutY,
|
DataOutY,
|
DataOutCb,
|
DataOutCb,
|
DataOutCr
|
DataOutCr
|
);
|
);
|
|
|
|
input rst;
|
input clk;
|
input clk;
|
|
|
|
input DataInit;
|
|
|
input DataInEnable;
|
input DataInEnable;
|
input [2:0] DataInColor;
|
input [2:0] DataInColor;
|
input [2:0] DataInPage;
|
input [2:0] DataInPage;
|
input [1:0] DataInCount;
|
input [1:0] DataInCount;
|
input [8:0] Data0In;
|
input [8:0] Data0In;
|
input [8:0] Data1In;
|
input [8:0] Data1In;
|
|
|
|
output DataOutEnable;
|
input [7:0] DataOutAddress;
|
input [7:0] DataOutAddress;
|
|
input DataOutRead;
|
output [8:0] DataOutY;
|
output [8:0] DataOutY;
|
output [8:0] DataOutCb;
|
output [8:0] DataOutCb;
|
output [8:0] DataOutCr;
|
output [8:0] DataOutCr;
|
|
|
reg [8:0] MemYA [0:127];
|
reg [8:0] MemYA [0:511];
|
reg [8:0] MemYB [0:127];
|
reg [8:0] MemYB [0:511];
|
reg [8:0] MemCbA [0:31];
|
reg [8:0] MemCbA [0:127];
|
reg [8:0] MemCbB [0:31];
|
reg [8:0] MemCbB [0:127];
|
reg [8:0] MemCrA [0:31];
|
reg [8:0] MemCrA [0:127];
|
reg [8:0] MemCrB [0:31];
|
reg [8:0] MemCrB [0:127];
|
|
|
reg [6:0] WriteAddressA;
|
reg [1:0] WriteBank, ReadBank;
|
reg [6:0] WriteAddressB;
|
|
|
wire [5:0] DataInAddress;
|
always @(DataInColor or DataInPage or DataInCount) begin
|
|
WriteAddressA[6] <= DataInColor[1];
|
assign DataInAddress = {DataInPage, DataInCount};
|
WriteAddressB[6] <= DataInColor[1];
|
|
|
// Bank
|
|
always @(posedge clk or negedge rst) begin
|
|
if(!rst) begin
|
|
WriteBank <= 2'd0;
|
|
ReadBank <= 2'd0;
|
|
end else begin
|
|
if(DataInit) begin
|
|
WriteBank <= 2'd0;
|
|
end else if(DataInEnable && (DataInAddress == 5'h1F) && (DataInColor == 3'b101)) begin
|
|
WriteBank <= WriteBank + 2'd1;
|
|
end
|
|
if(DataInit) begin
|
|
ReadBank <= 2'd0;
|
|
end else if(DataOutRead && (DataOutAddress == 8'hFF)) begin
|
|
ReadBank <= ReadBank + 2'd1;
|
|
end
|
|
end
|
|
end
|
|
|
|
wire [6:0] WriteAddressA;
|
|
wire [6:0] WriteAddressB;
|
|
|
|
function [6:0] F_WriteAddressA;
|
|
input [2:0] DataInColor;
|
|
input [2:0] DataInPage;
|
|
input [1:0] DataInCount;
|
|
begin
|
|
F_WriteAddressA[6] = DataInColor[1];
|
if(DataInColor[2] == 1'b0) begin
|
if(DataInColor[2] == 1'b0) begin
|
if(DataInColor[0] == 1'b0) begin
|
F_WriteAddressA[5:4] = DataInCount[1:0];
|
case(DataInCount)
|
F_WriteAddressA[3] = DataInColor[0] & ~DataInColor[2];
|
2'h0: begin
|
end else begin
|
WriteAddressA[5:0] <= DataInPage + 0;
|
F_WriteAddressA[5] = 1'b0;
|
WriteAddressB[5:0] <= DataInPage +112 -64;
|
F_WriteAddressA[4:3] = DataInCount[1:0];
|
end
|
end
|
2'h1: begin
|
F_WriteAddressA[2:0] = DataInPage[2:0];
|
WriteAddressA[5:0] <= DataInPage + 16;
|
end
|
WriteAddressB[5:0] <= DataInPage + 96 -64;
|
endfunction
|
end
|
|
2'h2: begin
|
function [6:0] F_WriteAddressB;
|
WriteAddressA[5:0] <= DataInPage + 32;
|
input [2:0] DataInColor;
|
WriteAddressB[5:0] <= DataInPage + 80 -64;
|
input [2:0] DataInPage;
|
end
|
input [1:0] DataInCount;
|
2'h3: begin
|
begin
|
WriteAddressA[5:0] <= DataInPage + 48;
|
F_WriteAddressB[6] = DataInColor[1];
|
WriteAddressB[5:0] <= DataInPage + 64 -64;
|
if(DataInColor[2] == 1'b0) begin
|
end
|
F_WriteAddressB[5:4] = ~DataInCount[1:0];
|
endcase // case(DataInCount)
|
F_WriteAddressB[3] = DataInColor[0] & ~DataInColor[2];
|
end else begin // if (DataInColor[0] == 1'b0)
|
end else begin
|
case(DataInCount)
|
F_WriteAddressB[5] = 1'b0;
|
2'h0: begin
|
F_WriteAddressB[4:3] = ~DataInCount[1:0];
|
WriteAddressA[5:0] <= DataInPage + 0 +8;
|
end
|
WriteAddressB[5:0] <= DataInPage +112 +8 -64;
|
F_WriteAddressB[2:0] = DataInPage[2:0];
|
end
|
end
|
2'h1: begin
|
endfunction
|
WriteAddressA[5:0] <= DataInPage + 16 +8;
|
|
WriteAddressB[5:0] <= DataInPage + 96 +8 -64;
|
assign WriteAddressA = F_WriteAddressA(DataInColor, DataInPage, DataInCount);
|
end
|
assign WriteAddressB = F_WriteAddressB(DataInColor, DataInPage, DataInCount);
|
2'h2: begin
|
|
WriteAddressA[5:0] <= DataInPage + 32 +8;
|
|
WriteAddressB[5:0] <= DataInPage + 80 +8 -64;
|
|
end
|
|
2'h3: begin
|
|
WriteAddressA[5:0] <= DataInPage + 48 +8;
|
|
WriteAddressB[5:0] <= DataInPage + 64 +8 -64;
|
|
end
|
|
endcase // case(DataInCount)
|
|
end // else: !if(DataInColor[0] == 1'b0)
|
|
end else begin // if (DataInColor[2] == 1'b0)
|
|
case(DataInCount)
|
|
2'h0: begin
|
|
WriteAddressA[5:0] <= DataInPage + 0;
|
|
WriteAddressB[5:0] <= DataInPage + 56 -32;
|
|
end
|
|
2'h1: begin
|
|
WriteAddressA[5:0] <= DataInPage + 8;
|
|
WriteAddressB[5:0] <= DataInPage + 48 -32;
|
|
end
|
|
2'h2: begin
|
|
WriteAddressA[5:0] <= DataInPage + 16;
|
|
WriteAddressB[5:0] <= DataInPage + 40 -32;
|
|
end
|
|
2'h3: begin
|
|
WriteAddressA[5:0] <= DataInPage + 24;
|
|
WriteAddressB[5:0] <= DataInPage + 32 -32;
|
|
end
|
|
endcase // case(DataInCount)
|
|
end // else: !if(DataInColor[2] == 1'b0)
|
|
end // always @ (DataInColor or DataInPage or DataInCount)
|
|
|
|
always @(posedge clk) begin
|
always @(posedge clk) begin
|
if(DataInColor[2] == 1'b0 & DataInEnable == 1'b1) begin
|
if(DataInColor[2] == 1'b0 & DataInEnable == 1'b1) begin
|
MemYA[WriteAddressA] <= Data0In;
|
MemYA[{WriteBank, WriteAddressA}] <= Data0In;
|
MemYB[WriteAddressB] <= Data1In;
|
MemYB[{WriteBank, WriteAddressB}] <= Data1In;
|
end
|
end
|
end
|
end
|
|
|
always @(posedge clk) begin
|
always @(posedge clk) begin
|
if(DataInColor == 3'b100 & DataInEnable == 1'b1) begin
|
if(DataInColor == 3'b100 & DataInEnable == 1'b1) begin
|
MemCbA[WriteAddressA[4:0]] <= Data0In;
|
MemCbA[{WriteBank, WriteAddressA[4:0]}] <= Data0In;
|
MemCbB[WriteAddressB[4:0]] <= Data1In;
|
MemCbB[{WriteBank, WriteAddressB[4:0]}] <= Data1In;
|
end
|
end
|
end
|
end
|
|
|
always @(posedge clk) begin
|
always @(posedge clk) begin
|
if(DataInColor == 3'b101 & DataInEnable == 1'b1) begin
|
if(DataInColor == 3'b101 & DataInEnable == 1'b1) begin
|
MemCrA[WriteAddressA[4:0]] <= Data0In;
|
MemCrA[{WriteBank, WriteAddressA[4:0]}] <= Data0In;
|
MemCrB[WriteAddressB[4:0]] <= Data1In;
|
MemCrB[{WriteBank, WriteAddressB[4:0]}] <= Data1In;
|
end
|
end
|
end
|
end
|
|
|
reg [8:0] ReadYA;
|
reg [8:0] ReadYA;
|
reg [8:0] ReadYB;
|
reg [8:0] ReadYB;
|
Line 156... |
Line 161... |
reg [7:0] RegAdrs;
|
reg [7:0] RegAdrs;
|
|
|
always @(posedge clk) begin
|
always @(posedge clk) begin
|
RegAdrs <= DataOutAddress;
|
RegAdrs <= DataOutAddress;
|
|
|
ReadYA <= MemYA[{DataOutAddress[7],DataOutAddress[5:0]}];
|
ReadYA <= MemYA[{ReadBank, DataOutAddress[7],DataOutAddress[5:0]}];
|
ReadYB <= MemYB[{DataOutAddress[7],DataOutAddress[5:0]}];
|
ReadYB <= MemYB[{ReadBank, DataOutAddress[7],DataOutAddress[5:0]}];
|
|
|
ReadCbA <= MemCbA[{DataOutAddress[6:5],DataOutAddress[3:1]}];
|
ReadCbA <= MemCbA[{ReadBank, DataOutAddress[6:5],DataOutAddress[3:1]}];
|
ReadCrA <= MemCrA[{DataOutAddress[6:5],DataOutAddress[3:1]}];
|
ReadCrA <= MemCrA[{ReadBank, DataOutAddress[6:5],DataOutAddress[3:1]}];
|
|
|
ReadCbB <= MemCbB[{DataOutAddress[6:5],DataOutAddress[3:1]}];
|
ReadCbB <= MemCbB[{ReadBank, DataOutAddress[6:5],DataOutAddress[3:1]}];
|
ReadCrB <= MemCrB[{DataOutAddress[6:5],DataOutAddress[3:1]}];
|
ReadCrB <= MemCrB[{ReadBank, DataOutAddress[6:5],DataOutAddress[3:1]}];
|
end // always @ (posedge clk)
|
end
|
|
|
|
assign DataOutEnable = (WriteBank != ReadBank);
|
assign DataOutY = (RegAdrs[6] ==1'b0)?ReadYA:ReadYB;
|
assign DataOutY = (RegAdrs[6] ==1'b0)?ReadYA:ReadYB;
|
assign DataOutCb = (RegAdrs[7] ==1'b0)?ReadCbA:ReadCbB;
|
assign DataOutCb = (RegAdrs[7] ==1'b0)?ReadCbA:ReadCbB;
|
assign DataOutCr = (RegAdrs[7] ==1'b0)?ReadCrA:ReadCrB;
|
assign DataOutCr = (RegAdrs[7] ==1'b0)?ReadCrA:ReadCrB;
|
|
|
endmodule // jpeg_ycbcr_mem
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|