/*
         * Function: Push
         * Description: Push a new segment into the buffer
         */
        public bool Push(uint tkeep, bool tlast, ulong tdata_0, ulong tdata_1, ulong tdata_2, ulong tdata_3,
                         ulong tuser_hi, ulong tuser_low, bool pstart = false)
        {
            if (!CanPush())
            {
                DebugFunctions.push_interrupt(DebugFunctions.Errors.FIFO_FULL);
                return(false);
            }

            //lock (_lck)
            //{
            if (pstart)
            {
                _curstart = writeloc;
            }

            _tkeep[writeloc]     = tkeep;
            _tlast[writeloc]     = tlast;
            _tdata_0[writeloc]   = tdata_0;
            _tdata_1[writeloc]   = tdata_1;
            _tdata_2[writeloc]   = tdata_2;
            _tdata_3[writeloc]   = tdata_3;
            _tuser_hi[writeloc]  = tuser_hi;
            _tuser_low[writeloc] = tuser_low;
            _pstart[writeloc]    = _curstart;
            _valid[writeloc]     = true;
            Count++;
            writeloc = (writeloc + 1) % Bufsize;
            //}

            Emu.debug_reg = Count;
            return(true);
        }
Ejemplo n.º 2
0
        public bool sendOne(bool check_ready = true, bool check_updated = true)
        {
            if ((!check_updated || s_updated) && (!check_ready || Emu.axi_m_axis_tready))
            {
                s_updated              = false;
                Emu.axi_m_axis_tvalid  = true;
                Emu.axi_m_axis_tdata_0 = axi_m_axis_tdata_0;
                Emu.axi_m_axis_tdata_1 = axi_m_axis_tdata_1;
                Emu.axi_m_axis_tdata_2 = axi_m_axis_tdata_2;
                Emu.axi_m_axis_tdata_3 = axi_m_axis_tdata_3;
                Emu.axi_m_axis_tstrb   = axi_m_axis_tstrb;
                Emu.axi_m_axis_tkeep   = axi_m_axis_tkeep;
                Emu.axi_m_axis_tlast   = axi_m_axis_tlast;
                Emu.axi_m_axis_tid     = axi_m_axis_tid;
                Emu.axi_m_axis_tdest   = axi_m_axis_tdest;
                Emu.axi_m_axis_tuser_0 = axi_m_axis_tuser_0;
                Emu.axi_m_axis_tuser_1 = axi_m_axis_tuser_1;
                Kiwi.Pause();
                Emu.axi_m_axis_tvalid = false;
                return(true);
            }

            if (check_ready && !Emu.axi_m_axis_tready)
            {
                DebugFunctions.push_interrupt(DebugFunctions.Errors.SEND_NOT_READY);
                return(false);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public bool push(ulong data)
        {
            if (!Emu.fifo_full)
            {
                Emu.fifo_din   = data;
                Emu.fifo_wr_en = true;
                Kiwi.Pause();
                Emu.fifo_wr_en = false;
                return(true);
            }

            DebugFunctions.push_interrupt(DebugFunctions.Errors.FIFO_FULL);
            return(false);
        }
Ejemplo n.º 4
0
        public ulong pop()
        {
            if (!Emu.fifo_empty)
            {
                var data = Emu.fifo_dout;
                Emu.fifo_rd_en = true;
                Kiwi.Pause();

                Emu.fifo_rd_en = false;
                return(data);
            }

            DebugFunctions.push_interrupt(DebugFunctions.Errors.FIFO_EMPTY);
            return(0);
        }
Ejemplo n.º 5
0
        private static void run()
        {
            //Test Packet Generation
            SetPacketData();

            //Generate packet (uses ethernet, ip and udp generator)
            HeaderGen.WriteUDPHeader(cfb, up, ep, ip, InterfaceFunctions.PORT_BROADCAST);

            //Write Contents of Buffer
            cfb.PrintContents();

            cfb.ResetPeek();

            // Verify Parsed Values
            ep.Parse(cfb);
            System.Console.WriteLine($"src_mac: {ep.SrcMac:X12} dest_mac: {ep.DestMac:X12} ethertype: {ep.Ethertype:X4}");
            ip.Parse(cfb);
            System.Console.WriteLine($"version: {ip.Version} IHL: {ip.IHL} DSCP: {ip.DSCP} ECN: {ip.ECN}");
            System.Console.WriteLine($"total_length: {ip.TotalLength} id: {ip.Identification} flags: {ip.Flags}");
            System.Console.WriteLine($"frag_offset: {ip.FragmentOffset} TTL: {ip.TTL} protocol: {ip.Protocol}");
            System.Console.WriteLine($"src_ip: {ip.SrcIp:X8} dest_ip: {ip.DestIp:X8}");
            up.Parse(cfb, ip.IHL);
            System.Console.WriteLine($"src_port: {up.SrcPort:x4} dest_port: {up.DestPort:x4} length: {up.Length:x4}");

            // Verify Interrupts
            DebugFunctions.interrupts_enable();
            DebugFunctions.push_interrupt(DebugFunctions.Errors.PACKET_DROP);
            DebugFunctions.push_interrupt(DebugFunctions.Errors.PARSE_FAIL);
            System.Console.WriteLine($"errors: {Emu.Interrupts:X16}");
            DebugFunctions.reset_interrupt();
            System.Console.WriteLine($"errors: {Emu.Interrupts:X16}");


            // Verify Sending Packets
            CircularNetworkFunctions.SendOne(cfb, false, true);
            System.Console.WriteLine($"data0: {Emu.m_axis_tdata_0:X16}");
            System.Console.WriteLine($"data1: {Emu.m_axis_tdata_1:X16}");
            System.Console.WriteLine($"data2: {Emu.m_axis_tdata_2:X16}");
            System.Console.WriteLine($"data3: {Emu.m_axis_tdata_3:X16}");

            CircularNetworkFunctions.SendOne(cfb, false, true);
            System.Console.WriteLine($"data0: {Emu.m_axis_tdata_0:X16}");
            System.Console.WriteLine($"data1: {Emu.m_axis_tdata_1:X16}");
            System.Console.WriteLine($"data2: {Emu.m_axis_tdata_2:X16}");
            System.Console.WriteLine($"data3: {Emu.m_axis_tdata_3:X16}");
        }
        /*
         * Function: UpdatePeek
         * Description: Update the value of the current peek location with the contents of a BufferEntry
         */
        public bool UpdatePeek(BufferEntry be)
        {
            //lock (_lck)
            //{
            //lock (PeekData)
            //{
            if (!_valid[peekloc])
            {
                DebugFunctions.push_interrupt(DebugFunctions.Errors.PACKET_BUFFER_INVALID);
                return(false);
            }

            _tkeep[peekloc]     = be.Tkeep;
            _tlast[peekloc]     = be.Tlast;
            _tdata_0[peekloc]   = be.Tdata0;
            _tdata_1[peekloc]   = be.Tdata1;
            _tdata_2[peekloc]   = be.Tdata2;
            _tdata_3[peekloc]   = be.Tdata3;
            _tuser_hi[peekloc]  = be.TuserHi;
            _tuser_low[peekloc] = be.TuserLow;
            return(true);
            //}
            //}
        }