Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / niu / rxc_sat / vera / rxdma / niu_rxdmc_init.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: niu_rxdmc_init.vr
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35#include "niu_rxdmc.vrh"
36
37extern CRDMC rdmc;
38class niu_rxdmc_init_class {
39
40 task new() {
41 rxdmc_init();
42 }
43
44 task rxdmc_init();
45}
46
47task niu_rxdmc_init_class::rxdmc_init() {
48 shadow integer n;
49 shadow integer i;
50 integer dma_chnl, desc_ring_length,compl_ring_len,initial_kick;
51 integer blk_size,buf_siz0,buf_siz1,buf_siz2,vld0,vld1,vld2;
52 bit [63:0] rbr_config_B_data;
53
54
55 if (get_plus_arg (CHECK, "LOOP_BACK_RXDMA_CHNL"))
56 dma_chnl = (get_plus_arg (NUM, "LOOP_BACK_RXDMA_CHNL"))%16;
57 else
58 dma_chnl = 0 ;
59
60 if (get_plus_arg (CHECK,"RX_BLKSZ"))
61 blk_size = get_plus_arg(NUM,"RX_BLKSZ");
62 else
63 blk_size = 4;
64 if (get_plus_arg (CHECK,"RX_BUF_SIZ0"))
65 buf_siz0 = get_plus_arg(NUM,"RX_BUF_SIZ0");
66 else
67 buf_siz0 = 256;
68 if (get_plus_arg (CHECK,"RX_BUF_SIZ1"))
69 buf_siz1 = get_plus_arg(NUM,"RX_BUF_SIZ1");
70 else
71 buf_siz1 = 1024;
72 if (get_plus_arg (CHECK,"RX_BUF_SIZ2"))
73 buf_siz2 = get_plus_arg(NUM,"RX_BUF_SIZ2");
74 else
75 buf_siz2 = 2048;
76 if (get_plus_arg (CHECK,"VLD0"))
77 vld0 = get_plus_arg(NUM,"VLD0");
78 else
79 vld0 = 1;
80 if (get_plus_arg (CHECK,"VLD1"))
81 vld1 = get_plus_arg(NUM,"VLD1");
82 else
83 vld1 = 1;
84 if (get_plus_arg (CHECK,"VLD2"))
85 vld2 = get_plus_arg(NUM,"VLD2");
86 else
87 vld2 = 1;
88
89 rbr_config_B_data[63:26]= 0;
90 rbr_config_B_data[22:18]= 0;
91 rbr_config_B_data[14:10]= 0;
92 rbr_config_B_data[6:2]= 0;
93
94 case(blk_size) {
95 4: rbr_config_B_data[25:24] = 2'b00;
96 8: rbr_config_B_data[25:24] = 2'b01;
97 16: rbr_config_B_data[25:24] = 2'b10;
98 32: rbr_config_B_data[25:24] = 2'b11;
99 }
100 rbr_config_B_data[23] = vld2; //VLD2
101 rbr_config_B_data[17:16] = 2'b00;
102 case(buf_siz2) {
103 2048: rbr_config_B_data[17:16] = 2'b00;
104 4096: rbr_config_B_data[17:16] = 2'b01;
105 8192: rbr_config_B_data[17:16] = 2'b10;
106 16384: rbr_config_B_data[17:16] = 2'b11;
107 }
108 rbr_config_B_data[15] = vld1; //VLD1
109 rbr_config_B_data[9:8] = 2'b00;
110 case(buf_siz1) {
111 1024: rbr_config_B_data[9:8] = 2'b00;
112 2048: rbr_config_B_data[9:8] = 2'b01;
113 4096: rbr_config_B_data[9:8] = 2'b10;
114 8192: rbr_config_B_data[9:8] = 2'b11;
115 }
116 rbr_config_B_data[7] = vld0; //VLD0
117 case(buf_siz0) {
118 256: rbr_config_B_data[1:0] = 2'b00;
119 512: rbr_config_B_data[1:0] = 2'b01;
120 1024: rbr_config_B_data[1:0] = 2'b10;
121 2048: rbr_config_B_data[1:0] = 2'b11;
122 }
123
124// ###################################################################################################
125// ###################################################################################################
126// ###################################################################################################
127 // One single function to initialize the whole RXDMA channel
128 // This function should be called for each RXDMA channel you want to initialize
129 desc_ring_length = 16'h1fff;
130 compl_ring_len = 16'h2000;
131 initial_kick = 16'h00ff;
132 rdmc.InitRXDMA(dma_chnl, desc_ring_length, compl_ring_len, rbr_config_B_data, initial_kick);
133
134}