2017-09-21 13:13:01 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright 2017 eyck@minres.com
|
2017-09-22 11:23:23 +02:00
|
|
|
//
|
2017-09-21 13:13:01 +02:00
|
|
|
// 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
|
|
|
|
// of the License at
|
2017-09-22 11:23:23 +02:00
|
|
|
//
|
2017-09-21 13:13:01 +02:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2017-09-22 11:23:23 +02:00
|
|
|
//
|
2017-09-21 13:13:01 +02:00
|
|
|
// 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.
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/*
|
|
|
|
* simplesystem.cpp
|
|
|
|
*
|
|
|
|
* Created on: 17.09.2017
|
|
|
|
* Author: eyck@minres.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sysc/SiFive/platform.h>
|
|
|
|
|
|
|
|
namespace sysc {
|
|
|
|
|
|
|
|
platform::platform(sc_core::sc_module_name nm)
|
2017-09-26 17:10:10 +02:00
|
|
|
: sc_core::sc_module(nm)
|
2017-10-04 10:31:11 +02:00
|
|
|
, NAMED(i_core_complex)
|
2017-11-10 22:40:24 +01:00
|
|
|
, NAMED(i_router, 12, 1)
|
2017-10-04 10:31:11 +02:00
|
|
|
, NAMED(i_uart0)
|
|
|
|
, NAMED(i_uart1)
|
2017-11-10 22:40:24 +01:00
|
|
|
, NAMED(i_qspi0)
|
|
|
|
, NAMED(i_qspi1)
|
|
|
|
, NAMED(i_qspi2)
|
|
|
|
, NAMED(i_gpio0)
|
2017-09-26 17:10:10 +02:00
|
|
|
, NAMED(i_plic)
|
2017-10-04 10:31:11 +02:00
|
|
|
, NAMED(i_aon)
|
|
|
|
, NAMED(i_prci)
|
|
|
|
, NAMED(i_clint)
|
|
|
|
, NAMED(i_mem_qspi)
|
|
|
|
, NAMED(i_mem_ram)
|
2017-09-26 17:10:10 +02:00
|
|
|
, NAMED(s_clk)
|
2017-10-04 23:15:04 +02:00
|
|
|
, NAMED(s_rst)
|
|
|
|
, NAMED(s_global_int, 256)
|
2017-11-10 22:40:24 +01:00
|
|
|
, NAMED(s_local_int, 16)
|
|
|
|
, NAMED(s_core_int)
|
|
|
|
, NAMED(s_gpio_pins) {
|
2017-10-04 10:31:11 +02:00
|
|
|
i_core_complex.initiator(i_router.target[0]);
|
2017-09-22 11:23:23 +02:00
|
|
|
size_t i = 0;
|
|
|
|
for (const auto &e : e300_plat_map) {
|
2017-09-21 13:13:01 +02:00
|
|
|
i_router.initiator.at(i)(e.target->socket);
|
|
|
|
i_router.add_target_range(i, e.start, e.size);
|
|
|
|
i++;
|
|
|
|
}
|
2017-10-04 10:31:11 +02:00
|
|
|
i_router.initiator.at(i)(i_mem_qspi.target);
|
|
|
|
i_router.add_target_range(i, 0x20000000, 512_MB);
|
|
|
|
i_router.initiator.at(++i)(i_mem_ram.target);
|
|
|
|
i_router.add_target_range(i, 0x80000000, 128_kB);
|
|
|
|
|
|
|
|
i_uart0.clk_i(s_clk);
|
|
|
|
i_uart1.clk_i(s_clk);
|
2017-11-10 22:40:24 +01:00
|
|
|
i_qspi0.clk_i(s_clk);
|
|
|
|
i_qspi1.clk_i(s_clk);
|
|
|
|
i_qspi2.clk_i(s_clk);
|
|
|
|
i_gpio0.clk_i(s_clk);
|
2017-09-21 13:13:01 +02:00
|
|
|
i_plic.clk_i(s_clk);
|
2017-10-04 10:31:11 +02:00
|
|
|
i_aon.clk_i(s_clk);
|
|
|
|
i_prci.clk_i(s_clk);
|
|
|
|
i_clint.clk_i(s_clk);
|
|
|
|
i_core_complex.clk_i(s_clk);
|
2017-09-21 13:13:01 +02:00
|
|
|
|
2017-10-04 10:31:11 +02:00
|
|
|
i_uart0.rst_i(s_rst);
|
|
|
|
i_uart1.rst_i(s_rst);
|
2017-11-10 22:40:24 +01:00
|
|
|
i_qspi0.rst_i(s_rst);
|
|
|
|
i_qspi1.rst_i(s_rst);
|
|
|
|
i_qspi2.rst_i(s_rst);
|
|
|
|
i_gpio0.rst_i(s_rst);
|
2017-09-21 13:13:01 +02:00
|
|
|
i_plic.rst_i(s_rst);
|
2017-10-04 10:31:11 +02:00
|
|
|
i_aon.rst_i(s_rst);
|
|
|
|
i_prci.rst_i(s_rst);
|
|
|
|
i_clint.rst_i(s_rst);
|
|
|
|
i_core_complex.rst_i(s_rst);
|
|
|
|
|
|
|
|
i_clint.mtime_int_o(s_mtime_int);
|
|
|
|
i_clint.msip_int_o(s_msie_int);
|
2017-09-21 13:13:01 +02:00
|
|
|
|
2017-10-04 23:15:04 +02:00
|
|
|
i_plic.global_interrupts_i(s_global_int);
|
|
|
|
i_plic.core_interrupt_o(s_core_int);
|
2017-11-10 22:40:24 +01:00
|
|
|
|
|
|
|
i_core_complex.sw_irq_i(s_msie_int);
|
|
|
|
i_core_complex.timer_irq_i(s_mtime_int);
|
|
|
|
i_core_complex.global_irq_i(s_core_int);
|
|
|
|
i_core_complex.local_irq_i(s_local_int);
|
|
|
|
|
|
|
|
i_gpio0.pins_io(s_gpio_pins);
|
|
|
|
|
2017-09-21 13:13:01 +02:00
|
|
|
SC_THREAD(gen_reset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void platform::gen_reset() {
|
2017-10-04 10:31:11 +02:00
|
|
|
s_clk = 10_ns;
|
2017-09-22 11:23:23 +02:00
|
|
|
s_rst = true;
|
2017-09-21 13:13:01 +02:00
|
|
|
wait(10_ns);
|
2017-09-22 11:23:23 +02:00
|
|
|
s_rst = false;
|
2017-09-21 13:13:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace sysc */
|