Added ADC, H-Bridge and motor models, refactored project structure
This commit is contained in:
		
							
								
								
									
										67
									
								
								platform/incl/sysc/SiFive/aon.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								platform/incl/sysc/SiFive/aon.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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 | ||||
| // | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _AON_H_ | ||||
| #define _AON_H_ | ||||
|  | ||||
| #include "scc/tlm_target.h" | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class aon_regs; | ||||
|  | ||||
| class aon : public sc_core::sc_module, public scc::tlm_target<> { | ||||
| public: | ||||
|     SC_HAS_PROCESS(aon); | ||||
|     sc_core::sc_in<sc_core::sc_time> clk_i; | ||||
|     sc_core::sc_in<bool> erst_n_i; | ||||
|     sc_core::sc_out<sc_core::sc_time> lfclkc_o; | ||||
|     sc_core::sc_out<bool> rst_o; | ||||
|     aon(sc_core::sc_module_name nm); | ||||
|     virtual ~aon() override; // need to keep it in source file because of fwd declaration of aon_regs | ||||
|  | ||||
| protected: | ||||
|     void start_of_simulation() override; | ||||
|     void clock_cb(); | ||||
|     void reset_cb(); | ||||
|     void reset_internal_cb(); | ||||
|     sc_core::sc_time clk; | ||||
|     std::unique_ptr<aon_regs> regs; | ||||
| }; | ||||
|  | ||||
| } /* namespace sysc */ | ||||
|  | ||||
| #endif /* _GPIO_H_ */ | ||||
							
								
								
									
										78
									
								
								platform/incl/sysc/SiFive/clint.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								platform/incl/sysc/SiFive/clint.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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 | ||||
| // | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _CLINT_H_ | ||||
| #define _CLINT_H_ | ||||
|  | ||||
| #include "scc/tlm_target.h" | ||||
|  | ||||
| namespace iss { | ||||
| namespace arch { | ||||
| template <typename BASE> class riscv_hart_msu_vp; | ||||
| } | ||||
| } | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class clint_regs; | ||||
| namespace SiFive { | ||||
| class core_complex; | ||||
| } | ||||
|  | ||||
| class clint : public sc_core::sc_module, public scc::tlm_target<> { | ||||
| public: | ||||
|     SC_HAS_PROCESS(clint); | ||||
|     sc_core::sc_in<sc_core::sc_time> tlclk_i; | ||||
|     sc_core::sc_in<sc_core::sc_time> lfclk_i; | ||||
|     sc_core::sc_in<bool> rst_i; | ||||
|     sc_core::sc_out<bool> mtime_int_o; | ||||
|     sc_core::sc_out<bool> msip_int_o; | ||||
|     clint(sc_core::sc_module_name nm); | ||||
|     virtual ~clint() override; // need to keep it in source file because of fwd declaration of clint_regs | ||||
|  | ||||
| protected: | ||||
|     void clock_cb(); | ||||
|     void reset_cb(); | ||||
|     void update_mtime(); | ||||
|     sc_core::sc_time clk, last_updt; | ||||
|     unsigned cnt_fraction; | ||||
|     std::unique_ptr<clint_regs> regs; | ||||
|     sc_core::sc_event mtime_evt; | ||||
| }; | ||||
|  | ||||
| } /* namespace sysc */ | ||||
|  | ||||
| #endif /* _CLINT_H_ */ | ||||
							
								
								
									
										180
									
								
								platform/incl/sysc/SiFive/gen/aon_regs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										180
									
								
								platform/incl/sysc/SiFive/gen/aon_regs.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,180 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // Created on: Fri Nov 10 18:01:53 CET 2017 | ||||
| //             *      aon_regs.h Author: <RDL Generator> | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _AON_REGS_H_ | ||||
| #define _AON_REGS_H_ | ||||
|  | ||||
| #include <scc/utilities.h> | ||||
| #include <util/bit_field.h> | ||||
| #include <scc/register.h> | ||||
| #include <scc/tlm_target.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class aon_regs : | ||||
|         public sc_core::sc_module, | ||||
|         public scc::resetable | ||||
| { | ||||
| public: | ||||
|     // storage declarations | ||||
|     uint32_t r_wdogcfg; | ||||
|      | ||||
|     uint32_t r_wdogcount; | ||||
|      | ||||
|     uint32_t r_wdogs; | ||||
|      | ||||
|     uint32_t r_wdogfeed; | ||||
|      | ||||
|     uint32_t r_wdogkey; | ||||
|      | ||||
|     uint32_t r_wdogcmp; | ||||
|      | ||||
|     uint32_t r_rtccfg; | ||||
|      | ||||
|     uint32_t r_rtclo; | ||||
|      | ||||
|     uint32_t r_rtchi; | ||||
|      | ||||
|     uint32_t r_rtcs; | ||||
|      | ||||
|     uint32_t r_rtccmp; | ||||
|      | ||||
|     uint32_t r_lfrosccfg; | ||||
|      | ||||
|     std::array<uint32_t, 32> r_backup; | ||||
|      | ||||
|     BEGIN_BF_DECL(pmuwakeupi_t, uint32_t); | ||||
|         BF_FIELD(delay, 0, 4); | ||||
|         BF_FIELD(vddpaden, 5, 1); | ||||
|         BF_FIELD(corerst, 7, 1); | ||||
|         BF_FIELD(hfclkrst, 8, 1); | ||||
|     END_BF_DECL() ; | ||||
|     std::array<pmuwakeupi_t, 8> r_pmuwakeupi; | ||||
|      | ||||
|     BEGIN_BF_DECL(pmusleepi_t, uint32_t); | ||||
|         BF_FIELD(delay, 0, 4); | ||||
|         BF_FIELD(vddpaden, 5, 1); | ||||
|         BF_FIELD(corerst, 7, 1); | ||||
|         BF_FIELD(hfclkrst, 8, 1); | ||||
|     END_BF_DECL() ; | ||||
|     std::array<pmusleepi_t, 8> r_pmusleepi; | ||||
|      | ||||
|     uint32_t r_pmuie; | ||||
|      | ||||
|     uint32_t r_pmucause; | ||||
|      | ||||
|     uint32_t r_pmusleep; | ||||
|      | ||||
|     uint32_t r_pmukey; | ||||
|      | ||||
|     // register declarations | ||||
|     scc::sc_register<uint32_t> wdogcfg; | ||||
|     scc::sc_register<uint32_t> wdogcount; | ||||
|     scc::sc_register<uint32_t> wdogs; | ||||
|     scc::sc_register<uint32_t> wdogfeed; | ||||
|     scc::sc_register<uint32_t> wdogkey; | ||||
|     scc::sc_register<uint32_t> wdogcmp; | ||||
|     scc::sc_register<uint32_t> rtccfg; | ||||
|     scc::sc_register<uint32_t> rtclo; | ||||
|     scc::sc_register<uint32_t> rtchi; | ||||
|     scc::sc_register<uint32_t> rtcs; | ||||
|     scc::sc_register<uint32_t> rtccmp; | ||||
|     scc::sc_register<uint32_t> lfrosccfg; | ||||
|     scc::sc_register_indexed<uint32_t, 32> backup; | ||||
|     scc::sc_register_indexed<pmuwakeupi_t, 8> pmuwakeupi; | ||||
|     scc::sc_register_indexed<pmusleepi_t, 8> pmusleepi; | ||||
|     scc::sc_register<uint32_t> pmuie; | ||||
|     scc::sc_register<uint32_t> pmucause; | ||||
|     scc::sc_register<uint32_t> pmusleep; | ||||
|     scc::sc_register<uint32_t> pmukey; | ||||
|      | ||||
|     aon_regs(sc_core::sc_module_name nm); | ||||
|  | ||||
|     template<unsigned BUSWIDTH=32> | ||||
|     void registerResources(scc::tlm_target<BUSWIDTH>& target); | ||||
| }; | ||||
| } | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
| // member functions | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| inline sysc::aon_regs::aon_regs(sc_core::sc_module_name nm) | ||||
| : sc_core::sc_module(nm) | ||||
| , NAMED(wdogcfg, r_wdogcfg, 0, *this) | ||||
| , NAMED(wdogcount, r_wdogcount, 0, *this) | ||||
| , NAMED(wdogs, r_wdogs, 0, *this) | ||||
| , NAMED(wdogfeed, r_wdogfeed, 0, *this) | ||||
| , NAMED(wdogkey, r_wdogkey, 0, *this) | ||||
| , NAMED(wdogcmp, r_wdogcmp, 0, *this) | ||||
| , NAMED(rtccfg, r_rtccfg, 0, *this) | ||||
| , NAMED(rtclo, r_rtclo, 0, *this) | ||||
| , NAMED(rtchi, r_rtchi, 0, *this) | ||||
| , NAMED(rtcs, r_rtcs, 0, *this) | ||||
| , NAMED(rtccmp, r_rtccmp, 0, *this) | ||||
| , NAMED(lfrosccfg, r_lfrosccfg, 0, *this) | ||||
| , NAMED(backup, r_backup, 0, *this) | ||||
| , NAMED(pmuwakeupi, r_pmuwakeupi, 0, *this) | ||||
| , NAMED(pmusleepi, r_pmusleepi, 0, *this) | ||||
| , NAMED(pmuie, r_pmuie, 0, *this) | ||||
| , NAMED(pmucause, r_pmucause, 0, *this) | ||||
| , NAMED(pmusleep, r_pmusleep, 0, *this) | ||||
| , NAMED(pmukey, r_pmukey, 0, *this) | ||||
| { | ||||
| } | ||||
|  | ||||
| template<unsigned BUSWIDTH> | ||||
| inline void sysc::aon_regs::registerResources(scc::tlm_target<BUSWIDTH>& target) { | ||||
|     target.addResource(wdogcfg, 0x0UL); | ||||
|     target.addResource(wdogcount, 0x8UL); | ||||
|     target.addResource(wdogs, 0x10UL); | ||||
|     target.addResource(wdogfeed, 0x18UL); | ||||
|     target.addResource(wdogkey, 0x1cUL); | ||||
|     target.addResource(wdogcmp, 0x20UL); | ||||
|     target.addResource(rtccfg, 0x40UL); | ||||
|     target.addResource(rtclo, 0x48UL); | ||||
|     target.addResource(rtchi, 0x4cUL); | ||||
|     target.addResource(rtcs, 0x50UL); | ||||
|     target.addResource(rtccmp, 0x60UL); | ||||
|     target.addResource(lfrosccfg, 0x70UL); | ||||
|     target.addResource(backup, 0x80UL); | ||||
|     target.addResource(pmuwakeupi, 0x100UL); | ||||
|     target.addResource(pmusleepi, 0x120UL); | ||||
|     target.addResource(pmuie, 0x140UL); | ||||
|     target.addResource(pmucause, 0x144UL); | ||||
|     target.addResource(pmusleep, 0x148UL); | ||||
|     target.addResource(pmukey, 0x14cUL); | ||||
| } | ||||
|  | ||||
| #endif // _AON_REGS_H_ | ||||
							
								
								
									
										90
									
								
								platform/incl/sysc/SiFive/gen/clint_regs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								platform/incl/sysc/SiFive/gen/clint_regs.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,90 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // Created on: Fri Nov 10 18:01:53 CET 2017 | ||||
| //             *      clint_regs.h Author: <RDL Generator> | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _CLINT_REGS_H_ | ||||
| #define _CLINT_REGS_H_ | ||||
|  | ||||
| #include <scc/utilities.h> | ||||
| #include <util/bit_field.h> | ||||
| #include <scc/register.h> | ||||
| #include <scc/tlm_target.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class clint_regs : | ||||
|         public sc_core::sc_module, | ||||
|         public scc::resetable | ||||
| { | ||||
| public: | ||||
|     // storage declarations | ||||
|     BEGIN_BF_DECL(msip_t, uint32_t); | ||||
|         BF_FIELD(msip, 0, 1); | ||||
|     END_BF_DECL() r_msip; | ||||
|      | ||||
|     uint64_t r_mtimecmp; | ||||
|      | ||||
|     uint64_t r_mtime; | ||||
|      | ||||
|     // register declarations | ||||
|     scc::sc_register<msip_t> msip; | ||||
|     scc::sc_register<uint64_t> mtimecmp; | ||||
|     scc::sc_register<uint64_t> mtime; | ||||
|      | ||||
|     clint_regs(sc_core::sc_module_name nm); | ||||
|  | ||||
|     template<unsigned BUSWIDTH=32> | ||||
|     void registerResources(scc::tlm_target<BUSWIDTH>& target); | ||||
| }; | ||||
| } | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
| // member functions | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| inline sysc::clint_regs::clint_regs(sc_core::sc_module_name nm) | ||||
| : sc_core::sc_module(nm) | ||||
| , NAMED(msip, r_msip, 0, *this) | ||||
| , NAMED(mtimecmp, r_mtimecmp, 0, *this) | ||||
| , NAMED(mtime, r_mtime, 0, *this) | ||||
| { | ||||
| } | ||||
|  | ||||
| template<unsigned BUSWIDTH> | ||||
| inline void sysc::clint_regs::registerResources(scc::tlm_target<BUSWIDTH>& target) { | ||||
|     target.addResource(msip, 0x0UL); | ||||
|     target.addResource(mtimecmp, 0x4000UL); | ||||
|     target.addResource(mtime, 0xbff8UL); | ||||
| } | ||||
|  | ||||
| #endif // _CLINT_REGS_H_ | ||||
							
								
								
									
										17
									
								
								platform/incl/sysc/SiFive/gen/e300_plat_t.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								platform/incl/sysc/SiFive/gen/e300_plat_t.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| #ifndef _E300_PLAT_MAP_H_ | ||||
| #define _E300_PLAT_MAP_H_ | ||||
| // need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191 | ||||
| const std::array<scc::target_memory_map_entry<32>, 10> e300_plat_map = {{ | ||||
|     {&i_clint, 0x2000000, 0xc000}, | ||||
|     {&i_plic, 0xc000000, 0x200008}, | ||||
|     {&i_aon, 0x10000000, 0x150}, | ||||
|     {&i_prci, 0x10008000, 0x14}, | ||||
|     {&i_gpio0, 0x10012000, 0x44}, | ||||
|     {&i_uart0, 0x10013000, 0x1c}, | ||||
|     {&i_qspi0, 0x10014000, 0x78}, | ||||
|     {&i_uart1, 0x10023000, 0x1c}, | ||||
|     {&i_qspi1, 0x10024000, 0x78}, | ||||
|     {&i_qspi2, 0x10034000, 0x78}, | ||||
| }}; | ||||
|  | ||||
| #endif /* _E300_PLAT_MAP_H_ */ | ||||
							
								
								
									
										158
									
								
								platform/incl/sysc/SiFive/gen/gpio_regs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										158
									
								
								platform/incl/sysc/SiFive/gen/gpio_regs.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,158 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // Created on: Fri Nov 10 18:01:53 CET 2017 | ||||
| //             *      gpio_regs.h Author: <RDL Generator> | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _GPIO_REGS_H_ | ||||
| #define _GPIO_REGS_H_ | ||||
|  | ||||
| #include <scc/utilities.h> | ||||
| #include <util/bit_field.h> | ||||
| #include <scc/register.h> | ||||
| #include <scc/tlm_target.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class gpio_regs : | ||||
|         public sc_core::sc_module, | ||||
|         public scc::resetable | ||||
| { | ||||
| public: | ||||
|     // storage declarations | ||||
|     uint32_t r_value; | ||||
|      | ||||
|     uint32_t r_input_en; | ||||
|      | ||||
|     uint32_t r_output_en; | ||||
|      | ||||
|     uint32_t r_port; | ||||
|      | ||||
|     uint32_t r_pue; | ||||
|      | ||||
|     uint32_t r_ds; | ||||
|      | ||||
|     uint32_t r_rise_ie; | ||||
|      | ||||
|     uint32_t r_rise_ip; | ||||
|      | ||||
|     uint32_t r_fall_ie; | ||||
|      | ||||
|     uint32_t r_fall_ip; | ||||
|      | ||||
|     uint32_t r_high_ie; | ||||
|      | ||||
|     uint32_t r_high_ip; | ||||
|      | ||||
|     uint32_t r_low_ie; | ||||
|      | ||||
|     uint32_t r_low_ip; | ||||
|      | ||||
|     uint32_t r_iof_en; | ||||
|      | ||||
|     uint32_t r_iof_sel; | ||||
|      | ||||
|     uint32_t r_out_xor; | ||||
|      | ||||
|     // register declarations | ||||
|     scc::sc_register<uint32_t> value; | ||||
|     scc::sc_register<uint32_t> input_en; | ||||
|     scc::sc_register<uint32_t> output_en; | ||||
|     scc::sc_register<uint32_t> port; | ||||
|     scc::sc_register<uint32_t> pue; | ||||
|     scc::sc_register<uint32_t> ds; | ||||
|     scc::sc_register<uint32_t> rise_ie; | ||||
|     scc::sc_register<uint32_t> rise_ip; | ||||
|     scc::sc_register<uint32_t> fall_ie; | ||||
|     scc::sc_register<uint32_t> fall_ip; | ||||
|     scc::sc_register<uint32_t> high_ie; | ||||
|     scc::sc_register<uint32_t> high_ip; | ||||
|     scc::sc_register<uint32_t> low_ie; | ||||
|     scc::sc_register<uint32_t> low_ip; | ||||
|     scc::sc_register<uint32_t> iof_en; | ||||
|     scc::sc_register<uint32_t> iof_sel; | ||||
|     scc::sc_register<uint32_t> out_xor; | ||||
|      | ||||
|     gpio_regs(sc_core::sc_module_name nm); | ||||
|  | ||||
|     template<unsigned BUSWIDTH=32> | ||||
|     void registerResources(scc::tlm_target<BUSWIDTH>& target); | ||||
| }; | ||||
| } | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
| // member functions | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| inline sysc::gpio_regs::gpio_regs(sc_core::sc_module_name nm) | ||||
| : sc_core::sc_module(nm) | ||||
| , NAMED(value, r_value, 0, *this) | ||||
| , NAMED(input_en, r_input_en, 0, *this) | ||||
| , NAMED(output_en, r_output_en, 0, *this) | ||||
| , NAMED(port, r_port, 0, *this) | ||||
| , NAMED(pue, r_pue, 0, *this) | ||||
| , NAMED(ds, r_ds, 0, *this) | ||||
| , NAMED(rise_ie, r_rise_ie, 0, *this) | ||||
| , NAMED(rise_ip, r_rise_ip, 0, *this) | ||||
| , NAMED(fall_ie, r_fall_ie, 0, *this) | ||||
| , NAMED(fall_ip, r_fall_ip, 0, *this) | ||||
| , NAMED(high_ie, r_high_ie, 0, *this) | ||||
| , NAMED(high_ip, r_high_ip, 0, *this) | ||||
| , NAMED(low_ie, r_low_ie, 0, *this) | ||||
| , NAMED(low_ip, r_low_ip, 0, *this) | ||||
| , NAMED(iof_en, r_iof_en, 0, *this) | ||||
| , NAMED(iof_sel, r_iof_sel, 0, *this) | ||||
| , NAMED(out_xor, r_out_xor, 0, *this) | ||||
| { | ||||
| } | ||||
|  | ||||
| template<unsigned BUSWIDTH> | ||||
| inline void sysc::gpio_regs::registerResources(scc::tlm_target<BUSWIDTH>& target) { | ||||
|     target.addResource(value, 0x0UL); | ||||
|     target.addResource(input_en, 0x4UL); | ||||
|     target.addResource(output_en, 0x8UL); | ||||
|     target.addResource(port, 0xcUL); | ||||
|     target.addResource(pue, 0x10UL); | ||||
|     target.addResource(ds, 0x14UL); | ||||
|     target.addResource(rise_ie, 0x18UL); | ||||
|     target.addResource(rise_ip, 0x1cUL); | ||||
|     target.addResource(fall_ie, 0x20UL); | ||||
|     target.addResource(fall_ip, 0x24UL); | ||||
|     target.addResource(high_ie, 0x28UL); | ||||
|     target.addResource(high_ip, 0x2cUL); | ||||
|     target.addResource(low_ie, 0x30UL); | ||||
|     target.addResource(low_ip, 0x34UL); | ||||
|     target.addResource(iof_en, 0x38UL); | ||||
|     target.addResource(iof_sel, 0x3cUL); | ||||
|     target.addResource(out_xor, 0x40UL); | ||||
| } | ||||
|  | ||||
| #endif // _GPIO_REGS_H_ | ||||
							
								
								
									
										103
									
								
								platform/incl/sysc/SiFive/gen/plic_regs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								platform/incl/sysc/SiFive/gen/plic_regs.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,103 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // Created on: Fri Nov 10 18:01:53 CET 2017 | ||||
| //             *      plic_regs.h Author: <RDL Generator> | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _PLIC_REGS_H_ | ||||
| #define _PLIC_REGS_H_ | ||||
|  | ||||
| #include <scc/utilities.h> | ||||
| #include <util/bit_field.h> | ||||
| #include <scc/register.h> | ||||
| #include <scc/tlm_target.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class plic_regs : | ||||
|         public sc_core::sc_module, | ||||
|         public scc::resetable | ||||
| { | ||||
| public: | ||||
|     // storage declarations | ||||
|     BEGIN_BF_DECL(priority_t, uint32_t); | ||||
|         BF_FIELD(priority, 0, 3); | ||||
|     END_BF_DECL() ; | ||||
|     std::array<priority_t, 256> r_priority; | ||||
|      | ||||
|     std::array<uint32_t, 8> r_pending; | ||||
|      | ||||
|     std::array<uint32_t, 8> r_enabled; | ||||
|      | ||||
|     BEGIN_BF_DECL(threshold_t, uint32_t); | ||||
|         BF_FIELD(threshold, 0, 3); | ||||
|     END_BF_DECL() r_threshold; | ||||
|      | ||||
|     uint32_t r_claim_complete; | ||||
|      | ||||
|     // register declarations | ||||
|     scc::sc_register_indexed<priority_t, 256> priority; | ||||
|     scc::sc_register_indexed<uint32_t, 8> pending; | ||||
|     scc::sc_register_indexed<uint32_t, 8> enabled; | ||||
|     scc::sc_register<threshold_t> threshold; | ||||
|     scc::sc_register<uint32_t> claim_complete; | ||||
|      | ||||
|     plic_regs(sc_core::sc_module_name nm); | ||||
|  | ||||
|     template<unsigned BUSWIDTH=32> | ||||
|     void registerResources(scc::tlm_target<BUSWIDTH>& target); | ||||
| }; | ||||
| } | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
| // member functions | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| inline sysc::plic_regs::plic_regs(sc_core::sc_module_name nm) | ||||
| : sc_core::sc_module(nm) | ||||
| , NAMED(priority, r_priority, 0, *this) | ||||
| , NAMED(pending, r_pending, 0, *this) | ||||
| , NAMED(enabled, r_enabled, 0, *this) | ||||
| , NAMED(threshold, r_threshold, 0, *this) | ||||
| , NAMED(claim_complete, r_claim_complete, 0, *this) | ||||
| { | ||||
| } | ||||
|  | ||||
| template<unsigned BUSWIDTH> | ||||
| inline void sysc::plic_regs::registerResources(scc::tlm_target<BUSWIDTH>& target) { | ||||
|     target.addResource(priority, 0x0UL); | ||||
|     target.addResource(pending, 0x1000UL); | ||||
|     target.addResource(enabled, 0x2000UL); | ||||
|     target.addResource(threshold, 0x200000UL); | ||||
|     target.addResource(claim_complete, 0x200004UL); | ||||
| } | ||||
|  | ||||
| #endif // _PLIC_REGS_H_ | ||||
							
								
								
									
										114
									
								
								platform/incl/sysc/SiFive/gen/prci_regs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								platform/incl/sysc/SiFive/gen/prci_regs.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,114 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // Created on: Fri Nov 10 18:01:53 CET 2017 | ||||
| //             *      prci_regs.h Author: <RDL Generator> | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _PRCI_REGS_H_ | ||||
| #define _PRCI_REGS_H_ | ||||
|  | ||||
| #include <scc/utilities.h> | ||||
| #include <util/bit_field.h> | ||||
| #include <scc/register.h> | ||||
| #include <scc/tlm_target.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class prci_regs : | ||||
|         public sc_core::sc_module, | ||||
|         public scc::resetable | ||||
| { | ||||
| public: | ||||
|     // storage declarations | ||||
|     BEGIN_BF_DECL(hfrosccfg_t, uint32_t); | ||||
|         BF_FIELD(hfroscdiv, 0, 6); | ||||
|         BF_FIELD(hfrosctrim, 16, 5); | ||||
|         BF_FIELD(hfroscen, 30, 1); | ||||
|         BF_FIELD(hfroscrdy, 31, 1); | ||||
|     END_BF_DECL() r_hfrosccfg; | ||||
|      | ||||
|     BEGIN_BF_DECL(hfxosccfg_t, uint32_t); | ||||
|         BF_FIELD(hfxoscrdy, 31, 1); | ||||
|         BF_FIELD(hfxoscen, 30, 1); | ||||
|     END_BF_DECL() r_hfxosccfg; | ||||
|      | ||||
|     BEGIN_BF_DECL(pllcfg_t, uint32_t); | ||||
|         BF_FIELD(pllr, 0, 3); | ||||
|         BF_FIELD(pllf, 4, 6); | ||||
|         BF_FIELD(pllq, 10, 2); | ||||
|         BF_FIELD(pllsel, 16, 1); | ||||
|         BF_FIELD(pllrefsel, 17, 1); | ||||
|         BF_FIELD(pllbypass, 18, 1); | ||||
|         BF_FIELD(plllock, 31, 1); | ||||
|     END_BF_DECL() r_pllcfg; | ||||
|      | ||||
|     uint32_t r_plloutdiv; | ||||
|      | ||||
|     uint32_t r_coreclkcfg; | ||||
|      | ||||
|     // register declarations | ||||
|     scc::sc_register<hfrosccfg_t> hfrosccfg; | ||||
|     scc::sc_register<hfxosccfg_t> hfxosccfg; | ||||
|     scc::sc_register<pllcfg_t> pllcfg; | ||||
|     scc::sc_register<uint32_t> plloutdiv; | ||||
|     scc::sc_register<uint32_t> coreclkcfg; | ||||
|      | ||||
|     prci_regs(sc_core::sc_module_name nm); | ||||
|  | ||||
|     template<unsigned BUSWIDTH=32> | ||||
|     void registerResources(scc::tlm_target<BUSWIDTH>& target); | ||||
| }; | ||||
| } | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
| // member functions | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| inline sysc::prci_regs::prci_regs(sc_core::sc_module_name nm) | ||||
| : sc_core::sc_module(nm) | ||||
| , NAMED(hfrosccfg, r_hfrosccfg, 0, *this) | ||||
| , NAMED(hfxosccfg, r_hfxosccfg, 0x40000000, *this) | ||||
| , NAMED(pllcfg, r_pllcfg, 0, *this) | ||||
| , NAMED(plloutdiv, r_plloutdiv, 0, *this) | ||||
| , NAMED(coreclkcfg, r_coreclkcfg, 0, *this) | ||||
| { | ||||
| } | ||||
|  | ||||
| template<unsigned BUSWIDTH> | ||||
| inline void sysc::prci_regs::registerResources(scc::tlm_target<BUSWIDTH>& target) { | ||||
|     target.addResource(hfrosccfg, 0x0UL); | ||||
|     target.addResource(hfxosccfg, 0x4UL); | ||||
|     target.addResource(pllcfg, 0x8UL); | ||||
|     target.addResource(plloutdiv, 0xcUL); | ||||
|     target.addResource(coreclkcfg, 0x10UL); | ||||
| } | ||||
|  | ||||
| #endif // _PRCI_REGS_H_ | ||||
							
								
								
									
										198
									
								
								platform/incl/sysc/SiFive/gen/spi_regs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										198
									
								
								platform/incl/sysc/SiFive/gen/spi_regs.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,198 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // Created on: Fri Nov 10 18:01:53 CET 2017 | ||||
| //             *      spi_regs.h Author: <RDL Generator> | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _SPI_REGS_H_ | ||||
| #define _SPI_REGS_H_ | ||||
|  | ||||
| #include <scc/utilities.h> | ||||
| #include <util/bit_field.h> | ||||
| #include <scc/register.h> | ||||
| #include <scc/tlm_target.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class spi_regs : | ||||
|         public sc_core::sc_module, | ||||
|         public scc::resetable | ||||
| { | ||||
| public: | ||||
|     // storage declarations | ||||
|     BEGIN_BF_DECL(sckdiv_t, uint32_t); | ||||
|         BF_FIELD(div, 0, 12); | ||||
|     END_BF_DECL() r_sckdiv; | ||||
|      | ||||
|     BEGIN_BF_DECL(sckmode_t, uint32_t); | ||||
|         BF_FIELD(pha, 0, 1); | ||||
|         BF_FIELD(pol, 1, 1); | ||||
|     END_BF_DECL() r_sckmode; | ||||
|      | ||||
|     uint32_t r_csid; | ||||
|      | ||||
|     uint32_t r_csdef; | ||||
|      | ||||
|     BEGIN_BF_DECL(csmode_t, uint32_t); | ||||
|         BF_FIELD(mode, 0, 2); | ||||
|     END_BF_DECL() r_csmode; | ||||
|      | ||||
|     BEGIN_BF_DECL(delay0_t, uint32_t); | ||||
|         BF_FIELD(cssck, 0, 8); | ||||
|         BF_FIELD(sckcs, 16, 8); | ||||
|     END_BF_DECL() r_delay0; | ||||
|      | ||||
|     BEGIN_BF_DECL(delay1_t, uint32_t); | ||||
|         BF_FIELD(intercs, 0, 16); | ||||
|         BF_FIELD(interxfr, 16, 8); | ||||
|     END_BF_DECL() r_delay1; | ||||
|      | ||||
|     BEGIN_BF_DECL(fmt_t, uint32_t); | ||||
|         BF_FIELD(proto, 0, 2); | ||||
|         BF_FIELD(endian, 2, 1); | ||||
|         BF_FIELD(dir, 3, 1); | ||||
|         BF_FIELD(len, 16, 4); | ||||
|     END_BF_DECL() r_fmt; | ||||
|      | ||||
|     BEGIN_BF_DECL(txdata_t, uint32_t); | ||||
|         BF_FIELD(data, 0, 8); | ||||
|         BF_FIELD(full, 31, 1); | ||||
|     END_BF_DECL() r_txdata; | ||||
|      | ||||
|     BEGIN_BF_DECL(rxdata_t, uint32_t); | ||||
|         BF_FIELD(data, 0, 8); | ||||
|         BF_FIELD(empty, 31, 1); | ||||
|     END_BF_DECL() r_rxdata; | ||||
|      | ||||
|     BEGIN_BF_DECL(txmark_t, uint32_t); | ||||
|         BF_FIELD(txmark, 0, 3); | ||||
|     END_BF_DECL() r_txmark; | ||||
|      | ||||
|     BEGIN_BF_DECL(rxmark_t, uint32_t); | ||||
|         BF_FIELD(rxmark, 0, 3); | ||||
|     END_BF_DECL() r_rxmark; | ||||
|      | ||||
|     BEGIN_BF_DECL(fctrl_t, uint32_t); | ||||
|         BF_FIELD(en, 0, 1); | ||||
|     END_BF_DECL() r_fctrl; | ||||
|      | ||||
|     BEGIN_BF_DECL(ffmt_t, uint32_t); | ||||
|         BF_FIELD(cmd_en, 0, 1); | ||||
|         BF_FIELD(addr_len, 1, 2); | ||||
|         BF_FIELD(pad_cnt, 3, 4); | ||||
|         BF_FIELD(cmd_proto, 7, 2); | ||||
|         BF_FIELD(addr_proto, 9, 2); | ||||
|         BF_FIELD(data_proto, 11, 2); | ||||
|         BF_FIELD(cmd_code, 16, 8); | ||||
|         BF_FIELD(pad_code, 24, 8); | ||||
|     END_BF_DECL() r_ffmt; | ||||
|      | ||||
|     BEGIN_BF_DECL(ie_t, uint32_t); | ||||
|         BF_FIELD(txwm, 0, 1); | ||||
|         BF_FIELD(rxwm, 1, 1); | ||||
|     END_BF_DECL() r_ie; | ||||
|      | ||||
|     BEGIN_BF_DECL(ip_t, uint32_t); | ||||
|         BF_FIELD(txwm, 0, 1); | ||||
|         BF_FIELD(rxwm, 1, 1); | ||||
|     END_BF_DECL() r_ip; | ||||
|      | ||||
|     // register declarations | ||||
|     scc::sc_register<sckdiv_t> sckdiv; | ||||
|     scc::sc_register<sckmode_t> sckmode; | ||||
|     scc::sc_register<uint32_t> csid; | ||||
|     scc::sc_register<uint32_t> csdef; | ||||
|     scc::sc_register<csmode_t> csmode; | ||||
|     scc::sc_register<delay0_t> delay0; | ||||
|     scc::sc_register<delay1_t> delay1; | ||||
|     scc::sc_register<fmt_t> fmt; | ||||
|     scc::sc_register<txdata_t> txdata; | ||||
|     scc::sc_register<rxdata_t> rxdata; | ||||
|     scc::sc_register<txmark_t> txmark; | ||||
|     scc::sc_register<rxmark_t> rxmark; | ||||
|     scc::sc_register<fctrl_t> fctrl; | ||||
|     scc::sc_register<ffmt_t> ffmt; | ||||
|     scc::sc_register<ie_t> ie; | ||||
|     scc::sc_register<ip_t> ip; | ||||
|      | ||||
|     spi_regs(sc_core::sc_module_name nm); | ||||
|  | ||||
|     template<unsigned BUSWIDTH=32> | ||||
|     void registerResources(scc::tlm_target<BUSWIDTH>& target); | ||||
| }; | ||||
| } | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
| // member functions | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| inline sysc::spi_regs::spi_regs(sc_core::sc_module_name nm) | ||||
| : sc_core::sc_module(nm) | ||||
| , NAMED(sckdiv, r_sckdiv, 0, *this) | ||||
| , NAMED(sckmode, r_sckmode, 0, *this) | ||||
| , NAMED(csid, r_csid, 0, *this) | ||||
| , NAMED(csdef, r_csdef, 0, *this) | ||||
| , NAMED(csmode, r_csmode, 0, *this) | ||||
| , NAMED(delay0, r_delay0, 0, *this) | ||||
| , NAMED(delay1, r_delay1, 0, *this) | ||||
| , NAMED(fmt, r_fmt, 0, *this) | ||||
| , NAMED(txdata, r_txdata, 0, *this) | ||||
| , NAMED(rxdata, r_rxdata, 0, *this) | ||||
| , NAMED(txmark, r_txmark, 0, *this) | ||||
| , NAMED(rxmark, r_rxmark, 0, *this) | ||||
| , NAMED(fctrl, r_fctrl, 0, *this) | ||||
| , NAMED(ffmt, r_ffmt, 0, *this) | ||||
| , NAMED(ie, r_ie, 0, *this) | ||||
| , NAMED(ip, r_ip, 0, *this) | ||||
| { | ||||
| } | ||||
|  | ||||
| template<unsigned BUSWIDTH> | ||||
| inline void sysc::spi_regs::registerResources(scc::tlm_target<BUSWIDTH>& target) { | ||||
|     target.addResource(sckdiv, 0x0UL); | ||||
|     target.addResource(sckmode, 0x4UL); | ||||
|     target.addResource(csid, 0x10UL); | ||||
|     target.addResource(csdef, 0x14UL); | ||||
|     target.addResource(csmode, 0x18UL); | ||||
|     target.addResource(delay0, 0x28UL); | ||||
|     target.addResource(delay1, 0x2cUL); | ||||
|     target.addResource(fmt, 0x40UL); | ||||
|     target.addResource(txdata, 0x48UL); | ||||
|     target.addResource(rxdata, 0x4cUL); | ||||
|     target.addResource(txmark, 0x50UL); | ||||
|     target.addResource(rxmark, 0x54UL); | ||||
|     target.addResource(fctrl, 0x60UL); | ||||
|     target.addResource(ffmt, 0x64UL); | ||||
|     target.addResource(ie, 0x70UL); | ||||
|     target.addResource(ip, 0x74UL); | ||||
| } | ||||
|  | ||||
| #endif // _SPI_REGS_H_ | ||||
							
								
								
									
										129
									
								
								platform/incl/sysc/SiFive/gen/uart_regs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								platform/incl/sysc/SiFive/gen/uart_regs.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,129 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // Created on: Fri Nov 10 18:01:53 CET 2017 | ||||
| //             *      uart_regs.h Author: <RDL Generator> | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _UART_REGS_H_ | ||||
| #define _UART_REGS_H_ | ||||
|  | ||||
| #include <scc/utilities.h> | ||||
| #include <util/bit_field.h> | ||||
| #include <scc/register.h> | ||||
| #include <scc/tlm_target.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class uart_regs : | ||||
|         public sc_core::sc_module, | ||||
|         public scc::resetable | ||||
| { | ||||
| public: | ||||
|     // storage declarations | ||||
|     BEGIN_BF_DECL(txdata_t, uint32_t); | ||||
|         BF_FIELD(data, 0, 8); | ||||
|         BF_FIELD(full, 31, 1); | ||||
|     END_BF_DECL() r_txdata; | ||||
|      | ||||
|     BEGIN_BF_DECL(rxdata_t, uint32_t); | ||||
|         BF_FIELD(data, 0, 8); | ||||
|         BF_FIELD(empty, 31, 1); | ||||
|     END_BF_DECL() r_rxdata; | ||||
|      | ||||
|     BEGIN_BF_DECL(txctrl_t, uint32_t); | ||||
|         BF_FIELD(txen, 0, 1); | ||||
|         BF_FIELD(nstop, 1, 1); | ||||
|         BF_FIELD(txcnt, 16, 3); | ||||
|     END_BF_DECL() r_txctrl; | ||||
|      | ||||
|     BEGIN_BF_DECL(rxctrl_t, uint32_t); | ||||
|         BF_FIELD(rxen, 0, 1); | ||||
|         BF_FIELD(rxcnt, 16, 3); | ||||
|     END_BF_DECL() r_rxctrl; | ||||
|      | ||||
|     BEGIN_BF_DECL(ie_t, uint32_t); | ||||
|         BF_FIELD(txwm, 0, 1); | ||||
|         BF_FIELD(rxwm, 1, 1); | ||||
|     END_BF_DECL() r_ie; | ||||
|      | ||||
|     BEGIN_BF_DECL(ip_t, uint32_t); | ||||
|         BF_FIELD(txwm, 0, 1); | ||||
|         BF_FIELD(rxwm, 1, 1); | ||||
|     END_BF_DECL() r_ip; | ||||
|      | ||||
|     BEGIN_BF_DECL(div_t, uint32_t); | ||||
|         BF_FIELD(div, 0, 16); | ||||
|     END_BF_DECL() r_div; | ||||
|      | ||||
|     // register declarations | ||||
|     scc::sc_register<txdata_t> txdata; | ||||
|     scc::sc_register<rxdata_t> rxdata; | ||||
|     scc::sc_register<txctrl_t> txctrl; | ||||
|     scc::sc_register<rxctrl_t> rxctrl; | ||||
|     scc::sc_register<ie_t> ie; | ||||
|     scc::sc_register<ip_t> ip; | ||||
|     scc::sc_register<div_t> div; | ||||
|      | ||||
|     uart_regs(sc_core::sc_module_name nm); | ||||
|  | ||||
|     template<unsigned BUSWIDTH=32> | ||||
|     void registerResources(scc::tlm_target<BUSWIDTH>& target); | ||||
| }; | ||||
| } | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
| // member functions | ||||
| ////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| inline sysc::uart_regs::uart_regs(sc_core::sc_module_name nm) | ||||
| : sc_core::sc_module(nm) | ||||
| , NAMED(txdata, r_txdata, 0, *this) | ||||
| , NAMED(rxdata, r_rxdata, 0, *this) | ||||
| , NAMED(txctrl, r_txctrl, 0, *this) | ||||
| , NAMED(rxctrl, r_rxctrl, 0, *this) | ||||
| , NAMED(ie, r_ie, 0, *this) | ||||
| , NAMED(ip, r_ip, 0, *this) | ||||
| , NAMED(div, r_div, 0, *this) | ||||
| { | ||||
| } | ||||
|  | ||||
| template<unsigned BUSWIDTH> | ||||
| inline void sysc::uart_regs::registerResources(scc::tlm_target<BUSWIDTH>& target) { | ||||
|     target.addResource(txdata, 0x0UL); | ||||
|     target.addResource(rxdata, 0x4UL); | ||||
|     target.addResource(txctrl, 0x8UL); | ||||
|     target.addResource(rxctrl, 0xcUL); | ||||
|     target.addResource(ie, 0x10UL); | ||||
|     target.addResource(ip, 0x14UL); | ||||
|     target.addResource(div, 0x18UL); | ||||
| } | ||||
|  | ||||
| #endif // _UART_REGS_H_ | ||||
							
								
								
									
										91
									
								
								platform/incl/sysc/SiFive/gpio.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								platform/incl/sysc/SiFive/gpio.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,91 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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 | ||||
| // | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _GPIO_H_ | ||||
| #define _GPIO_H_ | ||||
|  | ||||
| #include "scc/tlm_target.h" | ||||
| #include "scc/signal_target_mixin.h" | ||||
| #include "scc/signal_initiator_mixin.h" | ||||
| #include <tlm/tlm_signal.h> | ||||
| #include "cci_configuration" | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class gpio_regs; | ||||
| class WsHandler; | ||||
|  | ||||
| class gpio : public sc_core::sc_module, public scc::tlm_target<> { | ||||
| public: | ||||
|     SC_HAS_PROCESS(gpio); | ||||
|     sc_core::sc_in<sc_core::sc_time> clk_i; | ||||
|     sc_core::sc_in<bool> rst_i; | ||||
|     // sc_core::sc_inout_rv<32> pins_io; | ||||
|  | ||||
|     sc_core::sc_vector<scc::tlm_signal_logic_out> pins_o; | ||||
|     sc_core::sc_vector<scc::tlm_signal_logic_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); | ||||
|     virtual ~gpio() override; // need to keep it in source file because of fwd declaration of gpio_regs | ||||
|  | ||||
|     cci::cci_param<bool> write_to_ws; | ||||
|  | ||||
| protected: | ||||
|     void clock_cb(); | ||||
|     void reset_cb(); | ||||
|     void update_pins(); | ||||
|     void before_end_of_elaboration(); | ||||
|     void pin_input(unsigned int tag, tlm::tlm_signal_gp<sc_logic>& gp, sc_core::sc_time& delay); | ||||
|     void forward_pin_input(unsigned int tag, tlm::tlm_signal_gp<sc_logic>& 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; | ||||
|     std::array<bool, 32> last_iof0, last_iof1; | ||||
|     std::unique_ptr<gpio_regs> regs; | ||||
|     std::shared_ptr<sysc::WsHandler> handler; | ||||
|  | ||||
| private: | ||||
|     tlm::tlm_phase write_output(tlm::tlm_signal_gp<sc_dt::sc_logic>& gp, size_t i, sc_dt::sc_logic val); | ||||
|     void enable_outputs(uint32_t new_iof_en, uint32_t new_iof_sel); | ||||
| }; | ||||
|  | ||||
| } /* namespace sysc */ | ||||
|  | ||||
| #endif /* _GPIO_H_ */ | ||||
							
								
								
									
										101
									
								
								platform/incl/sysc/SiFive/hifive1.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								platform/incl/sysc/SiFive/hifive1.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,101 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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 | ||||
| // | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _PLATFORM_H_ | ||||
| #define _PLATFORM_H_ | ||||
|  | ||||
| #include "aon.h" | ||||
| #include "clint.h" | ||||
| #include "gpio.h" | ||||
| #include "plic.h" | ||||
| #include "prci.h" | ||||
| #include "spi.h" | ||||
| #include "uart.h" | ||||
| #include "sysc/core_complex.h" | ||||
|  | ||||
| #include "scc/memory.h" | ||||
| #include "scc/router.h" | ||||
| #include "scc/utilities.h" | ||||
| #include "tlm/tlm_signal_sockets.h" | ||||
| #include <sysc/kernel/sc_module.h> | ||||
| #include <array> | ||||
|  | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class hifive1 : public sc_core::sc_module { | ||||
| public: | ||||
|     SC_HAS_PROCESS(hifive1); | ||||
|  | ||||
|     sc_core::sc_vector<tlm::tlm_signal_initiator_socket<sc_dt::sc_logic>> pins_o; | ||||
|     sc_core::sc_vector<tlm::tlm_signal_target_socket<sc_dt::sc_logic>>    pins_i; | ||||
|  | ||||
|     sc_core::sc_in<bool> erst_n; | ||||
|  | ||||
|     hifive1(sc_core::sc_module_name nm); | ||||
|  | ||||
| private: | ||||
|     SiFive::core_complex i_core_complex; | ||||
|     scc::router<> i_router; | ||||
|     uart i_uart0, i_uart1; | ||||
|     spi i_qspi0, i_qspi1, i_qspi2; | ||||
|     gpio i_gpio0; | ||||
|     plic i_plic; | ||||
|     aon i_aon; | ||||
|     prci i_prci; | ||||
|     clint i_clint; | ||||
|  | ||||
|     scc::memory<512_MB, 32> i_mem_qspi; | ||||
|     scc::memory<128_kB, 32> i_mem_ram; | ||||
|     sc_core::sc_signal<sc_core::sc_time> s_tlclk; | ||||
|     sc_core::sc_signal<sc_core::sc_time> s_lfclk; | ||||
|     sc_core::sc_signal<bool> s_rst, s_mtime_int, s_msie_int; | ||||
|     sc_core::sc_vector<sc_core::sc_signal<bool, SC_MANY_WRITERS>> s_global_int, s_local_int; | ||||
|     sc_core::sc_signal<bool> s_core_int; | ||||
|     sc_core::sc_vector<sc_core::sc_signal<bool>> s_dummy; | ||||
|     sc_core::sc_vector<scc::tlm_signal_bool_opt_in>  s_dummy_sck_i; | ||||
|     sc_core::sc_vector<scc::tlm_signal_bool_opt_out> s_dummy_sck_o; | ||||
|  | ||||
|  | ||||
| protected: | ||||
|     void gen_reset(); | ||||
|  | ||||
| #include "gen/e300_plat_t.h" | ||||
| }; | ||||
|  | ||||
| } /* namespace sysc */ | ||||
|  | ||||
| #endif /* _PLATFORM_H_ */ | ||||
							
								
								
									
										77
									
								
								platform/incl/sysc/SiFive/plic.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								platform/incl/sysc/SiFive/plic.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,77 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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 | ||||
| // | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _PLIC_H_ | ||||
| #define _PLIC_H_ | ||||
|  | ||||
| #include <scc/register.h> | ||||
| #include <scc/tlm_target.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class plic_regs; | ||||
|  | ||||
| class plic : public sc_core::sc_module, public scc::tlm_target<> { | ||||
| public: | ||||
|     SC_HAS_PROCESS(plic); | ||||
|     sc_core::sc_in<sc_core::sc_time> clk_i; | ||||
|     sc_core::sc_in<bool> rst_i; | ||||
|     sc_core::sc_vector<sc_core::sc_in<bool>> global_interrupts_i; | ||||
|     sc_core::sc_out<bool> core_interrupt_o; | ||||
|     sc_core::sc_event raise_int_ev; | ||||
|     sc_core::sc_event clear_int_ev; | ||||
|     plic(sc_core::sc_module_name nm); | ||||
|     ~plic() override; | ||||
|  | ||||
| protected: | ||||
|     void clock_cb(); | ||||
|     void reset_cb(); | ||||
|     void init_callbacks(); | ||||
|  | ||||
|     void global_int_port_cb(); | ||||
|     void handle_pending_int(); | ||||
|     void reset_pending_int(uint32_t irq); | ||||
|  | ||||
|     void raise_core_interrupt(); | ||||
|     void clear_core_interrupt(); | ||||
|     sc_core::sc_time clk; | ||||
|     std::unique_ptr<plic_regs> regs; | ||||
|     std::function<bool(scc::sc_register<uint32_t>, uint32_t)> m_claim_complete_write_cb; | ||||
| }; | ||||
|  | ||||
| } /* namespace sysc */ | ||||
|  | ||||
| #endif /* _PLIC_H_ */ | ||||
							
								
								
									
										68
									
								
								platform/incl/sysc/SiFive/prci.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								platform/incl/sysc/SiFive/prci.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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 | ||||
| // | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _PRCI_H_ | ||||
| #define _PRCI_H_ | ||||
|  | ||||
| #include "scc/tlm_target.h" | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class prci_regs; | ||||
|  | ||||
| class prci : public sc_core::sc_module, public scc::tlm_target<> { | ||||
| public: | ||||
|     SC_HAS_PROCESS(prci); | ||||
|     sc_core::sc_port<sc_core::sc_signal_in_if<sc_core::sc_time>,1,SC_ZERO_OR_MORE_BOUND> hfxosc_i; | ||||
|     sc_core::sc_in<bool> rst_i; | ||||
|     sc_core::sc_out<sc_core::sc_time> hfclk_o; | ||||
|     prci(sc_core::sc_module_name nm); | ||||
|     virtual ~prci() override; // need to keep it in source file because of fwd declaration of prci_regs | ||||
|  | ||||
| protected: | ||||
|     void hfxosc_cb(); | ||||
|     void reset_cb(); | ||||
|     void hfrosc_en_cb(); | ||||
|     void hfxosc_en_cb(); | ||||
|     void update_hfclk(); | ||||
|     sc_core::sc_time hfxosc_clk, hfrosc_clk, pll_clk, hfclk; | ||||
|     std::unique_ptr<prci_regs> regs; | ||||
|     sc_core::sc_event hfrosc_en_evt, hfxosc_en_evt; | ||||
| }; | ||||
|  | ||||
| } /* namespace sysc */ | ||||
|  | ||||
| #endif /* _GPIO_H_ */ | ||||
							
								
								
									
										81
									
								
								platform/incl/sysc/SiFive/spi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								platform/incl/sysc/SiFive/spi.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,81 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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 | ||||
| // | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _SPI_H_ | ||||
| #define _SPI_H_ | ||||
|  | ||||
| #include "scc/tlm_target.h" | ||||
| #include "scc/signal_target_mixin.h" | ||||
| #include "scc/signal_initiator_mixin.h" | ||||
| #include <tlm/tlm_signal.h> | ||||
| #include "cci_configuration" | ||||
| #include <sysc/utils/sc_vector.h> | ||||
|  | ||||
| namespace sysc { | ||||
|  | ||||
| class spi_regs; | ||||
|  | ||||
| class spi : public sc_core::sc_module, public scc::tlm_target<> { | ||||
| public: | ||||
|     SC_HAS_PROCESS(spi); | ||||
|     sc_core::sc_in<sc_core::sc_time> clk_i; | ||||
|     sc_core::sc_in<bool>             rst_i; | ||||
|     scc::tlm_signal_bool_opt_out         sck_o; | ||||
|     scc::tlm_signal_bool_opt_out         mosi_o; | ||||
|     scc::tlm_signal_bool_opt_in          miso_i; | ||||
|     sc_core::sc_vector<scc::tlm_signal_bool_opt_out> scs_o; | ||||
|  | ||||
|     sc_core::sc_out<bool> irq_o; | ||||
|  | ||||
|     cci::cci_param<bool> bit_true_transfer; | ||||
|  | ||||
|     spi(sc_core::sc_module_name nm); | ||||
|     virtual ~spi() override; | ||||
|  | ||||
| protected: | ||||
|     void clock_cb(); | ||||
|     void reset_cb(); | ||||
|     void transmit_data(); | ||||
|     void receive_data(tlm::tlm_signal_gp<>& gp, sc_core::sc_time& delay); | ||||
|     void update_irq(); | ||||
|     sc_core::sc_time clk; | ||||
|     std::unique_ptr<spi_regs> regs; | ||||
|     sc_core::sc_fifo<uint8_t> rx_fifo, tx_fifo; | ||||
| }; | ||||
|  | ||||
| } /* namespace sysc */ | ||||
|  | ||||
| #endif /* _SPI_H_ */ | ||||
							
								
								
									
										79
									
								
								platform/incl/sysc/SiFive/uart.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								platform/incl/sysc/SiFive/uart.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,79 @@ | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
| // Copyright (C) 2017, MINRES Technologies GmbH | ||||
| // All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are met: | ||||
| // | ||||
| // 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 | ||||
| // | ||||
| // | ||||
| //////////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| #ifndef _UART_H_ | ||||
| #define _UART_H_ | ||||
|  | ||||
| #include "scc/tlm_target.h" | ||||
| #include "scc/signal_target_mixin.h" | ||||
| #include "scc/signal_initiator_mixin.h" | ||||
| #include <tlm/tlm_signal.h> | ||||
| #include "cci_configuration" | ||||
|  | ||||
| namespace sysc { | ||||
| class tlm_signal_uart_extension; | ||||
| class uart_regs; | ||||
| class WsHandler; | ||||
|  | ||||
| class uart : public sc_core::sc_module, public scc::tlm_target<> { | ||||
| public: | ||||
|     SC_HAS_PROCESS(uart); | ||||
|     sc_core::sc_in<sc_core::sc_time> clk_i; | ||||
|     sc_core::sc_in<bool> rst_i; | ||||
|     scc::tlm_signal_bool_out tx_o; | ||||
|     scc::tlm_signal_bool_in  rx_i; | ||||
|  | ||||
|     sc_core::sc_out<bool> irq_o; | ||||
|  | ||||
|     cci::cci_param<bool> bit_true_transfer; | ||||
|  | ||||
|     uart(sc_core::sc_module_name nm); | ||||
|     virtual ~uart() override; | ||||
|  | ||||
| protected: | ||||
|     void clock_cb(); | ||||
|     void reset_cb(); | ||||
|     void transmit_data(); | ||||
|     void receive_data(tlm::tlm_signal_gp<>& gp, sc_core::sc_time& delay); | ||||
|     void update_irq(); | ||||
|     sc_core::sc_time clk{SC_ZERO_TIME},rx_last_start{SC_ZERO_TIME}; | ||||
|     std::unique_ptr<uart_regs> regs; | ||||
|     sc_core::sc_fifo<uint8_t> rx_fifo, tx_fifo; | ||||
| }; | ||||
|  | ||||
| } /* namespace sysc */ | ||||
|  | ||||
| #endif /* _UART_H_ */ | ||||
		Reference in New Issue
	
	Block a user