Ejemplo n.º 1
0
 public RegisterProperty(uint index, uint regAddr, string regVal,
                         RWProperty rw, bool ifRead, bool ifwrite)
 {
     this._index      = index;
     this._regAddress = regAddr;
     this._regData    = regVal;
     this._rw         = rw;
     this._ifRead     = ifRead;
     this._ifWrite    = ifwrite;
     //_Read = "Read";
 }
Ejemplo n.º 2
0
        /// <summary>
        /// One Register(8 bits)
        /// </summary>
        /// <param name="_regGroup">the group name.</param>
        /// <param name="_regName">Register name.</param>
        /// <param name="_regAddress">Register address.</param>
        /// <param name="_rw"> register access propery.</param>
        /// <param name="_defaultValue">Defalut Value. </param>
        /// <param name="_paras">Bit field names array, LSB first.
        /// 3 bf example:bit7 - bit0: bf_2, bf_1, bf_0 -> _paras[0] = bf_0.name ... _paras[2] = bf_2.name</param>
        public Register(string _regGroup, string _regName, string _regAddress, RWProperty _rw, string _defaultValue, params object[] _paras)
        {
            this.groupName = _regGroup;
            this.regName   = _regName;
            this.regAddr   = byte.Parse(_regAddress.Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);
            this.rwPro     = _rw;
            this.regValue  = byte.Parse(_defaultValue.Replace("0x", ""), System.Globalization.NumberStyles.HexNumber);
            this.paras     = _paras;

            bfList.Clear();
            for (int ix = 0; ix < _paras.Length; ix++)
            {
                bfList.Add(new BitField(this, "", this.byteCount, (string)_paras[ix], "", ""));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create regmap from local excel data without bitfield
        /// </summary>
        /// <param name="_dsExcel"></param>
        private RegisterMap CreateRegMap(DataSet _dsExcel)
        {
            RegisterMap _regmap = new RegisterMap();

            ds_display.Clear();
            DataTable dt = _dsExcel.Tables[regmapName];

            // Get Device Address
            if (dt.Rows[0][0].ToString().ToUpper() == devAddrName)
            {
                this.devAddr    = Convert.ToUInt32(dt.Rows[0][1].ToString().TrimStart("7'b".ToCharArray()), 2);
                _regmap.DevAddr = devAddr;
            }

            // judge if this is a crazy mode reg map, if crazy mode, then there is one more column for num. of bytes of 1 register
            if (dt.Rows[0][2].ToString().ToUpper() == devRegMode)
            {
                if (dt.Rows[0][3].ToString().ToUpper() == "CRAZY")
                {
                    crazyMode = true;
                }
            }

            DataRowCollection drc = dt.Rows;
            int    rowsCount      = dt.Rows.Count;
            string regGroup       = "";
            string regName        = "";
            string regAddr        = "";
            string numOfBytes     = "";
            string defaultValue   = "";

            object[]      items;
            List <object> temp_bf = new List <object> {
            };
            int valid_count       = 0;

            RWProperty rw = RWProperty.RW;

            for (int ix = 2; ix < rowsCount;)
            {
                #region normal register map
                if (!crazyMode)
                {
                    // New reg group generated here
                    if (drc[ix].ItemArray[(int)itemIx.regGroup].ToString() != "")
                    {
                        regGroup = drc[ix].ItemArray[(int)itemIx.regGroup].ToString().Replace("\n", "");
                        _regmap.AddGroup(regGroup);
                    }

                    // Get all valid bit field name and store in a long array
                    items       = drc[ix++].ItemArray;
                    valid_count = 0;
                    temp_bf.Clear();
                    for (int bit_ix = (int)itemIx.bit7; bit_ix <= (int)itemIx.bit0; bit_ix++)
                    {
                        if (items[bit_ix].ToString() != "")
                        {
                            valid_count++;
                            temp_bf.Add(items[bit_ix]);
                        }
                    }

                    if (valid_count == 0)
                    {
                        continue;
                    }

                    // copy the true valid bit field name to new bitfield name array
                    object[] bfs = new object[valid_count];
                    for (int bf_ix = 0; bf_ix < valid_count; bf_ix++)
                    {
                        bfs[bf_ix] = temp_bf[bf_ix];
                    }

                    if (items[(int)itemIx.rw].ToString() == "R")
                    {
                        rw = RWProperty.R;
                    }
                    else if (items[3].ToString() == "W")
                    {
                        rw = RWProperty.W;
                    }
                    else
                    {
                        rw = RWProperty.RW;
                    }

                    _regmap.Add(new Register(regGroup, items[(int)itemIx.regName].ToString(), items[(int)itemIx.regAddr].ToString(), rw, items[(int)itemIx.defaultRegValue].ToString(), bfs));
                }
                #endregion

                #region  crazy register map mode
                else
                {
                    // New reg group generated here
                    if (drc[ix].ItemArray[(int)itemIx_Crazy.regGroup].ToString() != "")
                    {
                        regGroup = drc[ix].ItemArray[(int)itemIx_Crazy.regGroup].ToString().Replace("\n", "");
                        _regmap.AddGroup(regGroup);
                    }

                    // New Reg start from here, get regName, regAddr and number of bytes
                    if (drc[ix].ItemArray[(int)itemIx_Crazy.regName].ToString() != "")
                    {
                        regName      = drc[ix].ItemArray[(int)itemIx_Crazy.regName].ToString();
                        regAddr      = drc[ix].ItemArray[(int)itemIx_Crazy.regAddr].ToString();
                        numOfBytes   = drc[ix].ItemArray[(int)itemIx_Crazy.byteCount].ToString();
                        defaultValue = drc[ix].ItemArray[(int)itemIx_Crazy.defaultRegValue].ToString();
                    }

                    if (regName.ToUpper() == "RESERVED")
                    {
                        ix++;
                        continue;
                    }

                    // Get all valid bit field name and store in a long array
                    temp_bf.Clear();
                    valid_count = 0;
                    do
                    {
                        items = drc[ix].ItemArray;
                        for (int bit_ix = (int)itemIx_Crazy.bit7; bit_ix <= (int)itemIx_Crazy.bit0; bit_ix++)
                        {
                            if (items[bit_ix].ToString() != "" && items[bit_ix].ToString().ToUpper() != "RESERVED")
                            {
                                valid_count++;
                                temp_bf.Add(items[bit_ix]);
                            }
                        }
                    } while ((++ix < rowsCount) && (drc[ix].ItemArray[(int)itemIx_Crazy.regName].ToString() == ""));

                    // copy the true valid bit field name to new bitfield name array
                    object[] bfs = new object[valid_count];
                    for (int bf_ix = 0; bf_ix < valid_count; bf_ix++)
                    {
                        bfs[bf_ix] = temp_bf[bf_ix];
                    }

                    if (items[(int)itemIx_Crazy.rw].ToString() == "R")
                    {
                        rw = RWProperty.R;
                    }
                    else if (items[3].ToString() == "W")
                    {
                        rw = RWProperty.W;
                    }
                    else
                    {
                        rw = RWProperty.RW;
                    }

                    _regmap.Add(new Register(regGroup, regName, regAddr, rw, numOfBytes, defaultValue, bfs));
                }
                #endregion
            }

            return(_regmap);
        }