SeriesRequestGenerator.cc revision 8655:e4001326a5ba
111818SChristian.Menard@tu-dresden.de/*
211818SChristian.Menard@tu-dresden.de * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
311818SChristian.Menard@tu-dresden.de * Copyright (c) 2009-2010 Advanced Micro Devices, Inc.
411818SChristian.Menard@tu-dresden.de * All rights reserved.
511818SChristian.Menard@tu-dresden.de *
611818SChristian.Menard@tu-dresden.de * Redistribution and use in source and binary forms, with or without
711818SChristian.Menard@tu-dresden.de * modification, are permitted provided that the following conditions are
811818SChristian.Menard@tu-dresden.de * met: redistributions of source code must retain the above copyright
911818SChristian.Menard@tu-dresden.de * notice, this list of conditions and the following disclaimer;
1011818SChristian.Menard@tu-dresden.de * redistributions in binary form must reproduce the above copyright
1111818SChristian.Menard@tu-dresden.de * notice, this list of conditions and the following disclaimer in the
1211818SChristian.Menard@tu-dresden.de * documentation and/or other materials provided with the distribution;
1311818SChristian.Menard@tu-dresden.de * neither the name of the copyright holders nor the names of its
1411818SChristian.Menard@tu-dresden.de * contributors may be used to endorse or promote products derived from
1511818SChristian.Menard@tu-dresden.de * this software without specific prior written permission.
1611818SChristian.Menard@tu-dresden.de *
1711818SChristian.Menard@tu-dresden.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1811818SChristian.Menard@tu-dresden.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1911818SChristian.Menard@tu-dresden.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2011818SChristian.Menard@tu-dresden.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2111818SChristian.Menard@tu-dresden.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2211818SChristian.Menard@tu-dresden.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2311818SChristian.Menard@tu-dresden.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2411818SChristian.Menard@tu-dresden.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2511818SChristian.Menard@tu-dresden.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2611818SChristian.Menard@tu-dresden.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2711818SChristian.Menard@tu-dresden.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2811818SChristian.Menard@tu-dresden.de */
2911818SChristian.Menard@tu-dresden.de
3011818SChristian.Menard@tu-dresden.de#include "cpu/testers/directedtest/DirectedGenerator.hh"
3111818SChristian.Menard@tu-dresden.de#include "cpu/testers/directedtest/RubyDirectedTester.hh"
3211818SChristian.Menard@tu-dresden.de#include "cpu/testers/directedtest/SeriesRequestGenerator.hh"
3311818SChristian.Menard@tu-dresden.de#include "debug/DirectedTest.hh"
3411818SChristian.Menard@tu-dresden.de
3511818SChristian.Menard@tu-dresden.deSeriesRequestGenerator::SeriesRequestGenerator(const Params *p)
3611818SChristian.Menard@tu-dresden.de    : DirectedGenerator(p)
3711818SChristian.Menard@tu-dresden.de{
3811818SChristian.Menard@tu-dresden.de    m_status = SeriesRequestGeneratorStatus_Thinking;
3911818SChristian.Menard@tu-dresden.de    m_active_node = 0;
4011818SChristian.Menard@tu-dresden.de    m_address = 0x0;
4111818SChristian.Menard@tu-dresden.de    m_addr_increment_size = p->addr_increment_size;
4211818SChristian.Menard@tu-dresden.de    m_issue_writes = p->issue_writes;
4311818SChristian.Menard@tu-dresden.de}
4411818SChristian.Menard@tu-dresden.de
4511818SChristian.Menard@tu-dresden.deSeriesRequestGenerator::~SeriesRequestGenerator()
4611818SChristian.Menard@tu-dresden.de{
4711818SChristian.Menard@tu-dresden.de}
4811818SChristian.Menard@tu-dresden.de
4911821SChristian.Menard@tu-dresden.debool
5011821SChristian.Menard@tu-dresden.deSeriesRequestGenerator::initiate()
5111818SChristian.Menard@tu-dresden.de{
5211818SChristian.Menard@tu-dresden.de    DPRINTF(DirectedTest, "initiating request\n");
5311822SChristian.Menard@tu-dresden.de    assert(m_status == SeriesRequestGeneratorStatus_Thinking);
5411818SChristian.Menard@tu-dresden.de
5511818SChristian.Menard@tu-dresden.de    RubyDirectedTester::CpuPort* port =
5611818SChristian.Menard@tu-dresden.de        safe_cast<RubyDirectedTester::CpuPort*>(m_directed_tester->
5711818SChristian.Menard@tu-dresden.de                                              getCpuPort(m_active_node));
5811818SChristian.Menard@tu-dresden.de
5911821SChristian.Menard@tu-dresden.de    Request::Flags flags;
6011821SChristian.Menard@tu-dresden.de
6111821SChristian.Menard@tu-dresden.de    // For simplicity, requests are assumed to be 1 byte-sized
6211818SChristian.Menard@tu-dresden.de    Request *req = new Request(m_address, 1, flags);
6311818SChristian.Menard@tu-dresden.de
6411822SChristian.Menard@tu-dresden.de    Packet::Command cmd;
6511821SChristian.Menard@tu-dresden.de    if (m_issue_writes) {
6611821SChristian.Menard@tu-dresden.de        cmd = MemCmd::WriteReq;
6711821SChristian.Menard@tu-dresden.de    } else {
6811818SChristian.Menard@tu-dresden.de        cmd = MemCmd::ReadReq;
6911821SChristian.Menard@tu-dresden.de    }
7011818SChristian.Menard@tu-dresden.de    PacketPtr pkt = new Packet(req, cmd, m_active_node);
7111822SChristian.Menard@tu-dresden.de    uint8_t* dummyData = new uint8_t;
7211822SChristian.Menard@tu-dresden.de    *dummyData = 0;
7311822SChristian.Menard@tu-dresden.de    pkt->dataDynamic(dummyData);
7411822SChristian.Menard@tu-dresden.de
7511822SChristian.Menard@tu-dresden.de    if (port->sendTiming(pkt)) {
7611818SChristian.Menard@tu-dresden.de        DPRINTF(DirectedTest, "initiating request - successful\n");
7711822SChristian.Menard@tu-dresden.de        m_status = SeriesRequestGeneratorStatus_Request_Pending;
7811822SChristian.Menard@tu-dresden.de        return true;
7911818SChristian.Menard@tu-dresden.de    } else {
8011821SChristian.Menard@tu-dresden.de        // If the packet did not issue, must delete
8111821SChristian.Menard@tu-dresden.de        // Note: No need to delete the data, the packet destructor
8211818SChristian.Menard@tu-dresden.de        // will delete it
8311818SChristian.Menard@tu-dresden.de        delete pkt->req;
8411818SChristian.Menard@tu-dresden.de        delete pkt;
8511818SChristian.Menard@tu-dresden.de
8611818SChristian.Menard@tu-dresden.de        DPRINTF(DirectedTest, "failed to initiate request - sequencer not ready\n");
8711818SChristian.Menard@tu-dresden.de        return false;
8811818SChristian.Menard@tu-dresden.de    }
8911818SChristian.Menard@tu-dresden.de}
90
91void
92SeriesRequestGenerator::performCallback(uint32_t proc, Addr address)
93{
94    assert(m_active_node == proc);
95    assert(m_address == address);
96    assert(m_status == SeriesRequestGeneratorStatus_Request_Pending);
97
98    m_status = SeriesRequestGeneratorStatus_Thinking;
99    m_active_node++;
100    if (m_active_node == m_num_cpus) {
101        //
102        // Cycle of requests completed, increment cycle completions and restart
103        // at cpu zero
104        //
105        m_directed_tester->incrementCycleCompletions();
106        m_address += m_addr_increment_size;
107        m_active_node = 0;
108    }
109}
110
111SeriesRequestGenerator *
112SeriesRequestGeneratorParams::create()
113{
114    return new SeriesRequestGenerator(this);
115}
116