fastmodel: Export GICV3Comms directly.
authorGabe Black <gabeblack@google.com>
Sat, 31 Aug 2019 00:02:43 +0000 (17:02 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 9 Oct 2019 20:54:12 +0000 (20:54 +0000)
This lets us avoid having to have two levels of bridging and twice as
many ports on both the CPU and GIC side. The direct communication ports
can be instantiated and connected using array syntax, where the bridges
require instantiating each bridge individually and wiring them up one
at a time with a lot of boilerplate/duplicate code.

Change-Id: I815ee47bcd19994e46a5220e0c23e89c497d7aa5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21050
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chun-Chen TK Hsu <chunchenhsu@google.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>

src/arch/arm/fastmodel/CortexA76x1/CortexA76x1.lisa
src/arch/arm/fastmodel/CortexA76x1/FastModelCortexA76x1.py
src/arch/arm/fastmodel/CortexA76x1/cortex_a76x1.cc
src/arch/arm/fastmodel/CortexA76x1/cortex_a76x1.hh
src/arch/arm/fastmodel/GIC/FastModelGIC.py
src/arch/arm/fastmodel/GIC/GIC.lisa
src/arch/arm/fastmodel/GIC/gic.cc
src/arch/arm/fastmodel/GIC/gic.hh
src/arch/arm/fastmodel/SConscript

index 28c0bd9a5f1c2a633899a80dce943299661e28f0..695ae9ef2eb7aa4b8f7df269de7ccc5a0d446a81 100644 (file)
@@ -36,9 +36,6 @@ component CortexA76x1
 
         // Bridges for the core.
         ambaBridge : PVBus2AMBAPV();
-        gic_pv2gic : PVBusGICv3Comms();
-        gic_pv2amba : PVBus2AMBAPV();
-        gic_amba2pv : AMBAPV2PVBus();
 
         // Adapters for CPU-to-GIC signals
         CNTHPIRQ : SGSignal2AMBAPVSignal();
@@ -64,14 +61,7 @@ component CortexA76x1
         ambaBridge.amba_pv_m => self.amba;
 
         // Connection to the GIC.
-        self.redistributor_s => gic_amba2pv.amba_pv_s;
-        // Bridges coming in.
-        gic_amba2pv.pvbus_m => gic_pv2gic.pvbus_s;
-        // Bridge to GICV3Comms.
-        gic_pv2gic.distributor_m[0] => core.gicv3_redistributor_s[0];
-        // Bridges going out.
-        gic_pv2gic.pvbus_m => gic_pv2amba.pvbus_s;
-        gic_pv2amba.amba_pv_m => self.redistributor_m;
+        self.redistributor =>core.gicv3_redistributor_s[0];
 
         // Connections from CPU to adapters
         core.CNTHPIRQ[0] => CNTHPIRQ.sg_signal_s;
@@ -113,8 +103,7 @@ component CortexA76x1
             clockDiv.rate.set64(mul, div);
         }
     }
-    slave port<AMBAPV> redistributor_s;
-    master port<AMBAPV> redistributor_m;
+    slave port<GICv3Comms> redistributor;
 
     // External ports for CPU-to-GIC signals
     master port<AMBAPVSignal> cnthpirq;
index 215189f210151ce9742b231b396d7cc52e12194c..055223f9ceffbce516e4a5c5f64d55ccc8216391 100644 (file)
@@ -71,8 +71,7 @@ class FastModelCortexA76x1(SystemC_ScModule):
             "Non-secure physical timer event")
 
     amba = AmbaInitiatorSocket(64, 'AMBA initiator socket')
-    redistributor_m = Gicv3CommsInitiatorSocket('GIC communication initiator')
-    redistributor_s = Gicv3CommsTargetSocket('GIC communication target')
+    redistributor = Gicv3CommsTargetSocket('GIC communication target')
 
     # These parameters are described in "Fast Models Reference Manual" section
     # 3.4.19, "ARMCortexA7x1CT".
index 15021e71d42c50e6b6dd46288fe5c0ef8e0e818d..50d5417a63bbfa0e0c0fd799b346ce6138a74520 100644 (file)
@@ -50,8 +50,8 @@ CortexA76x1::CortexA76x1(const sc_core::sc_module_name &mod_name,
         const FastModelCortexA76x1Params &p)
     : scx_evs_CortexA76x1(mod_name),
       amba(scx_evs_CortexA76x1::amba, p.name + ".amba", -1),
-      redistributorM(redistributor_m, p.name + ".redistributor_m", -1),
-      redistributorS(redistributor_s, p.name + ".redistributor_s", -1),
+      redistributor(scx_evs_CortexA76x1::redistributor,
+              p.name + ".redistributor", -1),
       cnthpirq("cnthpirq"),
       cnthvirq("cnthvirq"),
       cntpsirq("cntpsirq"),
@@ -264,10 +264,8 @@ CortexA76x1::gem5_getPort(const std::string &if_name, int idx)
 {
     if (if_name == "amba")
         return amba;
-    else if (if_name == "redistributor_m")
-        return redistributorM;
-    else if (if_name == "redistributor_s")
-        return redistributorS;
+    else if (if_name == "redistributor")
+        return redistributor;
     else
         return scx_evs_CortexA76x1::gem5_getPort(if_name, idx);
 }
index 73f04ea8661a2f864b16e1ab7203f42911c6625a..c4ea983176fed7b1e4457fe49c2f1cc64809f8d6 100644 (file)
@@ -54,9 +54,13 @@ class CortexA76x1 : public scx_evs_CortexA76x1
   private:
     SC_HAS_PROCESS(CortexA76x1);
 
+    typedef sc_gem5::TlmTargetBaseWrapper<
+        64, svp_gicv3_comms::gicv3_comms_fw_if,
+        svp_gicv3_comms::gicv3_comms_bw_if, 1,
+        sc_core::SC_ONE_OR_MORE_BOUND> TlmGicTarget;
+
     AmbaInitiator amba;
-    AmbaInitiator redistributorM;
-    AmbaTarget redistributorS;
+    TlmGicTarget redistributor;
 
     ClockRateControlInitiatorSocket clockRateControl;
 
index 82f2d281aa593b3443958d72e4016e02cee41f10..6390edff7e10c13a4c618cbab321527eec1293e3 100644 (file)
@@ -457,5 +457,4 @@ class FastModelGIC(BaseGic):
     amba_m = AmbaInitiatorSocket(64, 'Memory initiator socket')
     amba_s = AmbaTargetSocket(64, 'Memory target socket')
 
-    redistributor_m = Gicv3CommsInitiatorSocket('GIC communication initiator')
-    redistributor_s = Gicv3CommsTargetSocket('GIC communication target')
+    redistributor = Gicv3CommsInitiatorSocket('GIC communication initiator')
index f691b261ac45b775000de15b5a92ad2f4f9df855..098b51d3994ccdb436ae98cf79486497448ad9d0 100644 (file)
@@ -54,11 +54,7 @@ component GIC
         mem_in.pvbus_m => gic.pvbus_s;
 
         // For the CPU interface.
-        gic.redistributor_m => gic_gic2pv.distributor_s;
-        gic_gic2pv.pvbus_m => gic_pv2amba.pvbus_s;
-        gic_pv2amba.amba_pv_m => self.redistributor_m;
-        self.redistributor_s => gic_amba2pv.amba_pv_s;
-        gic_amba2pv.pvbus_m => gic_gic2pv.pvbus_s;
+        gic.redistributor_m => self.redistributor;
 
         // Internal ports for PPI and SPI programmatic access.
         self.ppi_0 => gic.ppi_in_0;
@@ -329,8 +325,7 @@ component GIC
     master port<AMBAPV> amba_m;
     slave port<AMBAPV> amba_s;
 
-    slave port<AMBAPV> redistributor_s;
-    master port<AMBAPV> redistributor_m;
+    master port<GICv3Comms> redistributor;
 
     #define setPPI(C) \
           case C: ppi_##C[num].setValue(state); \
index 62a82b262295cd8f6d010be390471c523324c125..ae9ce02d295d94b2c4ee0b6c0688b85fcd1881ed 100644 (file)
@@ -261,10 +261,8 @@ GIC::GIC(const FastModelGICParams &params) :
     BaseGic(&params),
     ambaM(params.sc_gic->amba_m, params.name + ".amba_m", -1),
     ambaS(params.sc_gic->amba_s, params.name + ".amba_s", -1),
-    redistributorM(params.sc_gic->redistributor_m,
-                   params.name + ".redistributor_m", -1),
-    redistributorS(params.sc_gic->redistributor_s,
-                   params.name + ".redistributor_s", -1),
+    redistributor(params.sc_gic->redistributor,
+                  params.name + ".redistributor", -1),
     scGIC(params.sc_gic)
 {
 }
@@ -276,10 +274,8 @@ GIC::getPort(const std::string &if_name, PortID idx)
         return ambaM;
     else if (if_name == "amba_s")
         return ambaS;
-    else if (if_name == "redistributor_m")
-        return redistributorM;
-    else if (if_name == "redistributor_s")
-        return redistributorS;
+    else if (if_name == "redistributor")
+        return redistributor;
     else
         return BaseGic::getPort(if_name, idx);
 }
index 11209ab2772c5c6460a007990ad6e31f337a2a4c..de97f63fea9aa0c33d9abc01eb73e6f3c4f85836 100644 (file)
@@ -70,10 +70,14 @@ class SCGIC : public scx_evs_GIC
 class GIC : public BaseGic
 {
   private:
+    typedef sc_gem5::TlmInitiatorBaseWrapper<
+        64, svp_gicv3_comms::gicv3_comms_fw_if,
+        svp_gicv3_comms::gicv3_comms_bw_if, 1,
+        sc_core::SC_ONE_OR_MORE_BOUND> TlmGicInitiator;
+
     AmbaInitiator ambaM;
     AmbaTarget ambaS;
-    AmbaInitiator redistributorM;
-    AmbaTarget redistributorS;
+    TlmGicInitiator redistributor;
 
     SCGIC *scGIC;
 
index 17d931f4bf35488543b4aa2e908c24b326fa0f35..e4c95900b8931881edbb0a388106b4aa9252316c 100644 (file)
@@ -366,3 +366,26 @@ Source('fastmodel.cc')
 SimObject('FastModel.py')
 Source('amba_to_tlm_bridge.cc')
 Source('amba_from_tlm_bridge.cc')
+
+# HACK: Make sure the gic protocol headers are somewhere we can find them.
+# These should start out alongside other headers fast model provides which we
+# are already able to include, but unfortunately they're in the examples
+# directory.
+gicv3_comms_headers = (
+        'gicv3_comms_base.h', 'gicv3_comms_if.h', 'gicv3_comms_sockets.h')
+examples_common_dir = pvlib_home.Dir('examples/SystemCExport/Common')
+gic_protocol_path = 'Protocols/GICv3Comms'
+gic_protocol_dest = Dir(env['BUILDDIR']).Dir(gic_protocol_path)
+gic_protocol_src = examples_common_dir.Dir(gic_protocol_path)
+
+for header in gicv3_comms_headers:
+    Command(gic_protocol_dest.File(header), gic_protocol_src.File(header),
+            Copy('${TARGET}', '${SOURCE}'))
+
+lisa_protocol_types_header_path = 'include/lisa_protocol_types.h'
+lisa_protocol_types_header_target = \
+    gic_protocol_dest.File(lisa_protocol_types_header_path)
+lisa_protocol_types_header_src = \
+    examples_common_dir.File(lisa_protocol_types_header_path)
+Command(lisa_protocol_types_header_target, lisa_protocol_types_header_src,
+        Copy('${TARGET}', '${SOURCE}'))