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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [tbench/] [systemc/] [sc_pkt_if.cpp] - Diff between revs 15 and 29

Show entire file | Details | Blame | View Log

Rev 15 Rev 29
Line 52... Line 52...
    return &rx_fifo;
    return &rx_fifo;
}
}
 
 
void pkt_if::init(void) {
void pkt_if::init(void) {
    disable_rx = false;
    disable_rx = false;
 
    flush_rx = false;
    allow_rx_sop_err = false;
    allow_rx_sop_err = false;
}
}
 
 
void pkt_if::connect_scoreboard(scoreboard *sbptr, scoreboard::sbSourceId sid) {
void pkt_if::connect_scoreboard(scoreboard *sbptr, scoreboard::sbSourceId sid) {
    sb = sbptr;
    sb = sbptr;
Line 114... Line 115...
            // Pass packet to scoreboard
            // Pass packet to scoreboard
 
 
            sb->notify_packet_tx(sb_id, pkt);
            sb->notify_packet_tx(sb_id, pkt);
 
 
            //---
            //---
            // Enforce minimum spacing between SOP's
            // Wait for room in the FIFO before processing next packet
 
 
            for (int i = (pkt->length+7)/8; i < 8; i++) {
            while (pkt_tx_full) {
                wait();
                wait();
            }
            }
        }
        }
    }
    }
};
};
Line 130... Line 131...
 
 
    packet_t* pkt;
    packet_t* pkt;
 
 
    sc_uint<64> data;
    sc_uint<64> data;
 
 
 
    bool flush;
 
 
    wait();
    wait();
 
 
    while (true) {
    while (true) {
 
 
        if (pkt_rx_avail && !disable_rx) {
        if (pkt_rx_avail && !disable_rx) {
 
 
            pkt = new(packet_t);
            pkt = new(packet_t);
            pkt->length = 0;
            pkt->length = 0;
 
            pkt->err_flags = 0;
 
            flush = false;
 
 
            // If reading already selected just keep going,
            // If reading already selected just keep going,
            // if not we must enable ren
            // if not we must enable ren
            if (!pkt_rx_ren) {
            if (!pkt_rx_ren) {
                pkt_rx_ren = 1;
                pkt_rx_ren = 1;
Line 181... Line 186...
 
 
                for (int lane = 0; lane < 8; lane++) {
                for (int lane = 0; lane < 8; lane++) {
 
 
                    pkt->data[pkt->length++] = (data >> (8 * (7-lane))) & 0xff;
                    pkt->data[pkt->length++] = (data >> (8 * (7-lane))) & 0xff;
 
 
                    if (pkt->length >= 10000) {
                    if (pkt->length >= 17000) {
                        cout << "ERROR: Packet too long" << endl;
                        cout << "ERROR: Packet too long" << endl;
                        sc_stop();
                        sc_stop();
                    }
                    }
 
 
                    if (pkt_rx_eop && (pkt_rx_mod == ((lane+1) % 8))) {
                    if (pkt_rx_eop && (pkt_rx_mod == ((lane+1) % 8))) {
Line 198... Line 203...
                if (pkt_rx_eop) {
                if (pkt_rx_eop) {
                    break;
                    break;
                }
                }
            }
            }
 
 
 
            if (flush_rx && pkt->err_flags) {
 
                flush = true;
 
            }
 
 
            //---
            //---
            // Store packet
            // Store packet
 
 
            unpack(pkt);
            unpack(pkt);
            //rx_fifo.write(pkt);
            //rx_fifo.write(pkt);
Line 209... Line 218...
            //cout << "Receive PKT_IF packet:\n" << * pkt << endl;
            //cout << "Receive PKT_IF packet:\n" << * pkt << endl;
 
 
            //---
            //---
            // Pass packet to scoreboard
            // Pass packet to scoreboard
 
 
 
            if (!flush) {
            sb->notify_packet_rx(sb_id, pkt);
            sb->notify_packet_rx(sb_id, pkt);
 
            }
 
 
        }
        }
        else {
        else {
            pkt_rx_ren = 0;
            pkt_rx_ren = 0;
            wait();
            wait();

powered by: WebSVN 2.1.0

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