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

Subversion Repositories embedded_risc

[/] [embedded_risc/] [trunk/] [Verilog/] [dma_internal_reg.v] - Blame information for rev 27

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 hosseinami
/*********************************************************
2
 MODULE:                Sub Level DMA Internal Register Block
3
 
4
 FILE NAME:     dma_internal_reg.v
5
 VERSION:       1.0
6
 DATE:          May 20th, 2002
7
 AUTHOR:                Hossein Amidi
8
 COMPANY:
9
 CODE TYPE:     Register Transfer Level
10
 
11
 DESCRIPTION:   This module is the sub level RTL code of DMA Controller Internal
12
 Register verilog code.
13
 
14
 It will instantiate the following blocks in the ASIC:
15
 
16
 
17
 Hossein Amidi
18
 (C) April 2002
19
 
20
*********************************************************/
21
 
22
// DEFINES
23
`timescale 1ns / 10ps
24
 
25
// TOP MODULE
26
module dma_internal_reg(// Inputs
27
                                                                reset,
28
                                                                clk0,
29
                                                                dma_host_cmd,
30
                                                                dma_host_addr,
31
                                                                dma_host_datain,
32
                                                                dma_wr_addr_cnt,
33
                                                                dma_rd_addr_cnt,
34
                                                                fifo_rd,
35
                                                                fifo_wr,
36
                                                                // Output
37
                                                                dma_host_dataout,
38
                                                                done,
39
                                                                go,
40
                                                                busy,
41
                                                                fifo_wr_enb,
42
                                                                fifo_rd_enb,
43
                                                                wr_inc1,
44
                                                                wr_inc2,
45
                                                                wr_inc4,
46
                                                                rd_inc1,
47
                                                                rd_inc2,
48
                                                                rd_inc4
49
                                                                );
50
 
51
 
52
// Parameter
53
`include        "parameter.v"
54
 
55
// Inputs
56
input reset;
57
input clk0;
58
input [padd_size - 1 : 0]dma_host_addr;
59
input [cmd_size  - 1 : 0]dma_host_cmd;
60
input [data_size - 1 : 0]dma_host_datain;
61
input [dma_fifo_depth - 1 : 0]dma_wr_addr_cnt;
62
input [dma_fifo_depth - 1 : 0]dma_rd_addr_cnt;
63
input fifo_rd;
64
input fifo_wr;
65
 
66
 
67
// Outputs
68
output [data_size - 1 : 0]dma_host_dataout;
69
output done;
70
output go;
71
output busy;
72
output fifo_wr_enb;
73
output fifo_rd_enb;
74
output wr_inc1;
75
output wr_inc2;
76
output wr_inc4;
77
output rd_inc1;
78
output rd_inc2;
79
output rd_inc4;
80
 
81
 
82
// Signal Declarations
83
wire reset;
84
wire clk0;
85
wire [padd_size - 1 : 0]dma_host_addr;
86
wire [cmd_size  - 1 : 0]dma_host_cmd;
87
wire [data_size - 1 : 0]dma_host_datain;
88
wire [dma_fifo_depth - 1 : 0]dma_wr_addr_cnt;
89
wire [dma_fifo_depth - 1 : 0]dma_rd_addr_cnt;
90
wire fifo_rd;
91
wire fifo_wr;
92
 
93
 
94
reg [data_size - 1 : 0]dma_host_dataout;
95
 
96
 
97
// Internal signals
98
wire [dma_reg_width - 1 : 0]dma_register0;
99
wire [dma_reg_width - 1 : 0]dma_register1;
100
wire [dma_reg_width - 1 : 0]dma_register2;
101
wire [dma_reg_width - 1 : 0]dma_register3;
102
wire [dma_reg_width - 1 : 0]dma_register6;
103
 
104
 
105
wire wr_inc1;
106
wire wr_inc2;
107
wire wr_inc4;
108
 
109
wire rd_inc1;
110
wire rd_inc2;
111
wire rd_inc4;
112
 
113
wire done;
114
wire busy;
115
wire reop;
116
wire weop;
117
wire len;
118
 
119
wire byte;
120
wire hw;
121
wire word;
122
wire go;
123
wire i_en;
124
wire reen;
125
wire ween;
126
wire leen;
127
wire rcon;
128
wire wcon;
129
 
130
wire fifo_wr_enb;
131
wire fifo_rd_enb;
132
 
133
/***************** Internal Register of DMA configuration *******************/
134
reg [dma_reg_width - 1 : 0] dma_register [dma_reg_depth - 1 : 0];
135
 
136
// Assignment statments
137
 
138
// Increment the write/read counter according to byte, half word or word mode
139
assign wr_inc1  =       (~(dma_register0 == 32'h0) &
140
                                                        ~(dma_register2 == 32'h0) &
141
                                                        (go == 1'b1) &
142
                                                        (word == 1'b0) &
143
                                                        (hw == 1'b0) &
144
                                                        (byte == 1'b1));
145
 
146
assign wr_inc2  =       (~(dma_register0 == 32'h0) &
147
                                                        ~(dma_register2 == 32'h0) &
148
                                                        (go == 1'b1) &
149
                                                        (word == 1'b0) &
150
                                                        (hw == 1'b1) &
151
                                                        (byte == 1'b0));
152
 
153
assign wr_inc4  =       (~(dma_register0 == 32'h0) &
154
                                                        ~(dma_register2 == 32'h0) &
155
                                                        (go == 1'b1) &
156
                                                        (word == 1'b1) &
157
                                                        (hw == 1'b0) &
158
                                                        (byte == 1'b0));
159
 
160
 
161
assign rd_inc1  =       (~(dma_register0 == 32'h0) &
162
                                                        ~(dma_register1 == 32'h0) &
163
                                                        (go == 1'b1) &
164
                                                        (word == 1'b0) &
165
                                                        (hw == 1'b0) &
166
                                                        (byte == 1'b1));
167
 
168
assign rd_inc2  =       (~(dma_register0 == 32'h0) &
169
                                                        ~(dma_register1 == 32'h0) &
170
                                                        (go == 1'b1) &
171
                                                        (word == 1'b0) &
172
                                                        (hw == 1'b1) &
173
                                                        (byte == 1'b0));
174
 
175
assign rd_inc4  =       (~(dma_register0 == 32'h0) &
176
                                                        ~(dma_register1 == 32'h0) &
177
                                                        (go == 1'b1) &
178
                                                        (word == 1'b1) &
179
                                                        (hw == 1'b0) &
180
                                                        (byte == 1'b0));
181
 
182
 
183
assign fifo_wr_enb = (~(dma_register3 == 32'h0) &
184
                                                        ~(dma_register2 == 32'h0) &
185
                                                        (go == 1'b1));
186
 
187
 
188
assign fifo_rd_enb = (~(dma_register3 == 32'h0) &
189
                                                        ~(dma_register1 == 32'h0) &
190
                                                        (go == 1'b1));
191
 
192
assign dma_register0 = dma_register[0];
193
assign dma_register1 = dma_register[1];
194
assign dma_register2 = dma_register[2];
195
assign dma_register3 = dma_register[3];
196
assign dma_register6 = dma_register[6];
197
 
198
 
199
// Bitwise decoding of status register
200
assign done = dma_register0[0] & 32'd1;
201
assign busy = dma_register0[1] & 32'd1;
202
assign reop = dma_register0[2] & 32'd1;
203
assign weop = dma_register0[3] & 32'd1;
204
assign len  = dma_register0[4] & 32'd1;
205
 
206
// Bitwise decoding of control register
207
assign byte = dma_register6[0] & 32'd1;
208
assign hw   = dma_register6[1] & 32'd1;
209
assign word = dma_register6[2] & 32'd1;
210
assign go   = dma_register6[3] & 32'd1;
211
assign i_en = dma_register6[4] & 32'd1;
212
assign reen = dma_register6[5] & 32'd1;
213
assign ween = dma_register6[6] & 32'd1;
214
assign leen = dma_register6[7] & 32'd1;
215
assign rcon = dma_register6[8] & 32'd1;
216
assign wcon = dma_register6[9] & 32'd1;
217
 
218
 
219
// Access to internal register by CPU address and command signals (write/read)
220
always @(posedge reset or posedge clk0)
221
begin
222
        if(reset == 1'b1)
223
        begin
224
                dma_host_dataout <= 32'h0;
225
                dma_register[0] <= 32'h0;
226
                dma_register[1] <= 32'h0;
227
                dma_register[2] <= 32'h0;
228
                dma_register[3] <= 32'h0;
229
                dma_register[4] <= 32'h0;
230
                dma_register[5] <= 32'h0;
231
                dma_register[6] <= 32'h0;
232
                dma_register[7] <= 32'h0;
233
        end
234
        else
235
        begin
236
                if(dma_host_cmd == 3'b010)      // Write from Host to DMA internal Registers
237
                begin
238
                        case (dma_host_addr)
239
 
240
                                24'h080000:     dma_register[0] <= dma_host_datain;      // Status Register
241
                                24'h080001:     dma_register[1] <= dma_host_datain;     // Read Master Start Address
242
                                24'h080002:     dma_register[2] <= dma_host_datain;     // Write Master Start Address
243
                                24'h080003:     dma_register[3] <= dma_host_datain;     // Length in Bytes
244
                                24'h080004:     dma_register[4] <= dma_host_datain;     // Reserved
245
                                24'h080005:     dma_register[5] <= dma_host_datain; // Reserved
246
                                24'h080006:     dma_register[6] <= dma_host_datain;     // Control
247
                                24'h080007:     dma_register[7] <= dma_host_datain; // Reserved
248
                        endcase
249
                end
250
                else
251
                if(dma_host_cmd == 3'b001)      // Read from DMA internal Registers to Host
252
                begin
253
                        case (dma_host_addr)
254
 
255
                                24'h080000:     dma_host_dataout <= dma_register[0];
256
                                24'h080001:     dma_host_dataout <= dma_register[1];
257
                                24'h080002:     dma_host_dataout <= dma_register[2];
258
                                24'h080003:     dma_host_dataout <= dma_register[3];
259
                                24'h080004:     dma_host_dataout <= dma_register[4];
260
                                24'h080005:     dma_host_dataout <= dma_register[5];
261
                                24'h080006:     dma_host_dataout <= dma_register[6];
262
                                24'h080007:     dma_host_dataout <= dma_register[7];
263
                        endcase
264
                end
265
 
266
        if(((reop == 1'b1) || (weop == 1'b1) || (len == 32'h0)) && (i_en))
267
                dma_register[0] <= dma_register[0] | 32'h1;                               // Set the done pin
268
 
269
        if(~(len == 32'h0))
270
                dma_register[0] <= dma_register[0] | 32'h2;                               // Set the busy pin
271
 
272
        if((reen == 1'b1) && (len == 1'b1))
273
                dma_register[0] <= dma_register[0] | 32'h4;                               // Set the reop pin
274
 
275
        if((ween == 1'b1) && (len == 1'b1))
276
                dma_register[0] <= dma_register[0] | 32'h8;                               // Set the weop pin
277
 
278
        if((dma_register3 == dma_register2) || (dma_register3 == dma_register1))
279
                dma_register[0] <= dma_register[0] | 32'hf;                               // Set the len pin
280
 
281
        if(fifo_rd == 1'b1)
282
                dma_register[3] <= dma_register[3] - dma_wr_addr_cnt;
283
 
284
   if(fifo_wr == 1'b1)
285
                dma_register[3] <= dma_register[3] - dma_rd_addr_cnt;
286
 
287
        end
288
end
289
 
290
endmodule

powered by: WebSVN 2.1.0

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