private static Cmd base_cmd_issue(ReqType r, MemAddr a, Cmd cmd, NodeMachine bank, NodeMachine subarray)
        {
            Dbg.Assert(bank.OpenChildrenId.Count <= 1);

            // closed bank
            if (bank.OpenChildrenId.Count == 0)
            {
                cmd.Type = CmdType.ACT;
                return(cmd);
            }

            // subarray-miss
            if (bank.OpenChildrenId[0] != a.said)
            {
                cmd.Type = CmdType.PRE_BANK;
                return(cmd);
            }

            // row-miss
            if (subarray.OpenChildrenId[0] != a.rowid)
            {
                cmd.Type = CmdType.PRE_BANK;
                return(cmd);
            }

            // row-hit
            cmd.Type = r == ReqType.READ ? CmdType.RD : CmdType.WR;
            return(cmd);
        }
        private static Cmd salp1_cmd_issue(ReqType r, MemAddr a, Cmd cmd, NodeMachine bank, NodeMachine subarray)
        {
            Dbg.Assert(bank.OpenChildrenId.Count <= 1);

            // closed bank
            if (bank.OpenChildrenId.Count == 0)
            {
                cmd.Type = CmdType.ACT;
                return(cmd);
            }

            // subarray-miss
            if (bank.OpenChildrenId[0] != a.said)
            {
                cmd.Type      = CmdType.PRE_SA;
                cmd.Addr.said = (uint)bank.OpenChildrenId[0]; // close the opened sibling
                return(cmd);
            }

            // row-miss
            if (subarray.OpenChildrenId[0] != a.rowid)
            {
                cmd.Type = CmdType.PRE_SA;
                return(cmd);
            }

            // row-hit
            cmd.Type = r == ReqType.READ ? CmdType.RD : CmdType.WR;
            return(cmd);
        }
        private static Cmd masa_cmd_issue(ReqType r, MemAddr a, Cmd cmd, NodeMachine bank, NodeMachine subarray)
        {
            var open_said = bank.OpenChildrenId;

            // subarray-miss
            if (!open_said.Contains(a.said))
            {
                cmd.Type = CmdType.ACT;
                return(cmd);
            }

            // row-miss
            if (!subarray.OpenChildrenId.Contains(a.rowid))
            {
                cmd.Type = CmdType.PRE_SA;
                return(cmd);
            }

            // not the most-recently-opened subarray
            if (open_said[0] != a.said && !Config.mctrl.b_piggyback_SEL_SA)
            {
                cmd.Type = CmdType.SEL_SA;
                return(cmd);
            }

            // row-hit
            cmd.Type = r == ReqType.READ ? CmdType.RD : CmdType.WR;
            return(cmd);
        }
        private static Cmd salp2_cmd_issue(ReqType r, MemAddr a, Cmd cmd, NodeMachine bank, NodeMachine subarray)
        {
            Dbg.Assert(bank.OpenChildrenId.Count <= 2);

            // closed bank
            if (bank.OpenChildrenId.Count == 0)
            {
                cmd.Type = CmdType.ACT;
                return(cmd);
            }
            // open bank (one subarray)
            if (bank.OpenChildrenId.Count == 1)
            {
                // subarray-miss
                if (bank.OpenChildrenId[0] != a.said)
                {
                    cmd.Type = CmdType.ACT;
                    return(cmd);
                }

                // row-miss
                if (subarray.OpenChildrenId[0] != a.rowid)
                {
                    cmd.Type = CmdType.PRE_SA;
                    return(cmd);
                }

                // row-hit
                cmd.Type = r == ReqType.READ ? CmdType.RD : CmdType.WR;
                return(cmd);
            }
            // open bank (two subarrays)
            // all subarray-miss
            if (!bank.OpenChildrenId.Contains(a.said))
            {
                cmd.Type      = CmdType.PRE_SA;
                cmd.Addr.said = (uint)bank.OpenChildrenId[1]; // close least-recently-opened subarray
                return(cmd);
            }

            // not the most-recently-opened subarray
            if (bank.OpenChildrenId[0] != a.said)
            {
                cmd.Type      = CmdType.PRE_SA;
                cmd.Addr.said = (uint)bank.OpenChildrenId[1]; // close least-recently-opened subarray
                return(cmd);
            }

            // row-miss
            if (subarray.OpenChildrenId[0] != a.rowid)
            {
                cmd.Type = CmdType.PRE_SA;
                return(cmd);
            }

            // row-hit
            cmd.Type = r == ReqType.READ ? CmdType.RD : CmdType.WR;
            return(cmd);
        }
        public NodeMachine(NodeMachine parent, int level, uint id, uint[] fanOutArray)
        {
            Parent     = parent;
            this.level = (Level)level;
            this.id    = id;

            // initialize open children
            OpenChildrenId = new List <ulong>();

            // initialize children
            if (level == (int)Level.SUBARRAY)
            {
                Children = null; // a subarray has *NO* child objects
                return;
            }

            Children = new NodeMachine[fanOutArray[level + 1]];
            for (uint i = 0; i < Children.Length; i++)
            {
                Children[i] = new NodeMachine(this, level + 1, i, fanOutArray);
            }
        }
 public DRAMState(uint cid, uint[] fanOutArray, MemCtrl.MemCtrl mctrl)
 {
     _channel = new NodeMachine(null, 0, cid, fanOutArray);
 }