/*
 * Copyright 2019 Google, Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met: redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer;
 * redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution;
 * neither the name of the copyright holders nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Authors: Gabe Black
 */

#include "arch/arm/fastmodel/amba_to_tlm_bridge.hh"

#include "params/AmbaToTlmBridge64.hh"

namespace FastModel
{

AmbaToTlmBridge64::AmbaToTlmBridge64(const char *name) :
    amba_pv::amba_pv_to_tlm_bridge<64>(name),
    tlmWrapper(tlm_m, std::string(name) + ".tlm", -1),
    ambaWrapper(amba_pv_s, std::string(name) + ".amba", -1)
{}

Port &
AmbaToTlmBridge64::gem5_getPort(const std::string &if_name, int idx)
{
    if (if_name == "tlm")
        return tlmWrapper;
    else if (if_name == "amba")
        return ambaWrapper;
    else
        return amba_pv::amba_pv_to_tlm_bridge<64>::gem5_getPort(if_name, idx);
}

} // namespace FastModel

FastModel::AmbaToTlmBridge64 *
AmbaToTlmBridge64Params::create()
{
    return new FastModel::AmbaToTlmBridge64(name.c_str());
}
