Updated to work with latest sc-components
This commit is contained in:
parent
d92279f100
commit
7032b187f0
|
@ -5,7 +5,7 @@
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="124751743283202443" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-27600165872313448" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="124751743283202443" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-27600165872313448" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
namespace sysc {
|
namespace sysc {
|
||||||
|
|
||||||
class gpio_regs : public sc_core::sc_module, public scc::resetable {
|
class gpio_regs : public sc_core::sc_module, public scc::resetable {
|
||||||
protected:
|
public:
|
||||||
// storage declarations
|
// storage declarations
|
||||||
uint32_t r_value;
|
uint32_t r_value;
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,44 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright 2017 eyck@minres.com
|
// Copyright (C) 2017, MINRES Technologies GmbH
|
||||||
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// use this file except in compliance with the License. You may obtain a copy
|
// modification, are permitted provided that the following conditions are met:
|
||||||
// of the License at
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. 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.
|
||||||
|
//
|
||||||
|
// 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// eyck@minres.com - initial implementation
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
// License for the specific language governing permissions and limitations under
|
|
||||||
// the License.
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
#include "gen/gpio_regs.h"
|
#include "scc/report.h"
|
||||||
#include "scc/utilities.h"
|
#include "scc/utilities.h"
|
||||||
|
#include "gen/gpio_regs.h"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace sysc {
|
namespace sysc {
|
||||||
|
|
||||||
|
@ -25,25 +47,176 @@ gpio::gpio(sc_core::sc_module_name nm)
|
||||||
, tlm_target<>(clk)
|
, tlm_target<>(clk)
|
||||||
, NAMED(clk_i)
|
, NAMED(clk_i)
|
||||||
, NAMED(rst_i)
|
, NAMED(rst_i)
|
||||||
, NAMED(out, 32)
|
, NAMED(pins_o, 32)
|
||||||
, NAMED(in, 32)
|
, NAMED(pins_i, 32)
|
||||||
, NAMEDD(gpio_regs, regs) {
|
, NAMED(iof0_o, 32)
|
||||||
|
, NAMED(iof1_o, 32)
|
||||||
|
, NAMED(iof0_i, 32)
|
||||||
|
, NAMED(iof1_i, 32)
|
||||||
|
, NAMEDD(gpio_regs, regs)
|
||||||
|
{
|
||||||
regs->registerResources(*this);
|
regs->registerResources(*this);
|
||||||
SC_METHOD(clock_cb);
|
SC_METHOD(clock_cb);
|
||||||
sensitive << clk_i;
|
sensitive << clk_i;
|
||||||
SC_METHOD(reset_cb);
|
SC_METHOD(reset_cb);
|
||||||
sensitive << rst_i;
|
sensitive << rst_i;
|
||||||
|
dont_initialize();
|
||||||
|
auto pins_i_cb =[this](unsigned int tag, tlm::tlm_signal_gp<>& gp,
|
||||||
|
tlm::tlm_phase& phase, sc_core::sc_time& delay)->tlm::tlm_sync_enum{
|
||||||
|
this->pin_input(tag, gp, delay);
|
||||||
|
return tlm::TLM_COMPLETED;
|
||||||
|
};
|
||||||
|
auto i=0U;
|
||||||
|
for(auto& s:pins_i){
|
||||||
|
s.register_nb_transport(pins_i_cb, i);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
auto iof0_i_cb =[this](unsigned int tag, tlm::tlm_signal_gp<>& gp,
|
||||||
|
tlm::tlm_phase& phase, sc_core::sc_time& delay)->tlm::tlm_sync_enum{
|
||||||
|
last_iof0[tag]=gp.get_value();
|
||||||
|
this->iof_input(tag, 0, gp, delay);
|
||||||
|
return tlm::TLM_COMPLETED;
|
||||||
|
};
|
||||||
|
i=0;
|
||||||
|
for(auto& s:iof0_i){
|
||||||
|
s.register_nb_transport(iof0_i_cb, i);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
auto iof1_i_cb =[this](unsigned int tag, tlm::tlm_signal_gp<>& gp,
|
||||||
|
tlm::tlm_phase& phase, sc_core::sc_time& delay)->tlm::tlm_sync_enum{
|
||||||
|
last_iof1[tag]=gp.get_value();
|
||||||
|
this->iof_input(tag, 1, gp, delay);
|
||||||
|
return tlm::TLM_COMPLETED;
|
||||||
|
};
|
||||||
|
i=0;
|
||||||
|
for(auto& s:iof1_i){
|
||||||
|
s.register_nb_transport(iof1_i_cb, i);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
auto update_pins_cb = [this](scc::sc_register<uint32_t> ®, uint32_t data, sc_core::sc_time d) -> bool {
|
||||||
|
if (!this->regs->in_reset()) {
|
||||||
|
auto changed_bits = (reg.get()^data);
|
||||||
|
reg.put(data);
|
||||||
|
update_pins(changed_bits);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
regs->port.set_write_cb(update_pins_cb);
|
||||||
|
regs->output_en.set_write_cb(update_pins_cb);
|
||||||
|
regs->out_xor.set_write_cb(update_pins_cb);
|
||||||
|
regs->iof_en.set_write_cb(update_pins_cb);
|
||||||
|
regs->iof_sel.set_write_cb(update_pins_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpio::~gpio() {}
|
gpio::~gpio() {}
|
||||||
|
|
||||||
void gpio::clock_cb() {}
|
|
||||||
|
|
||||||
void gpio::reset_cb() {
|
void gpio::reset_cb() {
|
||||||
if (rst_i.read())
|
if (rst_i.read()){
|
||||||
regs->reset_start();
|
regs->reset_start();
|
||||||
else
|
} else {
|
||||||
regs->reset_stop();
|
regs->reset_stop();
|
||||||
|
}
|
||||||
|
update_pins(std::numeric_limits<uint32_t>::max());
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpio::clock_cb() {
|
||||||
|
this->clk = clk_i.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
tlm::tlm_phase gpio::write_output(tlm::tlm_signal_gp<bool>& gp, size_t i, bool val) {
|
||||||
|
sc_core::sc_time delay{SC_ZERO_TIME};
|
||||||
|
tlm::tlm_phase phase{ tlm::BEGIN_REQ };
|
||||||
|
gp.set_command(tlm::TLM_WRITE_COMMAND);
|
||||||
|
gp.set_response_status(tlm::TLM_OK_RESPONSE);
|
||||||
|
gp.set_value(val);
|
||||||
|
pins_o.at(i)->nb_transport_fw(gp, phase, delay);
|
||||||
|
return phase;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpio::update_pins(uint32_t changed_bits) {
|
||||||
|
sc_core::sc_inout_rv<32>::data_type out_val;
|
||||||
|
tlm::tlm_signal_gp<bool> gp;
|
||||||
|
bool val;
|
||||||
|
for(size_t i=0, mask = 1; i<32; ++i, mask<<=1){
|
||||||
|
if(changed_bits&mask){
|
||||||
|
if((regs->r_iof_en&mask!=0) && (iof0_i[i].size()==0 || iof1_i[i].size()==0)){
|
||||||
|
if((regs->r_iof_sel&mask)==0 && iof0_i[i].size()>0){
|
||||||
|
val=last_iof0[i]?sc_dt::Log_1:sc_dt::Log_0;
|
||||||
|
} else if((regs->r_iof_sel&mask)==1 && iof1_i[i].size()>0)
|
||||||
|
val=last_iof1[i]?sc_dt::Log_1:sc_dt::Log_0;
|
||||||
|
} else {
|
||||||
|
if((regs->r_output_en&mask) && (regs->r_port&mask))
|
||||||
|
val=true;
|
||||||
|
else
|
||||||
|
val=false;
|
||||||
|
if(regs->r_out_xor&mask)
|
||||||
|
val=~val;
|
||||||
|
}
|
||||||
|
tlm::tlm_phase phase = write_output(gp, i, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpio::pin_input(unsigned int tag, tlm::tlm_signal_gp<bool>& gp, sc_core::sc_time& delay) {
|
||||||
|
if(delay>SC_ZERO_TIME){
|
||||||
|
wait(delay);
|
||||||
|
delay=SC_ZERO_TIME;
|
||||||
|
}
|
||||||
|
auto mask = 1u<<tag;
|
||||||
|
switch(gp.get_value()){
|
||||||
|
case true:
|
||||||
|
if(regs->r_output_en&mask==0)
|
||||||
|
regs->r_value|=mask;
|
||||||
|
forward_pin_input(tag, gp);
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
if(regs->r_output_en&mask==0) regs->r_value&=~mask;
|
||||||
|
forward_pin_input(tag, gp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpio::forward_pin_input(unsigned int tag, tlm::tlm_signal_gp<bool>& gp) {
|
||||||
|
const auto mask = 1U<<tag;
|
||||||
|
if(regs->iof_en&mask){
|
||||||
|
auto& socket = regs->iof_sel&mask?iof1_o[tag]:iof0_o[tag];
|
||||||
|
tlm::tlm_signal_gp<> new_gp;
|
||||||
|
for(size_t i=0; i<socket.size(); ++i){
|
||||||
|
sc_core::sc_time delay{SC_ZERO_TIME};
|
||||||
|
tlm::tlm_phase phase{tlm::BEGIN_REQ};
|
||||||
|
new_gp.set_command(tlm::TLM_WRITE_COMMAND);
|
||||||
|
new_gp.set_response_status(tlm::TLM_OK_RESPONSE);
|
||||||
|
new_gp.set_value(gp.get_value());
|
||||||
|
new_gp.update_extensions_from(gp);
|
||||||
|
socket->nb_transport_fw(new_gp, phase, delay); // we don't care about phase and sync enum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpio::iof_input(unsigned int tag, unsigned iof_idx, tlm::tlm_signal_gp<>& gp, sc_core::sc_time& delay) {
|
||||||
|
if(delay>SC_ZERO_TIME){
|
||||||
|
wait(delay);
|
||||||
|
delay=SC_ZERO_TIME;
|
||||||
|
}
|
||||||
|
const auto mask = 1U<<tag;
|
||||||
|
if(regs->r_iof_en&mask){
|
||||||
|
const auto idx = regs->r_iof_sel&mask?1:0;
|
||||||
|
if(iof_idx == idx){
|
||||||
|
auto& socket = pins_o[tag];
|
||||||
|
for(size_t i=0; i<socket.size(); ++i){
|
||||||
|
sc_core::sc_time delay{SC_ZERO_TIME};
|
||||||
|
tlm::tlm_phase phase{tlm::BEGIN_REQ};
|
||||||
|
tlm::tlm_signal_gp<> new_gp;
|
||||||
|
new_gp.set_command(tlm::TLM_WRITE_COMMAND);
|
||||||
|
auto val = gp.get_value();
|
||||||
|
new_gp.set_value(val);
|
||||||
|
new_gp.copy_extensions_from(gp);
|
||||||
|
socket->nb_transport_fw(new_gp, phase, delay); // we don't care about phase and sync enum
|
||||||
|
gp.update_extensions_from(new_gp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace sysc */
|
} /* namespace sysc */
|
||||||
|
|
||||||
|
|
|
@ -1,44 +1,84 @@
|
||||||
/*******************************************************************************
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
* Copyright 2017 eyck@minres.com
|
// Copyright (C) 2017, MINRES Technologies GmbH
|
||||||
*
|
// All rights reserved.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
//
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
// Redistribution and use in source and binary forms, with or without
|
||||||
* of the License at
|
// modification, are permitted provided that the following conditions are met:
|
||||||
*
|
//
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
// 1. Redistributions of source code must retain the above copyright notice,
|
||||||
*
|
// this list of conditions and the following disclaimer.
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
//
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
* License for the specific language governing permissions and limitations under
|
// and/or other materials provided with the distribution.
|
||||||
* the License.
|
//
|
||||||
******************************************************************************/
|
// 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// eyck@minres.com - initial implementation
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _GPIO_H_
|
#ifndef _GPIO_H_
|
||||||
#define _GPIO_H_
|
#define _GPIO_H_
|
||||||
|
|
||||||
#include <scc/tlm_target.h>
|
#include "scc/tlm_target.h"
|
||||||
|
#include "scc/signal_target_mixin.h"
|
||||||
|
#include "scc/signal_initiator_mixin.h"
|
||||||
#include <tlm/tlm_signal.h>
|
#include <tlm/tlm_signal.h>
|
||||||
|
|
||||||
namespace sysc {
|
namespace sysc {
|
||||||
|
|
||||||
class gpio_regs;
|
class gpio_regs;
|
||||||
|
class WsHandler;
|
||||||
|
|
||||||
class gpio : public sc_core::sc_module, public scc::tlm_target<> {
|
class gpio : public sc_core::sc_module, public scc::tlm_target<> {
|
||||||
public:
|
public:
|
||||||
SC_HAS_PROCESS(gpio);
|
SC_HAS_PROCESS(gpio);
|
||||||
sc_core::sc_in<sc_core::sc_time> clk_i;
|
sc_core::sc_in<sc_core::sc_time> clk_i;
|
||||||
sc_core::sc_in<bool> rst_i;
|
sc_core::sc_in<bool> rst_i;
|
||||||
sc_core::sc_vector<tlm::tlm_signal_initiator_socket<>> out;
|
// sc_core::sc_inout_rv<32> pins_io;
|
||||||
sc_core::sc_vector<tlm::tlm_signal_target_socket<>> in;
|
|
||||||
|
sc_core::sc_vector<scc::tlm_signal_bool_out> pins_o;
|
||||||
|
sc_core::sc_vector<scc::tlm_signal_bool_in> pins_i;
|
||||||
|
|
||||||
|
sc_core::sc_vector<scc::tlm_signal_bool_opt_out> iof0_o;
|
||||||
|
sc_core::sc_vector<scc::tlm_signal_bool_opt_out> iof1_o;
|
||||||
|
sc_core::sc_vector<scc::tlm_signal_bool_opt_in> iof0_i;
|
||||||
|
sc_core::sc_vector<scc::tlm_signal_bool_opt_in> iof1_i;
|
||||||
|
|
||||||
gpio(sc_core::sc_module_name nm);
|
gpio(sc_core::sc_module_name nm);
|
||||||
virtual ~gpio();
|
virtual ~gpio() override; // need to keep it in source file because of fwd declaration of gpio_regs
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void clock_cb();
|
void clock_cb();
|
||||||
void reset_cb();
|
void reset_cb();
|
||||||
|
void update_pins(uint32_t changed_bits);
|
||||||
|
void pin_input(unsigned int tag, tlm::tlm_signal_gp<>& gp, sc_core::sc_time& delay);
|
||||||
|
void forward_pin_input(unsigned int tag, tlm::tlm_signal_gp<>& gp);
|
||||||
|
void iof_input(unsigned int tag, unsigned iof_idx, tlm::tlm_signal_gp<>& gp, sc_core::sc_time& delay);
|
||||||
sc_core::sc_time clk;
|
sc_core::sc_time clk;
|
||||||
|
std::array<bool, 32> last_iof0, last_iof1;
|
||||||
std::unique_ptr<gpio_regs> regs;
|
std::unique_ptr<gpio_regs> regs;
|
||||||
|
std::shared_ptr<sysc::WsHandler> handler;
|
||||||
|
|
||||||
|
private:
|
||||||
|
tlm::tlm_phase write_output(tlm::tlm_signal_gp<>& gp, size_t i, bool val);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace sysc */
|
} /* namespace sysc */
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <scc/report.h>
|
#include <scc/report.h>
|
||||||
#include <scc/scv_tr_db.h>
|
#include <scc/scv_tr_db.h>
|
||||||
#include <scc/tracer.h>
|
#include <scc/tracer.h>
|
||||||
|
#include <util/logging.h>
|
||||||
|
|
||||||
using namespace sysc;
|
using namespace sysc;
|
||||||
using namespace scc;
|
using namespace scc;
|
||||||
|
@ -40,8 +41,9 @@ const size_t ERROR_UNHANDLED_EXCEPTION = 2;
|
||||||
int sc_main(int argc, char *argv[]) {
|
int sc_main(int argc, char *argv[]) {
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setup initial logging
|
// setup initial logging
|
||||||
///////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////// LOGGER(DEFAULT)::reporting_level() = l;
|
||||||
scc::Logger<>::reporting_level() = logging::INFO;
|
LOGGER(DEFAULT)::reporting_level() = logging::INFO;
|
||||||
|
LOGGER(SystemC)::reporting_level() = logging::INFO;
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// CLI argument parsing
|
// CLI argument parsing
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -67,11 +69,10 @@ int sc_main(int argc, char *argv[]) {
|
||||||
std::cerr << desc << std::endl;
|
std::cerr << desc << std::endl;
|
||||||
return ERROR_IN_COMMAND_LINE;
|
return ERROR_IN_COMMAND_LINE;
|
||||||
}
|
}
|
||||||
if (vm.count("debug")) {
|
///////////////////////////////////////////////////////////////////////////
|
||||||
LOGGER(DEFAULT)::reporting_level() = log::DEBUG;
|
// configure logging
|
||||||
LOGGER(SystemC)::reporting_level() = log::DEBUG;
|
///////////////////////////////////////////////////////////////////////////
|
||||||
scc::Logger<>::reporting_level() = log::DEBUG;
|
scc::init_logging(vm.count("debug")?logging::DEBUG:logging::INFO);
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// set up tracing & transaction recording
|
// set up tracing & transaction recording
|
||||||
|
@ -83,7 +84,6 @@ int sc_main(int argc, char *argv[]) {
|
||||||
// instantiate top level
|
// instantiate top level
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
simple_system i_simple_system("i_simple_system");
|
simple_system i_simple_system("i_simple_system");
|
||||||
// sr_report_handler::add_sc_object_to_filter(&i_simple_system.i_master, sc_core::SC_WARNING, sc_core::SC_MEDIUM);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// run simulation
|
// run simulation
|
||||||
|
@ -92,7 +92,7 @@ int sc_main(int argc, char *argv[]) {
|
||||||
// todo: provide end-of-simulation macros
|
// todo: provide end-of-simulation macros
|
||||||
|
|
||||||
if (!sc_core::sc_end_of_simulation_invoked()) {
|
if (!sc_core::sc_end_of_simulation_invoked()) {
|
||||||
LOG(ERROR) << "simulation timed out";
|
SCERR() << "simulation timed out";
|
||||||
sc_core::sc_stop();
|
sc_core::sc_stop();
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
|
|
@ -35,7 +35,9 @@ simple_system::simple_system(sc_core::sc_module_name nm)
|
||||||
, NAMED(s_clk)
|
, NAMED(s_clk)
|
||||||
, NAMED(s_rst)
|
, NAMED(s_rst)
|
||||||
, NAMED(s_global_interrupts, 256)
|
, NAMED(s_global_interrupts, 256)
|
||||||
, NAMED(s_core_interrupt) {
|
, NAMED(s_core_interrupt)
|
||||||
|
, NAMED(s_gpio, 32)
|
||||||
|
{
|
||||||
// todo: discuss naming conventions (s_<signal> vs. <port>_i/_o) --> covnert into _s
|
// todo: discuss naming conventions (s_<signal> vs. <port>_i/_o) --> covnert into _s
|
||||||
|
|
||||||
// bus connections
|
// bus connections
|
||||||
|
@ -66,7 +68,11 @@ simple_system::simple_system(sc_core::sc_module_name nm)
|
||||||
i_master.global_interrupts_o(s_global_interrupts);
|
i_master.global_interrupts_o(s_global_interrupts);
|
||||||
i_master.core_interrupt_i(s_core_interrupt);
|
i_master.core_interrupt_i(s_core_interrupt);
|
||||||
|
|
||||||
i_gpio.in(i_gpio.out);
|
for(auto i=0U; i<s_gpio.size(); ++i){
|
||||||
|
s_gpio[i].in(i_gpio.pins_o[i]);
|
||||||
|
i_gpio.pins_i[i](s_gpio[i].out);
|
||||||
|
}
|
||||||
|
|
||||||
SC_THREAD(gen_reset);
|
SC_THREAD(gen_reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
sc_core::sc_signal<bool> s_rst;
|
sc_core::sc_signal<bool> s_rst;
|
||||||
sc_core::sc_vector<sc_core::sc_signal<bool>> s_global_interrupts;
|
sc_core::sc_vector<sc_core::sc_signal<bool>> s_global_interrupts;
|
||||||
sc_core::sc_signal<bool> s_core_interrupt;
|
sc_core::sc_signal<bool> s_core_interrupt;
|
||||||
|
sc_core::sc_vector<tlm::tlm_signal<>> s_gpio;
|
||||||
|
|
||||||
simple_system(sc_core::sc_module_name nm);
|
simple_system(sc_core::sc_module_name nm);
|
||||||
|
|
||||||
|
|
|
@ -11,5 +11,6 @@ target_link_libraries (transaction_recording LINK_PUBLIC sc-components)
|
||||||
target_link_libraries (transaction_recording LINK_PUBLIC ${SystemC_LIBRARIES})
|
target_link_libraries (transaction_recording LINK_PUBLIC ${SystemC_LIBRARIES})
|
||||||
target_link_libraries (transaction_recording LINK_PUBLIC ${SCV_LIBRARIES})
|
target_link_libraries (transaction_recording LINK_PUBLIC ${SCV_LIBRARIES})
|
||||||
target_link_libraries (transaction_recording LINK_PUBLIC ${Boost_LIBRARIES} )
|
target_link_libraries (transaction_recording LINK_PUBLIC ${Boost_LIBRARIES} )
|
||||||
|
target_link_libraries (transaction_recording LINK_PUBLIC ${ZLIB_LIBRARIES} )
|
||||||
target_link_libraries (transaction_recording LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries (transaction_recording LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_link_libraries (transaction_recording LINK_PUBLIC ${CMAKE_DL_LIBS})
|
target_link_libraries (transaction_recording LINK_PUBLIC ${CMAKE_DL_LIBS})
|
||||||
|
|
|
@ -16,6 +16,14 @@
|
||||||
|
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#include "scv.h"
|
#include "scv.h"
|
||||||
|
#include "scc/scv_tr_db.h"
|
||||||
|
#include "scc/report.h"
|
||||||
|
|
||||||
|
//47ms #define SQLITE_DB
|
||||||
|
//27ms
|
||||||
|
#define CTXT_DB
|
||||||
|
//29ms #define BINARY_DB
|
||||||
|
//27ms TEXT_DB
|
||||||
|
|
||||||
// hack to fake a true fifo_mutex
|
// hack to fake a true fifo_mutex
|
||||||
#define fifo_mutex sc_mutex
|
#define fifo_mutex sc_mutex
|
||||||
|
@ -189,8 +197,7 @@ inline void test::main1() {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
rw_task_if::addr_t addr = i;
|
rw_task_if::addr_t addr = i;
|
||||||
rw_task_if::data_t data = transactor->read(&addr);
|
rw_task_if::data_t data = transactor->read(&addr);
|
||||||
cout << "at time " << sc_time_stamp() << ": ";
|
SCINFO(sc_get_current_object()->name()) << "received data : " << data;
|
||||||
cout << "received data : " << data << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scv_smart_ptr<rw_task_if::addr_t> addr;
|
scv_smart_ptr<rw_task_if::addr_t> addr;
|
||||||
|
@ -198,14 +205,14 @@ inline void test::main1() {
|
||||||
|
|
||||||
addr->next();
|
addr->next();
|
||||||
rw_task_if::data_t data = transactor->read(addr->get_instance());
|
rw_task_if::data_t data = transactor->read(addr->get_instance());
|
||||||
cout << "data for address " << *addr << " is " << data << endl;
|
SCINFO(sc_get_current_object()->name()) << "data for address " << *addr << " is " << data;
|
||||||
}
|
}
|
||||||
|
|
||||||
scv_smart_ptr<rw_task_if::write_t> write;
|
scv_smart_ptr<rw_task_if::write_t> write;
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
write->next();
|
write->next();
|
||||||
transactor->write(write->get_instance());
|
transactor->write(write->get_instance());
|
||||||
cout << "send data : " << write->data << endl;
|
SCINFO(sc_get_current_object()->name()) << "send data : " << write->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
scv_smart_ptr<int> data;
|
scv_smart_ptr<int> data;
|
||||||
|
@ -224,8 +231,7 @@ inline void test::main2() {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
rw_task_if::addr_t addr = i;
|
rw_task_if::addr_t addr = i;
|
||||||
rw_task_if::data_t data = transactor->read(&addr);
|
rw_task_if::data_t data = transactor->read(&addr);
|
||||||
cout << "at time " << sc_time_stamp() << ": ";
|
SCINFO(sc_get_current_object()->name()) << "received data : " << data;
|
||||||
cout << "received data : " << data << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scv_smart_ptr<rw_task_if::addr_t> addr;
|
scv_smart_ptr<rw_task_if::addr_t> addr;
|
||||||
|
@ -233,14 +239,14 @@ inline void test::main2() {
|
||||||
|
|
||||||
addr->next();
|
addr->next();
|
||||||
rw_task_if::data_t data = transactor->read(addr->get_instance());
|
rw_task_if::data_t data = transactor->read(addr->get_instance());
|
||||||
cout << "data for address " << *addr << " is " << data << endl;
|
SCINFO(sc_get_current_object()->name()) << "data for address " << *addr << " is " << data;
|
||||||
}
|
}
|
||||||
|
|
||||||
scv_smart_ptr<rw_task_if::write_t> write;
|
scv_smart_ptr<rw_task_if::write_t> write;
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
write->next();
|
write->next();
|
||||||
transactor->write(write->get_instance());
|
transactor->write(write->get_instance());
|
||||||
cout << "send data : " << write->data << endl;
|
SCINFO(sc_get_current_object()->name()) << "send data : " << write->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
scv_smart_ptr<int> data;
|
scv_smart_ptr<int> data;
|
||||||
|
@ -291,8 +297,7 @@ inline void design::addr_phase() {
|
||||||
|
|
||||||
outstandingAddresses.push_back(_addr);
|
outstandingAddresses.push_back(_addr);
|
||||||
outstandingType.push_back(_rw);
|
outstandingType.push_back(_rw);
|
||||||
cout << "at time " << sc_time_stamp() << ": ";
|
SCINFO(sc_get_current_object()->name()) << "received request for memory address " << _addr;
|
||||||
cout << "received request for memory address " << _addr << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,15 +311,15 @@ inline void design::data_phase() {
|
||||||
wait(clk->posedge_event());
|
wait(clk->posedge_event());
|
||||||
}
|
}
|
||||||
if (outstandingType.front() == false) {
|
if (outstandingType.front() == false) {
|
||||||
cout << "reading memory address " << outstandingAddresses.front() << " with value "
|
SCINFO(sc_get_current_object()->name()) << "reading memory address " << outstandingAddresses.front() << " with value "
|
||||||
<< memory[outstandingAddresses.front().to_ulong()] << endl;
|
<< memory[outstandingAddresses.front().to_ulong()];
|
||||||
bus_data = memory[outstandingAddresses.front().to_ulong()];
|
bus_data = memory[outstandingAddresses.front().to_ulong()];
|
||||||
data_rdy = 1;
|
data_rdy = 1;
|
||||||
wait(clk->posedge_event());
|
wait(clk->posedge_event());
|
||||||
data_rdy = 0;
|
data_rdy = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cout << "writing memory address " << outstandingAddresses.front() << " with value " << bus_data << endl;
|
SCINFO(sc_get_current_object()->name()) << "writing memory address " << outstandingAddresses.front() << " with value " << bus_data;
|
||||||
memory[outstandingAddresses.front().to_ulong()] = bus_data;
|
memory[outstandingAddresses.front().to_ulong()] = bus_data;
|
||||||
data_rdy = 1;
|
data_rdy = 1;
|
||||||
wait(clk->posedge_event());
|
wait(clk->posedge_event());
|
||||||
|
@ -324,17 +329,25 @@ inline void design::data_phase() {
|
||||||
outstandingType.pop_front();
|
outstandingType.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extern void scv_tr_binary_init();
|
|
||||||
|
|
||||||
int sc_main(int argc, char *argv[]) {
|
int sc_main(int argc, char *argv[]) {
|
||||||
|
auto start = std::chrono::system_clock::now();
|
||||||
scv_startup();
|
scv_startup();
|
||||||
|
scc::init_logging(logging::INFO);
|
||||||
|
LOGGER(SystemC)::print_time() = false;
|
||||||
|
|
||||||
#if 0
|
#if defined(BINARY_DB)
|
||||||
scv_tr_text_init();
|
|
||||||
const char* fileName = "my_db.txlog";
|
|
||||||
#else
|
|
||||||
scv_tr_binary_init();
|
scv_tr_binary_init();
|
||||||
const char *fileName = "my_db";
|
const char *fileName = "my_db";
|
||||||
|
#elif defined(CTXT_DB)
|
||||||
|
scv_tr_compressed_init();
|
||||||
|
const char* fileName = "my_db.txlog";
|
||||||
|
#elif defined(SQLITE_DB)
|
||||||
|
scv_tr_sqlite_init();
|
||||||
|
const char* fileName = "my_db.txdb";
|
||||||
|
#else
|
||||||
|
scv_tr_text_init();
|
||||||
|
const char* fileName = "my_db.txlog";
|
||||||
#endif
|
#endif
|
||||||
scv_tr_db db(fileName);
|
scv_tr_db db(fileName);
|
||||||
scv_tr_db::set_default_db(&db);
|
scv_tr_db::set_default_db(&db);
|
||||||
|
@ -378,7 +391,9 @@ int sc_main(int argc, char *argv[]) {
|
||||||
// Disable check for bus simulation.
|
// Disable check for bus simulation.
|
||||||
sc_report_handler::set_actions(SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, SC_DO_NOTHING);
|
sc_report_handler::set_actions(SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, SC_DO_NOTHING);
|
||||||
// run the simulation
|
// run the simulation
|
||||||
sc_start(1.0, SC_MS);
|
sc_start(10.0, SC_US);
|
||||||
sc_close_vcd_trace_file(tf);
|
sc_close_vcd_trace_file(tf);
|
||||||
|
auto int_us = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now()-start);
|
||||||
|
SCINFO() << "simulation duration "<<int_us.count()<<"µs";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3bf292cae272e0cbe3ed84a25a843948a85e2ca1
|
Subproject commit 2e111d4bc47b1ef34d11fa813ce1fe094cd5c4c1
|
Loading…
Reference in New Issue