adding hyperram for arty a7 and also adding a workaround for some stupid issues
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 22 Mar 2022 16:59:31 +0000 (16:59 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 22 Mar 2022 16:59:31 +0000 (16:59 +0000)
coldboot/coldboot.c
src/arty_a7_ls2.py [new file with mode: 0644]
src/ls2.py
src/versa_ecp5_85_ls2.py [new file with mode: 0644]

index 24966707943acb5d890d3cb77e3194ec24aa289b..8b746d22f4a66c07a88c2e19544411c44e23b1ee 100644 (file)
@@ -67,7 +67,7 @@ int main(void) {
        //puts("Firmware launched...\n");
 
        puts("fw..");
-#if 0
+#if 1
        volatile uint32_t *hyperram = 0xa0000000;
     // quick write/read
     writel(0xDEAF0000, (unsigned long)&(hyperram[0]));
diff --git a/src/arty_a7_ls2.py b/src/arty_a7_ls2.py
new file mode 100644 (file)
index 0000000..180e845
--- /dev/null
@@ -0,0 +1,3 @@
+from ls2 import build_platform
+
+build_platform("arty_a7", "coldboot/coldboot.bin")
index 855ddd3dd2dfbfe381d2ad3c7ae6e3e4552077b4..269fdb5b78eb41895d656ab190d3cc9d597eb8d5 100644 (file)
@@ -546,13 +546,9 @@ class DDR3SoC(SoC, Elaboratable):
         ports += [ClockSignal(), ResetSignal()]
         return ports
 
-if __name__ == "__main__":
+def build_platform(fpga, firmware):
 
-    # create a platform selected from the toolchain. defaults to VERSA_ECP5
-    # only VERSA_ECP5 will work for now because of the DDR3 module
-    fpga = "versa_ecp5"
-    if len(sys.argv) >= 2:
-        fpga = sys.argv[1]
+    # create a platform selected from the toolchain. 
     platform_kls =  {'versa_ecp5': VersaECP5Platform,
                      'versa_ecp5_85': VersaECP5Platform85,
                      'ulx3s': ULX3S_85F_Platform,
@@ -591,13 +587,13 @@ if __name__ == "__main__":
     if fpga == 'arty_a7':
         clk_freq = 12e6
 
-    # select a firmware file
-    firmware = None
+    # select a firmware address
     fw_addr = None
-    if len(sys.argv) >= 3:
-        firmware = sys.argv[2]
+    if firmware is not None:
         fw_addr = 0x0000_0000
 
+    print ("fpga", fpga, "firmware", firmware)
+
     # get UART resource pins
     if platform is not None:
         uart_pins = platform.request("uart", 0)
@@ -631,15 +627,28 @@ if __name__ == "__main__":
 
     # Get HyperRAM pins
     hyperram_pins = None
-    if platform is not None and fpga in ['versa_ecp5', 'versa_ecp5_85']:
+    if platform is None or platform in ['isim']:
+        hyperram_pins = HyperRAMPads()
+    # Digilent Arty A7-100t
+    elif platform is not None and fpga in ['arty_a7']:
+        hyperram_ios = HyperRAMResource(0, cs_n="B11",
+                                        dq="D4 D3 F4 F3 G2 H2 D2 E2",
+                                        rwds="U13", rst_n="T13", ck_p="V10"
+                                        # ck_n="D12" - for later (DDR)
+                                        )
+                                        #attrs=Attrs(IO_TYPE="LVCMOS33"))
+        platform.add_resources(hyperram_ios)
+        hyperram_pins = platform.request("hyperram")
+        print ("arty a7 hyperram", hyperram_ios)
+    # VERSA ECP5
+    elif platform is not None and fpga in ['versa_ecp5', 'versa_ecp5_85']:
         hyperram_ios = HyperRAMResource(0, cs_n="B13",
                                         dq="E14 C10 B10 E12 D12 A9 D11 D14",
                                         rwds="C14", rst_n="E13", ck_p="D13",
                                         attrs=Attrs(IO_TYPE="LVCMOS33"))
         platform.add_resources(hyperram_ios)
         hyperram_pins = platform.request("hyperram")
-    else:
-        hyperram_pins = HyperRAMPads()
+        print ("versa ecp5 hyperram", hyperram_ios)
 
     # set up the SOC
     soc = DDR3SoC(fpga=fpga, dram_cls=dram_cls,
@@ -679,3 +688,14 @@ if __name__ == "__main__":
         with open("ls2.v", "w") as f:
             f.write(vl)
 
+
+# urrr this gets exec()d by the build process without arguments
+# which screws up.  use the arty_a7_ls2.py etc. with no arguments
+if __name__ == '__main__':
+    fpga = None
+    firmware = None
+    if len(sys.argv) >= 2:
+        fpga = sys.argv[1]
+    if len(sys.argv) >= 3:
+        firmware = sys.argv[2]
+    build_platform(fpga, firmware)
diff --git a/src/versa_ecp5_85_ls2.py b/src/versa_ecp5_85_ls2.py
new file mode 100644 (file)
index 0000000..e5780b0
--- /dev/null
@@ -0,0 +1,3 @@
+from ls2 import build_platform
+
+build_platform("versa_ecp5_85", "coldboot/coldboot.bin")