OpenCores
URL https://opencores.org/ocsvn/djpeg/djpeg/trunk

Subversion Repositories djpeg

[/] [djpeg/] [trunk/] [src/] [jpeg_ycbcr_mem.v] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 hidemi
//---------------------------------------------------------------------------
2
// File Name   : jpeg_ycbcr_mem.v
3
// Module Name : jpeg_ycbcr_mem
4
// Description : Memory for YCbCr2RGB
5
// Project     : JPEG Decoder
6
// Belong to   : 
7
// Author      : H.Ishihara
8
// E-Mail      : hidemi@sweetcafe.jp
9
// HomePage    : http://www.sweetcafe.jp/
10
// Date        : 2006/10/01
11
// Rev.        : 1.1
12
//---------------------------------------------------------------------------
13
// Rev. Date       Description
14
//---------------------------------------------------------------------------
15
// 1.01 2006/10/01 1st Release
16
// 1.02 2006/10/04 remove a WriteData,WriteDataA,WriteDataB wires.
17
//---------------------------------------------------------------------------
18
// $Id: 
19
//---------------------------------------------------------------------------
20
`timescale 1ps / 1ps
21
 
22
module jpeg_ycbcr_mem
23
  (
24
   clk,
25
 
26
   DataInEnable,
27
   DataInColor,
28
   DataInPage,
29
   DataInCount,
30
   Data0In,
31
   Data1In,
32
 
33
   DataOutAddress,
34
   DataOutY,
35
   DataOutCb,
36
   DataOutCr
37
   );
38
 
39
   input          clk;
40
 
41
   input          DataInEnable;
42
   input [2:0]    DataInColor;
43
   input [2:0]    DataInPage;
44
   input [1:0]    DataInCount;
45
   input [8:0]    Data0In;
46
   input [8:0]    Data1In;
47
 
48
   input [7:0]    DataOutAddress;
49
   output [8:0]   DataOutY;
50
   output [8:0]   DataOutCb;
51
   output [8:0]   DataOutCr;
52
 
53 5 hidemi
   reg [8:0]      MemYA  [0:127];
54
   reg [8:0]      MemYB  [0:127];
55
   reg [8:0]      MemCbA [0:31];
56
   reg [8:0]      MemCbB [0:31];
57
   reg [8:0]      MemCrA [0:31];
58
   reg [8:0]      MemCrB [0:31];
59 3 hidemi
 
60 5 hidemi
   reg [6:0]      WriteAddressA;
61
   reg [6:0]      WriteAddressB;
62 3 hidemi
 
63
   always @(DataInColor or DataInPage or DataInCount) begin
64 5 hidemi
      WriteAddressA[6] <= DataInColor[1];
65
      WriteAddressB[6] <= DataInColor[1];
66 3 hidemi
      if(DataInColor[2] == 1'b0) begin
67
         if(DataInColor[0] == 1'b0) begin
68
            case(DataInCount)
69
              2'h0: begin
70 5 hidemi
                 WriteAddressA[5:0] <= DataInPage +  0;
71
                 WriteAddressB[5:0] <= DataInPage +112 -64;
72 3 hidemi
              end
73
              2'h1: begin
74 5 hidemi
                 WriteAddressA[5:0] <= DataInPage + 16;
75
                 WriteAddressB[5:0] <= DataInPage + 96 -64;
76 3 hidemi
              end
77
              2'h2: begin
78 5 hidemi
                 WriteAddressA[5:0] <= DataInPage + 32;
79
                 WriteAddressB[5:0] <= DataInPage + 80 -64;
80 3 hidemi
              end
81
              2'h3: begin
82 5 hidemi
                 WriteAddressA[5:0] <= DataInPage + 48;
83
                 WriteAddressB[5:0] <= DataInPage + 64 -64;
84 3 hidemi
              end
85
            endcase // case(DataInCount)
86
         end else begin // if (DataInColor[0] == 1'b0)
87
            case(DataInCount)
88
              2'h0: begin
89 5 hidemi
                 WriteAddressA[5:0] <= DataInPage +  0 +8;
90
                 WriteAddressB[5:0] <= DataInPage +112 +8 -64;
91 3 hidemi
              end
92
              2'h1: begin
93 5 hidemi
                 WriteAddressA[5:0] <= DataInPage + 16 +8;
94
                 WriteAddressB[5:0] <= DataInPage + 96 +8 -64;
95 3 hidemi
              end
96
              2'h2: begin
97 5 hidemi
                 WriteAddressA[5:0] <= DataInPage + 32 +8;
98
                 WriteAddressB[5:0] <= DataInPage + 80 +8 -64;
99 3 hidemi
              end
100
              2'h3: begin
101 5 hidemi
                 WriteAddressA[5:0] <= DataInPage + 48 +8;
102
                 WriteAddressB[5:0] <= DataInPage + 64 +8 -64;
103 3 hidemi
              end
104
            endcase // case(DataInCount)
105
         end // else: !if(DataInColor[0] == 1'b0)
106
      end else begin // if (DataInColor[2] == 1'b0)
107
         case(DataInCount)
108
           2'h0: begin
109
              WriteAddressA[5:0] <= DataInPage +  0;
110 5 hidemi
              WriteAddressB[5:0] <= DataInPage + 56 -32;
111 3 hidemi
           end
112
           2'h1: begin
113
              WriteAddressA[5:0] <= DataInPage +  8;
114 5 hidemi
              WriteAddressB[5:0] <= DataInPage + 48 -32;
115 3 hidemi
           end
116
           2'h2: begin
117
              WriteAddressA[5:0] <= DataInPage + 16;
118 5 hidemi
              WriteAddressB[5:0] <= DataInPage + 40 -32;
119 3 hidemi
           end
120
           2'h3: begin
121
              WriteAddressA[5:0] <= DataInPage + 24;
122 5 hidemi
              WriteAddressB[5:0] <= DataInPage + 32 -32;
123 3 hidemi
           end
124
         endcase // case(DataInCount)
125
      end // else: !if(DataInColor[2] == 1'b0)
126
   end // always @ (DataInColor or DataInPage or DataInCount)
127
 
128
   always @(posedge clk) begin
129
      if(DataInColor[2] == 1'b0 & DataInEnable == 1'b1) begin
130
         MemYA[WriteAddressA] <= Data0In;
131
         MemYB[WriteAddressB] <= Data1In;
132
      end
133
   end
134
 
135
   always @(posedge clk) begin
136
      if(DataInColor == 3'b100 & DataInEnable == 1'b1) begin
137 5 hidemi
         MemCbA[WriteAddressA[4:0]] <= Data0In;
138
         MemCbB[WriteAddressB[4:0]] <= Data1In;
139 3 hidemi
      end
140
   end
141
 
142
   always @(posedge clk) begin
143
      if(DataInColor == 3'b101 & DataInEnable == 1'b1) begin
144 5 hidemi
         MemCrA[WriteAddressA[4:0]] <= Data0In;
145
         MemCrB[WriteAddressB[4:0]] <= Data1In;
146 3 hidemi
      end
147
   end
148
 
149
   reg [8:0] ReadYA;
150
   reg [8:0] ReadYB;
151
   reg [8:0] ReadCbA;
152
   reg [8:0] ReadCbB;
153
   reg [8:0] ReadCrA;
154
   reg [8:0] ReadCrB;
155
 
156
   reg [7:0] RegAdrs;
157
 
158
   always @(posedge clk) begin
159
      RegAdrs <= DataOutAddress;
160
 
161 5 hidemi
      ReadYA  <= MemYA[{DataOutAddress[7],DataOutAddress[5:0]}];
162
      ReadYB  <= MemYB[{DataOutAddress[7],DataOutAddress[5:0]}];
163 3 hidemi
 
164 5 hidemi
      ReadCbA <= MemCbA[{DataOutAddress[6:5],DataOutAddress[3:1]}];
165
      ReadCrA <= MemCrA[{DataOutAddress[6:5],DataOutAddress[3:1]}];
166 3 hidemi
 
167 5 hidemi
      ReadCbB <= MemCbB[{DataOutAddress[6:5],DataOutAddress[3:1]}];
168
      ReadCrB <= MemCrB[{DataOutAddress[6:5],DataOutAddress[3:1]}];
169 3 hidemi
   end // always @ (posedge clk)
170
 
171
   assign DataOutY  = (RegAdrs[6] ==1'b0)?ReadYA:ReadYB;
172
   assign DataOutCb = (RegAdrs[7] ==1'b0)?ReadCbA:ReadCbB;
173
   assign DataOutCr = (RegAdrs[7] ==1'b0)?ReadCrA:ReadCrB;
174
 
175
endmodule // jpeg_ycbcr_mem

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.