examples/{sram,sdram}_soc: add --build-dir parameter.
authorJean-François Nguyen <jf@lambdaconcept.com>
Wed, 30 Jun 2021 15:40:57 +0000 (17:40 +0200)
committerJean-François Nguyen <jf@lambdaconcept.com>
Wed, 30 Jun 2021 15:40:57 +0000 (17:40 +0200)
examples/sdram_soc.py
examples/sram_soc.py

index c8afa89a19f18e44e55f1eb6795078e7f37ca88b..bbe68ebc6a5a89c20cfdff04c052d5a03ddc2b2c 100644 (file)
@@ -107,6 +107,9 @@ if __name__ == "__main__":
     parser.add_argument("--baudrate", type=int,
             default=9600,
             help="UART baudrate (default: 9600)")
+    parser.add_argument("--build-dir", type=str,
+            default="build",
+            help="local build directory (default: 'build')")
     args = parser.parse_args()
 
     if args.platform == "arty_a7":
@@ -144,8 +147,9 @@ if __name__ == "__main__":
     litedram_pins = litedram_cfg.request_pins(platform, "ddr3", 0)
     litedram_core = litedram.Core(litedram_cfg, pins=litedram_pins)
 
-    litedram_builder  = litedram.Builder()
-    litedram_products = litedram_core.build(litedram_builder, do_build=True)
+    litedram_builder   = litedram.Builder()
+    litedram_build_dir = f"{args.build_dir}/litedram"
+    litedram_products  = litedram_core.build(litedram_builder, build_dir=litedram_build_dir)
 
     litedram_core_v = f"{litedram_core.name}/{litedram_core.name}.v"
     platform.add_file(litedram_core_v, litedram_products.get(litedram_core_v, mode="t"))
@@ -160,6 +164,7 @@ if __name__ == "__main__":
            ram_addr=0x30008000, ram_size=0x1000,
          sdram_addr=0x40000000, sdram_core=litedram_core, sdram_cache_size=8192,
     )
-    soc.build(do_build=True, do_init=True)
 
-    platform.build(soc, do_program=True)
+    soc.build(build_dir=f"{args.build_dir}/soc", litedram_dir=litedram_build_dir, do_init=True)
+
+    platform.build(soc, build_dir=args.build_dir, do_program=True)
index 0ebe512a9820137902d28de5fedd9b6bdd5b68a6..b570d2bc33653e6951824f19f831218839d2e387 100644 (file)
@@ -73,13 +73,14 @@ class SRAMSoC(CPUSoC, Elaboratable):
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser()
-
     parser.add_argument("platform", type=str,
             help="target platform (e.g. 'nmigen_boards.arty_a7.ArtyA7Platform')")
     parser.add_argument("--baudrate", type=int,
             default=9600,
             help="UART baudrate (default: 9600)")
-
+    parser.add_argument("--build-dir", type=str,
+            default="build",
+            help="local build directory (default: 'build')")
     args = parser.parse_args()
 
     def get_platform(platform_name):
@@ -101,5 +102,6 @@ if __name__ == "__main__":
          timer_addr=0x00006000, timer_width=32,
     )
 
-    soc.build(do_build=True, do_init=True)
-    platform.build(soc, do_program=True)
+    soc.build(build_dir=f"{args.build_dir}/soc", do_init=True)
+
+    platform.build(soc, build_dir=args.build_dir, do_program=True)