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

Subversion Repositories nova

[/] [nova/] [trunk/] [src/] [rec_DF_RAM_ctrl.v] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 eexuke
//--------------------------------------------------------------------------------------------------
2
// Design    : nova
3
// Author(s) : Ke Xu
4
// Email           : eexuke@yahoo.com
5
// File      : rec_DF_RAM_ctrl.v
6
// Generated : Nov 3, 2005
7
// Copyright (C) 2008 Ke Xu                
8
//-------------------------------------------------------------------------------------------------
9
// Description 
10
// Controller for rec_DF_RAM0 & rec_DF_RAM1,single port SRAM
11
// write during reconstruction,read during DF
12
// assume "_wr" & "_rd" are both high active
13
//-------------------------------------------------------------------------------------------------
14
 
15
// synopsys translate_off
16
`include "timescale.v"
17
// synopsys translate_on
18
`include "nova_defines.v"
19
 
20
module rec_DF_RAM_ctrl (clk,reset_n,disable_DF,end_of_MB_DEC,
21
        DF_edge_counter_MR,one_edge_counter_MR,
22
        blk4x4_sum_PE0_out,blk4x4_sum_PE1_out,blk4x4_sum_PE2_out,blk4x4_sum_PE3_out,
23
        blk4x4_sum_counter,blk4x4_rec_counter_2_raster_order,rec_DF_RAM0_dout,rec_DF_RAM1_dout,
24
 
25
        rec_DF_RAM_dout,
26
        rec_DF_RAM0_wr,rec_DF_RAM0_rd,rec_DF_RAM0_addr,rec_DF_RAM0_din,
27
        rec_DF_RAM1_wr,rec_DF_RAM1_rd,rec_DF_RAM1_addr,rec_DF_RAM1_din);
28
        input clk,reset_n;
29
        input disable_DF;
30
        input end_of_MB_DEC;
31
        input [5:0] DF_edge_counter_MR;
32
        input [1:0] one_edge_counter_MR;
33
        input [7:0] blk4x4_sum_PE0_out,blk4x4_sum_PE1_out,blk4x4_sum_PE2_out,blk4x4_sum_PE3_out;
34
        input [2:0] blk4x4_sum_counter;
35
        input [4:0] blk4x4_rec_counter_2_raster_order;
36
        input [31:0] rec_DF_RAM0_dout,rec_DF_RAM1_dout;
37
 
38
        output [31:0] rec_DF_RAM_dout;
39
        output rec_DF_RAM0_wr;
40
        output rec_DF_RAM0_rd;
41
        output [6:0]rec_DF_RAM0_addr;
42
        output [31:0] rec_DF_RAM0_din;
43
        output rec_DF_RAM1_wr;
44
        output rec_DF_RAM1_rd;
45
        output [6:0]rec_DF_RAM1_addr;
46
        output [31:0] rec_DF_RAM1_din;
47
 
48
        reg rec_DF_RAM0_wr;
49
        reg rec_DF_RAM0_rd;
50
        reg [6:0]rec_DF_RAM0_addr;
51
        reg [31:0] rec_DF_RAM0_din;
52
        reg rec_DF_RAM1_wr;
53
        reg rec_DF_RAM1_rd;
54
        reg [6:0]rec_DF_RAM1_addr;
55
        reg [31:0] rec_DF_RAM1_din;
56
        //-----------------------------------------------------------------
57
        //Write:after reconstruction 
58
        //-----------------------------------------------------------------     
59
        wire rec_DF_RAM_wr;
60
        wire [4:0] rec_DF_RAM_wr_addr_blk4x4;
61
        wire [1:0] rec_DF_RAM_wr_addr_offset;
62
        wire [6:0] rec_DF_RAM_wr_addr;
63
        wire [31:0] rec_DF_RAM_din;
64
 
65
        assign rec_DF_RAM_wr = !disable_DF && (blk4x4_sum_counter[2] != 1'b1);
66
        assign rec_DF_RAM_wr_addr_blk4x4 = {5{rec_DF_RAM_wr}} & blk4x4_rec_counter_2_raster_order;
67
        assign rec_DF_RAM_wr_addr_offset = {2{rec_DF_RAM_wr}} & blk4x4_sum_counter[1:0];
68
        assign rec_DF_RAM_wr_addr = {rec_DF_RAM_wr_addr_blk4x4,2'b0} + rec_DF_RAM_wr_addr_offset;
69
        assign rec_DF_RAM_din = (rec_DF_RAM_wr)? {blk4x4_sum_PE3_out,blk4x4_sum_PE2_out,blk4x4_sum_PE1_out,blk4x4_sum_PE0_out}:0;
70
        //-----------------------------------------------------------------
71
        //Read:during deblocking filter
72
        //-----------------------------------------------------------------     
73
        wire rec_DF_RAM_rd;
74
        reg [4:0] rec_DF_RAM_rd_addr_blk4x4;
75
        wire [1:0] rec_DF_RAM_rd_addr_offset;
76
        wire [6:0] rec_DF_RAM_rd_addr;
77
 
78
        assign rec_DF_RAM_rd = ((DF_edge_counter_MR[5] == 1'b0 && (DF_edge_counter_MR[3:0] == 4'd0 ||
79
        DF_edge_counter_MR[3:0] == 4'd1     ||  DF_edge_counter_MR[3:0] == 4'd2 || DF_edge_counter_MR[3:0] == 4'd3 ||
80
        DF_edge_counter_MR[3:0] == 4'd6     ||  DF_edge_counter_MR[3:0] == 4'd7 || DF_edge_counter_MR[3:0] == 4'd10||
81
        DF_edge_counter_MR[3:0] == 4'd11))  || (DF_edge_counter_MR[5] == 1'b1   && DF_edge_counter_MR[2] == 1'b0));
82
 
83
        always @ (rec_DF_RAM_rd or DF_edge_counter_MR)
84
                if (rec_DF_RAM_rd)
85
                        case (DF_edge_counter_MR)
86
                                6'd0 :rec_DF_RAM_rd_addr_blk4x4 <= 5'd0;
87
                                6'd1 :rec_DF_RAM_rd_addr_blk4x4 <= 5'd1;
88
                                6'd2 :rec_DF_RAM_rd_addr_blk4x4 <= 5'd4;
89
                                6'd3 :rec_DF_RAM_rd_addr_blk4x4 <= 5'd5;
90
                                6'd6 :rec_DF_RAM_rd_addr_blk4x4 <= 5'd2;
91
                                6'd7 :rec_DF_RAM_rd_addr_blk4x4 <= 5'd6;
92
                                6'd10:rec_DF_RAM_rd_addr_blk4x4 <= 5'd3;
93
                                6'd11:rec_DF_RAM_rd_addr_blk4x4 <= 5'd7;
94
                                6'd16:rec_DF_RAM_rd_addr_blk4x4 <= 5'd8;
95
                                6'd17:rec_DF_RAM_rd_addr_blk4x4 <= 5'd9;
96
                                6'd18:rec_DF_RAM_rd_addr_blk4x4 <= 5'd12;
97
                                6'd19:rec_DF_RAM_rd_addr_blk4x4 <= 5'd13;
98
                                6'd22:rec_DF_RAM_rd_addr_blk4x4 <= 5'd10;
99
                                6'd23:rec_DF_RAM_rd_addr_blk4x4 <= 5'd14;
100
                                6'd26:rec_DF_RAM_rd_addr_blk4x4 <= 5'd11;
101
                                6'd27:rec_DF_RAM_rd_addr_blk4x4 <= 5'd15;
102
                                6'd32:rec_DF_RAM_rd_addr_blk4x4 <= 5'd16;
103
                                6'd33:rec_DF_RAM_rd_addr_blk4x4 <= 5'd17;
104
                                6'd34:rec_DF_RAM_rd_addr_blk4x4 <= 5'd18;
105
                                6'd35:rec_DF_RAM_rd_addr_blk4x4 <= 5'd19;
106
                                6'd40:rec_DF_RAM_rd_addr_blk4x4 <= 5'd20;
107
                                6'd41:rec_DF_RAM_rd_addr_blk4x4 <= 5'd21;
108
                                6'd42:rec_DF_RAM_rd_addr_blk4x4 <= 5'd22;
109
                                6'd43:rec_DF_RAM_rd_addr_blk4x4 <= 5'd23;
110
                                default:rec_DF_RAM_rd_addr_blk4x4 <= 0;
111
                        endcase
112
                else
113
                        rec_DF_RAM_rd_addr_blk4x4 <= 0;
114
 
115
        assign rec_DF_RAM_rd_addr_offset = one_edge_counter_MR;
116
        assign rec_DF_RAM_rd_addr = {rec_DF_RAM_rd_addr_blk4x4,2'b0} + rec_DF_RAM_rd_addr_offset;
117
 
118
        //----------------------------------------------------------------------------------
119
        //Generate control signals for rec_DF_RAM0 & rec_DF_RAM1 
120
        //----------------------------------------------------------------------------------                    
121
        reg rec_DF_RAM_sel;     //0:rec_DF_RAM0 at reconstruction stage                 
122
                                                //0:rec_DF_RAM1 at DF stage
123
                                                //1:rec_DF_RAM0 at DF stage                     
124
                                                //1:rec_DF_RAM1 at reconstruction stage
125
        always @ (posedge clk)
126
                if (reset_n == 1'b0)
127
                        rec_DF_RAM_sel <= 1'b0;
128
                else if (end_of_MB_DEC)
129
                        rec_DF_RAM_sel <= ~ rec_DF_RAM_sel;
130
 
131
        assign rec_DF_RAM_dout = (rec_DF_RAM_sel == 1'b0)? rec_DF_RAM1_dout:rec_DF_RAM0_dout;
132
 
133
        always @ (rec_DF_RAM_sel
134
                or rec_DF_RAM_wr or rec_DF_RAM_wr_addr or rec_DF_RAM_din
135
                or rec_DF_RAM_rd or rec_DF_RAM_rd_addr)
136
                case (rec_DF_RAM_sel)
137
                        1'b0:   //rec_DF_RAM0 at reconstruction stage,rec_DF_RAM1 at DF stage
138
                        begin
139
                                rec_DF_RAM0_wr <= rec_DF_RAM_wr;
140
                                rec_DF_RAM0_rd <= 1'b0;
141
                                rec_DF_RAM0_addr <= rec_DF_RAM_wr_addr;
142
                                rec_DF_RAM0_din  <= rec_DF_RAM_din;
143
 
144
                                rec_DF_RAM1_wr <= 1'b0;
145
                                rec_DF_RAM1_rd <= rec_DF_RAM_rd;
146
                                rec_DF_RAM1_addr <= rec_DF_RAM_rd_addr;
147
                                rec_DF_RAM1_din  <= 0;
148
                        end
149
                        1'b1:   //rec_DF_RAM0 at DF stage,rec_DF_RAM1 at reconstruction stage
150
                        begin
151
                                rec_DF_RAM0_wr <= 1'b0;
152
                                rec_DF_RAM0_rd <= rec_DF_RAM_rd;
153
                                rec_DF_RAM0_addr <= rec_DF_RAM_rd_addr;
154
                                rec_DF_RAM0_din  <= 0;
155
 
156
                                rec_DF_RAM1_wr <= rec_DF_RAM_wr;
157
                                rec_DF_RAM1_rd <= 1'b0;
158
                                rec_DF_RAM1_addr <= rec_DF_RAM_wr_addr;
159
                                rec_DF_RAM1_din  <= rec_DF_RAM_din;
160
                        end
161
                endcase
162
endmodule
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
 
173
 

powered by: WebSVN 2.1.0

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