diff --git a/.gitmodules b/.gitmodules
index 6fba9eca6..9b5c03e8a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,8 +4,8 @@
[submodule "misoc/cores/mor1kx/verilog"]
path = misoc/cores/mor1kx/verilog
url = https://github.com/openrisc/mor1kx.git
-[submodule "misoc/software/compiler-rt"]
- path = misoc/software/compiler-rt
+[submodule "misoc/software/compiler_rt"]
+ path = misoc/software/compiler_rt
url = http://llvm.org/git/compiler-rt.git
[submodule "misoc/software/unwinder"]
path = misoc/software/unwinder
diff --git a/crc.py b/crc.py
deleted file mode 100644
index 60efbabc0..000000000
--- a/crc.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import binascii
-
-
-def insert_crc(i_filename, fbi_mode=False, o_filename=None):
- if o_filename is None:
- o_filename = i_filename
-
- with open(i_filename, 'rb') as f:
- fdata = f.read()
- fcrc = binascii.crc32(fdata).to_bytes(4, byteorder="big")
- flength = len(fdata).to_bytes(4, byteorder="big")
-
- with open(o_filename, 'wb') as f:
- if fbi_mode:
- f.write(flength)
- f.write(fcrc)
- f.write(fdata)
- else:
- f.write(fdata)
- f.write(fcrc)
diff --git a/flash_extra.py b/flash_extra.py
deleted file mode 100755
index d27a4a25e..000000000
--- a/flash_extra.py
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-import sys
-import argparse
-
-from migen.util.misc import autotype
-
-from misoc_import import misoc_import
-
-if __name__ == "__main__":
- parser = argparse.ArgumentParser(description="Program extra data to flash memory.")
- parser.add_argument("-f", "--flash-proxy-dir", default=None, help="set search directory for flash proxy bitstreams")
- parser.add_argument("-X", "--external", default="", help="use external directory for platforms and imports")
- parser.add_argument("-Op", "--platform-option", default=[], nargs=2, action="append", help="set platform-specific option")
- parser.add_argument("platform", help="target platform")
- parser.add_argument("file", help="file to flash")
- parser.add_argument("address", help="flash address to write")
- args = parser.parse_args()
-
- external_platform = ""
- if args.external:
- external_platform = os.path.join(args.external, "platforms")
- sys.path.insert(1, os.path.abspath(args.external))
-
- platform_module = misoc_import("mibuild.platforms", external_platform, args.platform)
- platform_kwargs = dict((k, autotype(v)) for k, v in args.platform_option)
- platform = platform_module.Platform(**platform_kwargs)
-
- prog = platform.create_programmer()
- prog.set_flash_proxy_dir(args.flash_proxy_dir)
- prog.flash(int(args.address, 0), args.file)
diff --git a/make.py b/make.py
deleted file mode 100755
index 206ac0957..000000000
--- a/make.py
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-import os
-import argparse
-import subprocess
-import struct
-
-from migen.build.tools import write_to_file
-from migen.util.misc import autotype
-from migen.fhdl import simplify
-
-from misoc.integration import cpu_interface
-from misoc.integration import sdram_init
-
-from misoc_import import misoc_import
-
-
-def _get_args():
- parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
- description="""\
-MiSoC - a high performance and small footprint SoC based on Migen.
-
-This program builds and/or loads MiSoC components.
-One or several actions can be specified:
-
-clean delete previous build(s).
-build-bitstream build FPGA bitstream. Implies build-bios on targets with
- integrated BIOS.
-build-headers build software header files with CPU/CSR/IRQ/SDRAM_PHY definitions.
-build-csr-csv save CSR map into CSV file.
-build-bios build BIOS. Implies build-header.
-
-load-bitstream load bitstream into volatile storage.
-flash-bitstream load bitstream into non-volatile storage.
-flash-bios load BIOS into non-volatile storage.
-
-all clean, build-bitstream, build-bios, flash-bitstream, flash-bios.
-
-Load/flash actions use the existing outputs, and do not trigger new builds.
-""")
-
- parser.add_argument("-t", "--target", default="mlabs_video", help="SoC type to build")
- parser.add_argument("-s", "--sub-target", default="", help="variant of the SoC type to build")
- parser.add_argument("-p", "--platform", default=None, help="platform to build for")
- parser.add_argument("-Ot", "--target-option", default=[], nargs=2, action="append", help="set target-specific option")
- parser.add_argument("-Op", "--platform-option", default=[], nargs=2, action="append", help="set platform-specific option")
- parser.add_argument("-X", "--external", default="", help="use external directory for targets, platforms and imports")
- parser.add_argument("--csr_csv", default="csr.csv", help="CSV file to save the CSR map into")
-
- parser.add_argument("-d", "--decorate", default=[], action="append", help="apply simplification decorator to top-level")
- parser.add_argument("-Ob", "--build-option", default=[], nargs=2, action="append", help="set build option")
- parser.add_argument("-f", "--flash-proxy-dir", default=None, help="set search directory for flash proxy bitstreams")
-
- parser.add_argument("action", nargs="+", help="specify an action")
-
- return parser.parse_args()
-
-if __name__ == "__main__":
- args = _get_args()
-
- external_target = ""
- external_platform = ""
- if args.external:
- external_target = os.path.join(args.external, "targets")
- external_platform = os.path.join(args.external, "platforms")
- sys.path.insert(0, os.path.abspath(args.external))
-
- # create top-level SoC object
- target_module = misoc_import("targets", external_target, args.target)
- if args.sub_target:
- top_class = getattr(target_module, args.sub_target)
- else:
- top_class = target_module.default_subtarget
-
- if args.platform is None:
- if hasattr(top_class, "default_platform"):
- platform_name = top_class.default_platform
- else:
- raise ValueError("Target has no default platform, specify a platform with -p your_platform")
- else:
- platform_name = args.platform
- platform_module = misoc_import("migen.build.platforms", external_platform, platform_name)
- platform_kwargs = dict((k, autotype(v)) for k, v in args.platform_option)
- platform = platform_module.Platform(**platform_kwargs)
- if args.external:
- platform.soc_ext_path = os.path.abspath(args.external)
-
- build_name = args.target + "-" + top_class.__name__.lower() + "-" + platform_name
- top_kwargs = dict((k, autotype(v)) for k, v in args.target_option)
- soc = top_class(platform, **top_kwargs)
- soc.finalize()
- memory_regions = soc.get_memory_regions()
- csr_regions = soc.get_csr_regions()
-
- # decode actions
- action_list = ["clean", "build-bitstream", "build-headers", "build-csr-csv", "build-bios",
- "load-bitstream", "flash-bitstream", "flash-bios", "all"]
- actions = {k: False for k in action_list}
- for action in args.action:
- if action in actions:
- actions[action] = True
- else:
- print("Unknown action: {}. Valid actions are:".format(action))
- for a in action_list:
- print(" "+a)
- sys.exit(1)
-
- print("""\
- __ ___ _ ____ _____
- / |/ / (_) / __/__ / ___/
- / /|_/ / / / _\ \/ _ \/ /__
- /_/ /_/ /_/ /___/\___/\___/
-
-a high performance and small footprint SoC based on Migen
-
-====== Building for: ======
-Platform: {}
-Target: {}
-Subtarget: {}
-CPU type: {}
-===========================""".format(platform_name, args.target, top_class.__name__, soc.cpu_type))
-
- # dependencies
- if actions["all"]:
- actions["clean"] = True
- actions["build-bitstream"] = True
- actions["build-bios"] = True
- if not actions["load-bitstream"]:
- actions["flash-bitstream"] = True
- if not soc.integrated_rom_size:
- actions["flash-bios"] = True
- if actions["build-bitstream"] and soc.integrated_rom_size:
- actions["build-bios"] = True
- if actions["build-bios"]:
- actions["build-headers"] = True
-
- if actions["clean"]:
- subprocess.check_call("rm -rvf build/*", shell=True) # Need shell for the build/* globbing
- subprocess.check_call(["make", "-C", os.path.join("software", "libcompiler-rt"), "clean"])
- subprocess.check_call(["make", "-C", os.path.join("software", "libbase"), "clean"])
- subprocess.check_call(["make", "-C", os.path.join("software", "libnet"), "clean"])
- subprocess.check_call(["make", "-C", os.path.join("software", "bios"), "clean"])
-
- if actions["build-headers"]:
- boilerplate = """/*
- * Platform: {}
- * Target: {}
- * Subtarget: {}
- * CPU type: {}
- */
-
-""".format(platform_name, args.target, top_class.__name__, soc.cpu_type)
- genhdir = os.path.join("software", "include", "generated")
- if soc.cpu_type != "none":
- cpu_mak = cpu_interface.get_cpu_mak(soc.cpu_type)
- write_to_file(os.path.join(genhdir, "cpu.mak"), cpu_mak)
- linker_output_format = cpu_interface.get_linker_output_format(soc.cpu_type)
- write_to_file(os.path.join(genhdir, "output_format.ld"), linker_output_format)
-
- linker_regions = cpu_interface.get_linker_regions(memory_regions)
- write_to_file(os.path.join(genhdir, "regions.ld"), boilerplate + linker_regions)
-
- for sdram_phy in ["sdrphy", "ddrphy"]:
- if hasattr(soc, sdram_phy):
- sdram_phy_header = sdram_init.get_sdram_phy_header(getattr(soc, sdram_phy).settings)
- write_to_file(os.path.join(genhdir, "sdram_phy.h"), boilerplate + sdram_phy_header)
- mem_header = cpu_interface.get_mem_header(memory_regions, getattr(soc, "flash_boot_address", None))
- write_to_file(os.path.join(genhdir, "mem.h"), boilerplate + mem_header)
- csr_header = cpu_interface.get_csr_header(csr_regions, sorted(soc.get_constants()))
- write_to_file(os.path.join(genhdir, "csr.h"), boilerplate + csr_header)
-
- if actions["build-csr-csv"]:
- csr_csv = cpu_interface.get_csr_csv(csr_regions)
- write_to_file(args.csr_csv, csr_csv)
-
- if actions["build-bios"]:
- ret = subprocess.call(["make", "-C", os.path.join("software", "bios")])
- if ret:
- raise OSError("BIOS build failed")
-
- bios_file = os.path.join("software", "bios", "bios.bin")
-
- if actions["build-bitstream"]:
- if soc.integrated_rom_size:
- with open(bios_file, "rb") as boot_file:
- boot_data = []
- while True:
- w = boot_file.read(4)
- if not w:
- break
- boot_data.append(struct.unpack(">I", w)[0])
- soc.init_rom(boot_data)
-
- for decorator in args.decorate:
- soc = getattr(simplify, decorator)(soc)
- build_kwargs = dict((k, autotype(v)) for k, v in args.build_option)
- vns = platform.build(soc, build_name=build_name, **build_kwargs)
- soc.do_exit(vns)
-
- if actions["load-bitstream"]:
- prog = platform.create_programmer()
- prog.load_bitstream(os.path.join("build", build_name + platform.bitstream_ext))
-
- if actions["flash-bitstream"]:
- prog = platform.create_programmer()
- prog.set_flash_proxy_dir(args.flash_proxy_dir)
- if prog.needs_bitreverse:
- flashbit = os.path.join("build", build_name + ".fpg")
- subprocess.check_call([os.path.join("tools", "byteswap"),
- os.path.join("build", build_name + ".bin"),
- flashbit])
- else:
- flashbit = os.path.join("build", build_name + ".bin")
- prog.flash(0, flashbit)
-
- if actions["flash-bios"]:
- prog = platform.create_programmer()
- prog.set_flash_proxy_dir(args.flash_proxy_dir)
- prog.flash(soc.cpu_reset_address, bios_file)
diff --git a/misoc/cores/identifier.py b/misoc/cores/identifier.py
index 22c8c893e..5088fd32c 100644
--- a/misoc/cores/identifier.py
+++ b/misoc/cores/identifier.py
@@ -1,28 +1,16 @@
-import subprocess
-
from migen import *
from misoc.interconnect.csr import *
-def get_id():
- output = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii")
- return int(output[:8], 16)
-
-
class Identifier(Module, AutoCSR):
def __init__(self, sysid, frequency, revision=None):
self._sysid = CSRStatus(16)
- self._revision = CSRStatus(32)
self._frequency = CSRStatus(32)
###
- if revision is None:
- revision = get_id()
-
self.comb += [
self._sysid.status.eq(sysid),
- self._revision.status.eq(revision),
self._frequency.status.eq(frequency)
]
diff --git a/misoc/integration/builder.py b/misoc/integration/builder.py
new file mode 100644
index 000000000..0e1ed054f
--- /dev/null
+++ b/misoc/integration/builder.py
@@ -0,0 +1,114 @@
+import os
+import subprocess
+import struct
+
+from misoc.integration import cpu_interface, sdram_init
+
+
+# in build order (for dependencies)
+misoc_software_packages = [
+ "libbase",
+ "libcompiler_rt",
+ "libdyld",
+ "libnet",
+ "libunwind",
+ "bios"
+]
+
+
+misoc_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+
+
+class Builder:
+ def __init__(self, soc, output_dir):
+ self.soc = soc
+ # From Python doc: makedirs() will become confused if the path
+ # elements to create include '..'
+ self.output_dir = os.path.abspath(output_dir)
+
+ self.software_packages = []
+ for name in misoc_software_packages:
+ self.add_software_package(
+ name, os.path.join(misoc_directory, "software", name))
+
+ def add_software_package(self, name, src_dir):
+ self.software_packages.append((name, src_dir))
+
+ def _generate_includes(self):
+ cpu_type = self.soc.cpu_type
+ memory_regions = self.soc.get_memory_regions()
+ flash_boot_address = getattr(self.soc, "flash_boot_address", None)
+ csr_regions = self.soc.get_csr_regions()
+ constants = self.soc.get_constants()
+ # TODO: cleanup
+ sdram_phy_settings = None
+ for sdram_phy in "sdrphy", "ddrphy":
+ if hasattr(self.soc, sdram_phy):
+ sdram_phy_settings = getattr(self.soc, sdram_phy).settings
+
+ buildinc_dir = os.path.join(self.output_dir, "software", "include")
+ generated_dir = os.path.join(buildinc_dir, "generated")
+ os.makedirs(generated_dir, exist_ok=True)
+ with open(os.path.join(generated_dir, "variables.mak"), "w") as f:
+ def define(k, v):
+ f.write("{}={}\n".format(k, v))
+ for k, v in cpu_interface.get_cpu_mak(cpu_type):
+ define(k, v)
+ define("MISOC_DIRECTORY", misoc_directory)
+ define("BUILDINC_DIRECTORY", buildinc_dir)
+ for name, src_dir in self.software_packages:
+ define(name.upper() + "_DIRECTORY", src_dir)
+
+ with open(os.path.join(generated_dir, "output_format.ld"), "w") as f:
+ f.write(cpu_interface.get_linker_output_format(cpu_type))
+ with open(os.path.join(generated_dir, "regions.ld"), "w") as f:
+ f.write(cpu_interface.get_linker_regions(memory_regions))
+
+ with open(os.path.join(generated_dir, "mem.h"), "w") as f:
+ f.write(cpu_interface.get_mem_header(memory_regions, flash_boot_address))
+ with open(os.path.join(generated_dir, "csr.h"), "w") as f:
+ f.write(cpu_interface.get_csr_header(csr_regions, constants))
+
+ if sdram_phy_settings is not None:
+ with open(os.path.join(generated_dir, "sdram_phy.h"), "w") as f:
+ f.write(sdram_init.get_sdram_phy_header(sdram_phy_settings))
+
+ def _generate_software(self, compile):
+ for name, src_dir in self.software_packages:
+ dst_dir = os.path.join(self.output_dir, "software", name)
+ os.makedirs(dst_dir, exist_ok=True)
+ src = os.path.join(src_dir, "Makefile")
+ dst = os.path.join(dst_dir, "Makefile")
+ try:
+ os.remove(dst)
+ except FileNotFoundError:
+ pass
+ os.symlink(src, dst)
+ if compile:
+ subprocess.check_call(["make", "-C", dst_dir])
+
+ def _initialize_rom(self):
+ bios_file = os.path.join(self.output_dir, "software" "bios",
+ "bios.bin")
+ if self.soc.integrated_rom_size:
+ with open(bios_file, "rb") as boot_file:
+ boot_data = []
+ while True:
+ w = boot_file.read(4)
+ if not w:
+ break
+ boot_data.append(struct.unpack(">I", w)[0])
+ self.soc.initialize_rom(boot_data)
+
+ def build(self, compile_software=True, compile_gateware=True):
+ self.soc.finalize()
+
+ if self.soc.integrated_rom_size and not compile_software:
+ raise ValueError("Software must be compiled in order to "
+ "intitialize integrated ROM")
+
+ self._generate_includes()
+ self._generate_software(compile_software)
+ self._initialize_rom()
+ self.soc.build(build_dir=os.path.join(self.output_dir, "gateware"),
+ run=compile_gateware)
diff --git a/misoc/integration/cpu_interface.py b/misoc/integration/cpu_interface.py
index 1aa96f327..0514b4ee7 100644
--- a/misoc/integration/cpu_interface.py
+++ b/misoc/integration/cpu_interface.py
@@ -3,18 +3,23 @@ from migen import *
from misoc.interconnect.csr import CSRStatus
-def get_cpu_mak(cpu_type):
- if cpu_type == "lm32":
+def get_cpu_mak(cpu):
+ if cpu == "lm32":
triple = "lm32-elf"
cpuflags = "-mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled -msign-extend-enabled"
clang = ""
- elif cpu_type == "or1k":
+ elif cpu == "or1k":
triple = "or1k-linux"
cpuflags = "-mhard-mul -mhard-div -mror -mffl1 -maddc"
clang = "1"
else:
- raise ValueError("Unsupported CPU type: "+cpu_type)
- return "TRIPLE={}\nCPU={}\nCPUFLAGS={}\nCLANG={}".format(triple, cpu_type, cpuflags, clang)
+ raise ValueError("Unsupported CPU type: "+cpu)
+ return [
+ ("TRIPLE", triple),
+ ("CPU", cpu),
+ ("CPUFLAGS", cpuflags),
+ ("CLANG", clang)
+ ]
def get_linker_output_format(cpu_type):
diff --git a/misoc/integration/soc_core.py b/misoc/integration/soc_core.py
index 93d085253..0264d7fb6 100644
--- a/misoc/integration/soc_core.py
+++ b/misoc/integration/soc_core.py
@@ -116,7 +116,7 @@ class SoCCore(Module):
raise NotImplementedError("More than one CPU is not supported")
self.submodules.cpu_or_bridge = cpu_or_bridge
- def init_rom(self, data):
+ def initialize_rom(self, data):
self.rom.mem.init = data
def add_wb_master(self, wbm):
@@ -200,3 +200,6 @@ class SoCCore(Module):
for k, v in sorted(self.interrupt_map.items(), key=itemgetter(1)):
if hasattr(self, k):
self.comb += self.cpu_or_bridge.interrupt[v].eq(getattr(self, k).ev.irq)
+
+ def build(self, *args, **kwargs):
+ self.platform.build(self, *args, **kwargs)
diff --git a/misoc/software/bios/Makefile b/misoc/software/bios/Makefile
index bd849f07b..067ab4f5a 100644
--- a/misoc/software/bios/Makefile
+++ b/misoc/software/bios/Makefile
@@ -1,5 +1,5 @@
-MSCDIR=../..
-include $(MSCDIR)/software/common.mak
+include ../include/generated/variables.mak
+include $(MISOC_DIRECTORY)/software/common.mak
OBJECTS=isr.o sdram.o main.o boot-helper-$(CPU).o boot.o dataflow.o
@@ -11,35 +11,30 @@ all: bios.bin
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
chmod -x $@
- $(MSCDIR)/mkmscimg.py $@
+ $(PYTHON) -m misoc.tools.mkmscimg $@
-bios.elf: linker.ld $(OBJECTS) libs
+bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS)
%.elf:
$(LD) $(LDFLAGS) -T $< -N -o $@ \
- $(MSCDIR)/software/libbase/crt0-$(CPU).o \
+ ../libbase/crt0-$(CPU).o \
$(OBJECTS) \
- -L$(MSCDIR)/software/libnet \
- -L$(MSCDIR)/software/libbase \
- -L$(MSCDIR)/software/libcompiler-rt \
- -lnet -lbase-nofloat -lcompiler-rt
+ -L../libnet \
+ -L../libbase \
+ -L../libcompiler_rt \
+ -lnet -lbase-nofloat -lcompiler_rt
chmod -x $@
-main.o: main.c
+main.o: $(BIOS_DIRECTORY)/main.c
$(compile-dep)
-%.o: %.c
+%.o: $(BIOS_DIRECTORY)/%.c
$(compile-dep)
-%.o: %.S
+%.o: $(BIOS_DIRECTORY)/%.S
$(assemble)
-libs:
- $(MAKE) -C $(MSCDIR)/software/libcompiler-rt
- $(MAKE) -C $(MSCDIR)/software/libbase
- $(MAKE) -C $(MSCDIR)/software/libnet
-
clean:
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) bios.elf bios.bin .*~ *~
-.PHONY: all main.o clean libs
+.PHONY: all main.o clean
diff --git a/misoc/software/bios/main.c b/misoc/software/bios/main.c
index 389314144..1316665bd 100644
--- a/misoc/software/bios/main.c
+++ b/misoc/software/bios/main.c
@@ -377,8 +377,6 @@ static void do_command(char *c)
else if(strcmp(token, "netboot") == 0) netboot();
#endif
- else if(strcmp(token, "revision") == 0) printf("%08x\n", MSC_GIT_ID);
-
else if(strcmp(token, "help") == 0) help();
#ifdef __lm32__
@@ -535,9 +533,9 @@ int main(int i, char **c)
irq_setmask(0);
irq_setie(1);
uart_init();
- puts("\nMiSoC BIOS http://m-labs.hk\n"
- "(c) Copyright 2007-2014 Sebastien Bourdeauducq");
- printf("Revision %08x built "__DATE__" "__TIME__"\n\n", MSC_GIT_ID);
+ puts("\nMiSoC BIOS\n"
+ "(c) Copyright 2007-2015 M-Labs Limited\n"
+ "Built "__DATE__" "__TIME__"\n");
crcbios();
id_print();
#ifdef CSR_ETHMAC_BASE
diff --git a/misoc/software/common.mak b/misoc/software/common.mak
index 053ace1cb..78c537ca5 100644
--- a/misoc/software/common.mak
+++ b/misoc/software/common.mak
@@ -1,4 +1,3 @@
-include $(MSCDIR)/software/include/generated/cpu.mak
TARGET_PREFIX=$(TRIPLE)-
RM ?= rm -f
@@ -21,8 +20,6 @@ AR_quiet = @echo " AR " $@ && $(AR_normal)
LD_quiet = @echo " LD " $@ && $(LD_normal)
OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(OBJCOPY_normal)
-MSC_GIT_ID := $(shell cd $(MSCDIR) && $(PYTHON) -c "from misoc.cores.identifier import get_id; print(hex(get_id()), end='')")
-
ifeq ($(V),1)
CC = $(CC_normal)
CX = $(CX_normal)
@@ -39,11 +36,11 @@ endif
# Toolchain options
#
-INCLUDES = -I$(MSCDIR)/software/include/base -I$(MSCDIR)/software/include -I$(MSCDIR)/common
-COMMONFLAGS = -Os $(CPUFLAGS) -fomit-frame-pointer -Wall -fno-builtin -nostdinc -DMSC_GIT_ID=$(MSC_GIT_ID) $(INCLUDES)
+INCLUDES = -I$(MISOC_DIRECTORY)/software/include/base -I$(MISOC_DIRECTORY)/software/include -I$(MISOC_DIRECTORY)/common -I$(BUILDINC_DIRECTORY)
+COMMONFLAGS = -Os $(CPUFLAGS) -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES)
CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
-CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(MSCDIR)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
-LDFLAGS = -nostdlib -nodefaultlibs -L$(MSCDIR)/software/include
+CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(MISOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
+LDFLAGS = -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY)
# compile and generate dependencies, based on
# http://scottmcpeak.com/autodepend/autodepend.html
diff --git a/misoc/software/compiler-rt b/misoc/software/compiler_rt
similarity index 100%
rename from misoc/software/compiler-rt
rename to misoc/software/compiler_rt
diff --git a/misoc/software/libbase/Makefile b/misoc/software/libbase/Makefile
index c1f2434df..bf48b25af 100644
--- a/misoc/software/libbase/Makefile
+++ b/misoc/software/libbase/Makefile
@@ -1,5 +1,5 @@
-MSCDIR=../..
-include $(MSCDIR)/software/common.mak
+include ../include/generated/variables.mak
+include $(MISOC_DIRECTORY)/software/common.mak
OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o system.o id.o uart.o time.o qsort.o strtod.o spiflash.o
@@ -14,13 +14,13 @@ libbase.a: $(OBJECTS) vsnprintf.o
libbase-nofloat.a: $(OBJECTS) vsnprintf-nofloat.o
$(AR) crs libbase-nofloat.a $(OBJECTS) vsnprintf-nofloat.o
-vsnprintf-nofloat.o: vsnprintf.c
+vsnprintf-nofloat.o: $(LIBBASE_DIRECTORY)/vsnprintf.c
$(call compile-dep,-DNO_FLOAT)
-%.o: %.c
+%.o: $(LIBBASE_DIRECTORY)/%.c
$(compile-dep)
-%.o: %.S
+%.o: $(LIBBASE_DIRECTORY)/%.S
$(assemble)
.PHONY: clean
diff --git a/misoc/software/libbase/id.c b/misoc/software/libbase/id.c
index 254aa55cc..034ddfa56 100644
--- a/misoc/software/libbase/id.c
+++ b/misoc/software/libbase/id.c
@@ -16,5 +16,5 @@ void id_print(void)
char sysid[3];
get_sysid_formatted(sysid);
- printf("Running on MiSoC rev. %08x (sysid:%s) at %dMHz\n", identifier_revision_read(), sysid, identifier_frequency_read()/1000000);
+ printf("Running on MiSoC (sysid:%s) at %dMHz\n", sysid, identifier_frequency_read()/1000000);
}
diff --git a/misoc/software/libcompiler-rt/Makefile b/misoc/software/libcompiler_rt/Makefile
similarity index 71%
rename from misoc/software/libcompiler-rt/Makefile
rename to misoc/software/libcompiler_rt/Makefile
index 917c0aee4..2637ce1d5 100644
--- a/misoc/software/libcompiler-rt/Makefile
+++ b/misoc/software/libcompiler_rt/Makefile
@@ -1,5 +1,5 @@
-MSCDIR=../..
-include $(MSCDIR)/software/common.mak
+include ../include/generated/variables.mak
+include $(MISOC_DIRECTORY)/software/common.mak
CFLAGS+=-D_YUGA_LITTLE_ENDIAN=0 -D_YUGA_BIG_ENDIAN=1 -Wno-missing-prototypes
@@ -7,18 +7,18 @@ OBJECTS=divsi3.o modsi3.o comparedf2.o negsf2.o negdf2.o addsf3.o subsf3.o mulsf
floatsisf.o floatunsisf.o fixsfsi.o fixdfdi.o fixunssfsi.o adddf3.o subdf3.o muldf3.o divdf3.o floatsidf.o floatunsidf.o floatdidf.o fixdfsi.o fixunsdfsi.o \
clzsi2.o ctzsi2.o udivdi3.o umoddi3.o moddi3.o ucmpdi2.o
-all: libcompiler-rt.a
+all: libcompiler_rt.a
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)
-libcompiler-rt.a: $(OBJECTS)
- $(AR) crs libcompiler-rt.a $(OBJECTS)
+libcompiler_rt.a: $(OBJECTS)
+ $(AR) crs libcompiler_rt.a $(OBJECTS)
-%.o: $(MSCDIR)/software/compiler-rt/lib/builtins/%.c
+%.o: $(MISOC_DIRECTORY)/software/compiler_rt/lib/builtins/%.c
$(compile-dep)
.PHONY: clean
clean:
- $(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libcompiler-rt.a .*~ *~
+ $(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libcompiler_rt.a .*~ *~
diff --git a/misoc/software/libdyld/Makefile b/misoc/software/libdyld/Makefile
index 27a29db89..9dcac10ce 100644
--- a/misoc/software/libdyld/Makefile
+++ b/misoc/software/libdyld/Makefile
@@ -1,7 +1,7 @@
-MSCDIR=../..
-include $(MSCDIR)/software/common.mak
+include ../include/generated/variables.mak
+include $(MISOC_DIRECTORY)/software/common.mak
-COMMONFLAGS += -I$(MSCDIR)/software/include/dyld
+COMMONFLAGS += -I$(MISOC_DIRECTORY)/software/include/dyld
OBJECTS=dyld.o
@@ -13,6 +13,9 @@ all: libdyld.a
libdyld.a: $(OBJECTS)
$(AR) crs libdyld.a $(OBJECTS)
+%.o: $(LIBDYLD_DIRECTORY)/%.c
+ $(compile-dep)
+
.PHONY: clean
clean:
diff --git a/misoc/software/libnet/Makefile b/misoc/software/libnet/Makefile
index dc2a28362..d38ef5b5d 100644
--- a/misoc/software/libnet/Makefile
+++ b/misoc/software/libnet/Makefile
@@ -1,5 +1,5 @@
-MSCDIR=../..
-include $(MSCDIR)/software/common.mak
+include ../include/generated/variables.mak
+include $(MISOC_DIRECTORY)/software/common.mak
OBJECTS=microudp.o tftp.o
@@ -11,7 +11,7 @@ all: libnet.a
libnet.a: $(OBJECTS)
$(AR) crs libnet.a $(OBJECTS)
-%.o: %.c
+%.o: $(LIBNET_DIRECTORY)/%.c
$(compile-dep)
%.o: %.S
diff --git a/misoc/software/libunwind/Makefile b/misoc/software/libunwind/Makefile
index 579ad4dae..26ae44aca 100644
--- a/misoc/software/libunwind/Makefile
+++ b/misoc/software/libunwind/Makefile
@@ -1,8 +1,9 @@
-MSCDIR=../..
-include $(MSCDIR)/software/common.mak
+include ../include/generated/variables.mak
+include $(MISOC_DIRECTORY)/software/common.mak
COMMONFLAGS+=-integrated-as \
- -I. -I$(MSCDIR)/software/include/dyld/ -I$(MSCDIR)/software/unwinder/include/ \
+ -I. -I$(MISOC_DIRECTORY)/software/include/dyld/ -I$(MISOC_DIRECTORY)/software/unwinder/include/ \
+ -I$(LIBUNWIND_DIRECTORY) \
-D__ELF__ -D__linux__ -D_LIBUNWIND_NO_HEAP -DNDEBUG
OBJECTS=UnwindRegistersSave.o UnwindRegistersRestore.o UnwindLevel1.o libunwind.o
@@ -15,16 +16,16 @@ all: libunwind.a
libunwind.a: $(OBJECTS)
$(AR) crs libunwind.a $(OBJECTS)
-%.o: $(MSCDIR)/software/unwinder/src/%.cpp
+%.o: $(MISOC_DIRECTORY)/software/unwinder/src/%.cpp
$(compilexx-dep)
-%.o: $(MSCDIR)/software/unwinder/src/%.c
+%.o: $(MISOC_DIRECTORY)/software/unwinder/src/%.c
$(compile-dep)
-%.o: $(MSCDIR)/software/unwinder/src/%.S
+%.o: $(MISOC_DIRECTORY)/software/unwinder/src/%.S
$(assemble)
.PHONY: clean
clean:
- $(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libuwind.a .*~ *~
+ $(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libunwind.a .*~ *~
diff --git a/targets/__init__.py b/misoc/targets/__init__.py
similarity index 100%
rename from targets/__init__.py
rename to misoc/targets/__init__.py
diff --git a/targets/de0nano.py b/misoc/targets/de0nano.py
old mode 100644
new mode 100755
similarity index 100%
rename from targets/de0nano.py
rename to misoc/targets/de0nano.py
diff --git a/targets/kc705.py b/misoc/targets/kc705.py
old mode 100644
new mode 100755
similarity index 100%
rename from targets/kc705.py
rename to misoc/targets/kc705.py
diff --git a/targets/minispartan6.py b/misoc/targets/minispartan6.py
old mode 100644
new mode 100755
similarity index 100%
rename from targets/minispartan6.py
rename to misoc/targets/minispartan6.py
diff --git a/targets/mlabs_video.py b/misoc/targets/mlabs_video.py
old mode 100644
new mode 100755
similarity index 100%
rename from targets/mlabs_video.py
rename to misoc/targets/mlabs_video.py
diff --git a/targets/ppro.py b/misoc/targets/papilio_pro.py
old mode 100644
new mode 100755
similarity index 93%
rename from targets/ppro.py
rename to misoc/targets/papilio_pro.py
index ac236b985..25e003d56
--- a/targets/ppro.py
+++ b/misoc/targets/papilio_pro.py
@@ -1,13 +1,17 @@
+#!/usr/bin/env python3
+
from fractions import Fraction
from migen import *
from migen.genlib.resetsync import AsyncResetSynchronizer
+from migen.build.platforms import papilio_pro
from misoc.cores.sdram_settings import MT48LC4M16
from misoc.cores.sdram_phy import GENSDRPHY
from misoc.cores.lasmicon.core import LASMIconSettings
from misoc.cores import spi_flash
from misoc.integration.soc_sdram import SoCSDRAM
+from misoc.integration.builder import Builder
class _CRG(Module):
@@ -62,8 +66,6 @@ class _CRG(Module):
class BaseSoC(SoCSDRAM):
- default_platform = "papilio_pro"
-
csr_map = {
"spiflash": 16,
}
@@ -89,4 +91,12 @@ class BaseSoC(SoCSDRAM):
self.flash_boot_address = 0x70000
self.register_rom(self.spiflash.bus)
-default_subtarget = BaseSoC
+
+def main():
+ soc = BaseSoC(papilio_pro.Platform(), cpu_type="or1k")
+ builder = Builder(soc, "misoc_build")
+ builder.build()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/targets/pipistrello.py b/misoc/targets/pipistrello.py
old mode 100644
new mode 100755
similarity index 100%
rename from targets/pipistrello.py
rename to misoc/targets/pipistrello.py
diff --git a/targets/simple.py b/misoc/targets/simple.py
old mode 100644
new mode 100755
similarity index 100%
rename from targets/simple.py
rename to misoc/targets/simple.py
diff --git a/targets/versa.py b/misoc/targets/versa.py
old mode 100644
new mode 100755
similarity index 100%
rename from targets/versa.py
rename to misoc/targets/versa.py
diff --git a/misoc/tools/__init__.py b/misoc/tools/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tools/flterm.py b/misoc/tools/flterm.py
similarity index 99%
rename from tools/flterm.py
rename to misoc/tools/flterm.py
index 2bebbe600..cafe7a903 100644
--- a/tools/flterm.py
+++ b/misoc/tools/flterm.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
+
import sys
import os
import time
diff --git a/misoc/tools/mkmscimg.py b/misoc/tools/mkmscimg.py
new file mode 100755
index 000000000..751e9e535
--- /dev/null
+++ b/misoc/tools/mkmscimg.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import argparse
+import binascii
+
+
+def insert_crc(i_filename, fbi_mode=False, o_filename=None):
+ if o_filename is None:
+ o_filename = i_filename
+
+ with open(i_filename, "rb") as f:
+ fdata = f.read()
+ fcrc = binascii.crc32(fdata).to_bytes(4, byteorder="big")
+ flength = len(fdata).to_bytes(4, byteorder="big")
+
+ with open(o_filename, "wb") as f:
+ if fbi_mode:
+ f.write(flength)
+ f.write(fcrc)
+ f.write(fdata)
+ else:
+ f.write(fdata)
+ f.write(fcrc)
+
+
+def main():
+ parser = argparse.ArgumentParser(description="CRC32 computation tool and MiSoC image file writer.")
+ parser.add_argument("input", help="input file")
+ parser.add_argument("-o", "--output", default=None, help="output file (if not specified, use input file)")
+ parser.add_argument("-f", "--fbi", default=False, action="store_true", help="build flash boot image (FBI) file")
+ args = parser.parse_args()
+ insert_crc(args.input, args.fbi, args.output)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/misoc_import.py b/misoc_import.py
deleted file mode 100644
index 6bbf263a9..000000000
--- a/misoc_import.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import sys
-import importlib
-
-
-def misoc_import(default, external, name):
- if external:
- try:
- del sys.modules[name] # force external path search
- except KeyError:
- pass
- loader = importlib.find_loader(name, [external])
- if loader is None:
- # try internal import
- return importlib.import_module(default + "." + name)
- return loader.load_module()
- else:
- return importlib.import_module(default + "." + name)
diff --git a/mkmscimg.py b/mkmscimg.py
deleted file mode 100755
index dd78d4aac..000000000
--- a/mkmscimg.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-import crc
-
-if __name__ == "__main__":
- parser = argparse.ArgumentParser(description="CRC32 computation tool and MiSoC image file writer.")
- parser.add_argument("input", help="input file")
- parser.add_argument("-o", "--output", default=None, help="output file (if not specified, use input file)")
- parser.add_argument("-f", "--fbi", default=False, action="store_true", help="build flash boot image (FBI) file")
- args = parser.parse_args()
- crc.insert_crc(args.input, args.fbi, args.output)
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
diff --git a/tools/Makefile b/tools/Makefile
deleted file mode 100644
index bc53c4753..000000000
--- a/tools/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGETS=byteswap
-CC=gcc
-RM ?= rm -f
-
-all: $(TARGETS)
-
-%: %.c
- $(CC) -O2 -Wall -I../common -s -o $@ $<
-
-.PHONY: all clean
-
-clean:
- $(RM) $(TARGETS)
diff --git a/tools/byteswap.c b/tools/byteswap.c
deleted file mode 100644
index 3e16236b2..000000000
--- a/tools/byteswap.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * MiSoC
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-int main(int argc, char *argv[])
-{
- FILE *fdi, *fdo;
- unsigned short wi;
- unsigned short wo;
- int i;
-
- if(argc != 3) {
- fprintf(stderr, "Usage: byteswap \n");
- return 1;
- }
- fdi = fopen(argv[1], "rb");
- if(!fdi) {
- perror("Unable to open input file");
- return 1;
- }
- fdo = fopen(argv[2], "w");
- if(!fdo) {
- perror("Unable to open output file");
- fclose(fdi);
- return 1;
- }
- while(1) {
- if(fread(&wi, 2, 1, fdi) <= 0) break;
- wo = 0;
- for(i=0;i<16;i++)
- if(wi & (1 << i))
- wo |= (0x8000 >> i);
- /* comment out the next line on big endian machines! */
- wo = ((wo & 0x00ff) << 8) | ((wo & 0xff00) >> 8);
- fwrite(&wo, 2, 1, fdo);
- }
- fclose(fdi);
- if(fclose(fdo) != 0) {
- perror("Unable to close output file");
- return 1;
- }
- return 0;
-}