Working at 50MHz system clock
authorRaptor Engineering Development Team <support@raptorengineering.com>
Thu, 7 Apr 2022 18:39:38 +0000 (13:39 -0500)
committerRaptor Engineering Development Team <support@raptorengineering.com>
Thu, 7 Apr 2022 18:39:38 +0000 (13:39 -0500)
examples/headless-versa-85.py
examples/headless/main.c

index d2692e5e8a9b59dc82506bb8a18a141490922d9e..3050f8966ff90e57d6e0d049cc6e9d2642b43cce 100644 (file)
@@ -31,23 +31,32 @@ class DDR3SoC(SoC, Elaboratable):
         self._decoder = wishbone.Decoder(addr_width=30, data_width=32, granularity=8,
                                          features={"cti", "bte"})
 
+        #desired_sys_clk_freq = 100e6
+        #desired_sys_clk_freq = 90e6
+        #desired_sys_clk_freq = 75e6
+        #desired_sys_clk_freq = 70e6
+        #desired_sys_clk_freq = 65e6
+        #desired_sys_clk_freq = 60e6
+        #desired_sys_clk_freq = 55e6
+        desired_sys_clk_freq = 50e6
+
         #self.crg = ECPIX5CRG()
-        self.crg = ECP5CRG()
+        self.crg = ECP5CRG(sys_clk_freq=desired_sys_clk_freq)
 
-        self.ub = UARTBridge(divisor=868, pins=platform.request("uart", 0))
+        self.ub = UARTBridge(divisor=int(desired_sys_clk_freq/115200), pins=platform.request("uart", 0))
 
         ddr_pins = platform.request("ddr3", 0, dir={"dq":"-", "dqs":"-"},
             xdr={"clk":4, "a":4, "ba":4, "clk_en":4, "odt":4, "ras":4, "cas":4, "we":4, "cs":4, "rst":1})
         self.ddrphy = DomainRenamer("dramsync")(ECP5DDRPHY(ddr_pins))
         self._decoder.add(self.ddrphy.bus, addr=ddrphy_addr)
 
-        ddrmodule = MT41K64M16(platform.default_clk_frequency, "1:2")
+        ddrmodule = MT41K64M16(self.crg.sys_clk_freq, "1:2")
 
         self.dramcore = DomainRenamer("dramsync")(gramCore(
             phy=self.ddrphy,
             geom_settings=ddrmodule.geom_settings,
             timing_settings=ddrmodule.timing_settings,
-            clk_freq=platform.default_clk_frequency))
+            clk_freq=self.crg.sys_clk_freq))
         self._decoder.add(self.dramcore.bus, addr=dramcore_addr)
 
         self.drambone = DomainRenamer("dramsync")(gramWishbone(self.dramcore))
@@ -55,7 +64,7 @@ class DDR3SoC(SoC, Elaboratable):
 
         self.memory_map = self._decoder.bus.memory_map
 
-        self.clk_freq = platform.default_clk_frequency
+        self.clk_freq = self.crg.sys_clk_freq
 
     def elaborate(self, platform):
         m = Module()
index 35e6b46a3a8fddf434582135c6b03700988d84c2..37d22bdb9ee8f36623bee50c206d90c51b31a9d1 100644 (file)
@@ -122,13 +122,22 @@ int main(int argc, char *argv[]) {
 #if 0
        struct gramProfile profile = {
                .mode_registers = {
-                       0xb20, 0x806, 0x200, 0x0
+                       0xb30, 0x806, 0x200, 0x0
                },
                .rdly_p0 = 2,
                .rdly_p1 = 2,
        };
 #endif
 #if 1
+       struct gramProfile profile = {
+               .mode_registers = {
+                       0xb20, 0x806, 0x200, 0x0
+               },
+               .rdly_p0 = 2,
+               .rdly_p1 = 2,
+       };
+#endif
+#if 0
        struct gramProfile profile = {
                .mode_registers = {
                        0x320, 0x6, 0x200, 0x0