generate linker memory map, move all generated files into the same folder
This commit is contained in:
parent
b95563e45e
commit
fca0b968e7
|
@ -9,8 +9,8 @@ build/*
|
||||||
tools/flterm
|
tools/flterm
|
||||||
tools/mkmscimg
|
tools/mkmscimg
|
||||||
tools/byteswap
|
tools/byteswap
|
||||||
software/include/hw/csr.h
|
software/include/generated/*.h
|
||||||
software/include/hw/sdram_phy.h
|
software/include/generated/*.ld
|
||||||
software/videomixer/dvisampler0.c
|
software/videomixer/dvisampler0.c
|
||||||
software/videomixer/dvisampler0.h
|
software/videomixer/dvisampler0.h
|
||||||
software/videomixer/dvisampler1.c
|
software/videomixer/dvisampler1.c
|
||||||
|
|
6
make.py
6
make.py
|
@ -65,10 +65,12 @@ def main():
|
||||||
*/
|
*/
|
||||||
|
|
||||||
""".format(args.platform, args.target, top_class.__name__)
|
""".format(args.platform, args.target, top_class.__name__)
|
||||||
|
linker_header = cpuif.get_linker_regions(soc.cpu_memory_regions)
|
||||||
|
write_to_file("software/include/generated/regions.ld", boilerplate + linker_header)
|
||||||
csr_header = cpuif.get_csr_header(soc.csr_base, soc.csrbankarray, soc.interrupt_map)
|
csr_header = cpuif.get_csr_header(soc.csr_base, soc.csrbankarray, soc.interrupt_map)
|
||||||
write_to_file("software/include/hw/csr.h", boilerplate + csr_header)
|
write_to_file("software/include/generated/csr.h", boilerplate + csr_header)
|
||||||
sdram_phy_header = initsequence.get_sdram_phy_header(soc.ddrphy)
|
sdram_phy_header = initsequence.get_sdram_phy_header(soc.ddrphy)
|
||||||
write_to_file("software/include/hw/sdram_phy.h", boilerplate + sdram_phy_header)
|
write_to_file("software/include/generated/sdram_phy.h", boilerplate + sdram_phy_header)
|
||||||
if args.csr_csv:
|
if args.csr_csv:
|
||||||
csr_csv = cpuif.get_csr_csv(soc.csr_base, soc.csrbankarray)
|
csr_csv = cpuif.get_csr_csv(soc.csr_base, soc.csrbankarray)
|
||||||
write_to_file(args.csr_csv, csr_csv)
|
write_to_file(args.csr_csv, csr_csv)
|
||||||
|
|
|
@ -29,13 +29,14 @@ class GenSoC(Module):
|
||||||
"m1": 0x4D31
|
"m1": 0x4D31
|
||||||
})
|
})
|
||||||
|
|
||||||
def __init__(self, platform, clk_freq, sram_size, l2_size=0):
|
def __init__(self, platform, clk_freq, cpu_reset_address, sram_size, l2_size=0):
|
||||||
self.clk_freq = clk_freq
|
self.clk_freq = clk_freq
|
||||||
self.sram_size = sram_size
|
self.sram_size = sram_size
|
||||||
self.l2_size = l2_size
|
self.l2_size = l2_size
|
||||||
|
self.cpu_memory_regions = []
|
||||||
|
|
||||||
# Wishbone
|
# Wishbone
|
||||||
self.submodules.cpu = lm32.LM32()
|
self.submodules.cpu = lm32.LM32() # TODO: cpu_reset_address
|
||||||
self.submodules.sram = wishbone.SRAM(sram_size)
|
self.submodules.sram = wishbone.SRAM(sram_size)
|
||||||
self.submodules.wishbone2csr = wishbone2csr.WB2CSR()
|
self.submodules.wishbone2csr = wishbone2csr.WB2CSR()
|
||||||
|
|
||||||
|
@ -47,6 +48,8 @@ class GenSoC(Module):
|
||||||
(lambda a: a[26:29] == 1, self.sram.bus),
|
(lambda a: a[26:29] == 1, self.sram.bus),
|
||||||
(lambda a: a[27:29] == 3, self.wishbone2csr.wishbone)
|
(lambda a: a[27:29] == 3, self.wishbone2csr.wishbone)
|
||||||
]
|
]
|
||||||
|
self.add_cpu_memory_region("rom", cpu_reset_address, 0x8000) # 32KB for BIOS
|
||||||
|
self.add_cpu_memory_region("sram", 0x10000000, sram_size)
|
||||||
|
|
||||||
# CSR
|
# CSR
|
||||||
self.submodules.uart = uart.UART(platform.request("serial"), clk_freq, baud=115200)
|
self.submodules.uart = uart.UART(platform.request("serial"), clk_freq, baud=115200)
|
||||||
|
@ -74,6 +77,9 @@ class GenSoC(Module):
|
||||||
raise FinalizeError
|
raise FinalizeError
|
||||||
self._wb_slaves.append((address_decoder, interface))
|
self._wb_slaves.append((address_decoder, interface))
|
||||||
|
|
||||||
|
def add_cpu_memory_region(self, name, origin, length):
|
||||||
|
self.cpu_memory_regions.append((name, origin, length))
|
||||||
|
|
||||||
def do_finalize(self):
|
def do_finalize(self):
|
||||||
# Wishbone
|
# Wishbone
|
||||||
self.submodules.wishbonecon = wishbone.InterconnectShared(self._wb_masters,
|
self.submodules.wishbonecon = wishbone.InterconnectShared(self._wb_masters,
|
||||||
|
@ -104,8 +110,8 @@ class SDRAMSoC(GenSoC):
|
||||||
}
|
}
|
||||||
csr_map.update(GenSoC.csr_map)
|
csr_map.update(GenSoC.csr_map)
|
||||||
|
|
||||||
def __init__(self, platform, clk_freq, sram_size, l2_size, with_memtest):
|
def __init__(self, platform, clk_freq, cpu_reset_address, sram_size, l2_size, with_memtest):
|
||||||
GenSoC.__init__(self, platform, clk_freq, sram_size, l2_size)
|
GenSoC.__init__(self, platform, clk_freq, cpu_reset_address, sram_size, l2_size)
|
||||||
self.with_memtest = with_memtest
|
self.with_memtest = with_memtest
|
||||||
self._sdram_modules_created = False
|
self._sdram_modules_created = False
|
||||||
|
|
||||||
|
@ -132,6 +138,8 @@ class SDRAMSoC(GenSoC):
|
||||||
# Wishbone bridge: map SDRAM at 0x40000000 (shadow @0xc0000000)
|
# Wishbone bridge: map SDRAM at 0x40000000 (shadow @0xc0000000)
|
||||||
self.submodules.wishbone2lasmi = wishbone2lasmi.WB2LASMI(self.l2_size//4, self.lasmixbar.get_master())
|
self.submodules.wishbone2lasmi = wishbone2lasmi.WB2LASMI(self.l2_size//4, self.lasmixbar.get_master())
|
||||||
self.add_wb_slave(lambda a: a[27:29] == 2, self.wishbone2lasmi.wishbone)
|
self.add_wb_slave(lambda a: a[27:29] == 2, self.wishbone2lasmi.wishbone)
|
||||||
|
self.add_cpu_memory_region("sdram", 0x40000000,
|
||||||
|
2**self.lasmicon.lasmic.aw*self.lasmicon.lasmic.dw*self.lasmicon.lasmic.nbanks//8)
|
||||||
|
|
||||||
def do_finalize(self):
|
def do_finalize(self):
|
||||||
if not self._sdram_modules_created:
|
if not self._sdram_modules_created:
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
from migen.bank.description import CSRStatus
|
from migen.bank.description import CSRStatus
|
||||||
|
|
||||||
|
def get_linker_regions(regions):
|
||||||
|
r = "MEMORY {\n"
|
||||||
|
for name, origin, length in regions:
|
||||||
|
r += "\t{} : ORIGIN = 0x{:08x}, LENGTH = 0x{:08x}\n".format(name, origin, length)
|
||||||
|
r += "}\n"
|
||||||
|
return r
|
||||||
|
|
||||||
def _get_rw_functions(reg_name, reg_base, size, read_only):
|
def _get_rw_functions(reg_name, reg_base, size, read_only):
|
||||||
r = ""
|
r = ""
|
||||||
|
|
||||||
|
@ -39,7 +46,7 @@ def _get_rw_functions(reg_name, reg_base, size, read_only):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def get_csr_header(csr_base, bank_array, interrupt_map):
|
def get_csr_header(csr_base, bank_array, interrupt_map):
|
||||||
r = "#ifndef __HW_CSR_H\n#define __HW_CSR_H\n#include <hw/common.h>\n"
|
r = "#ifndef __GENERATED_CSR_H\n#define __GENERATED_CSR_H\n#include <hw/common.h>\n"
|
||||||
for name, csrs, mapaddr, rmap in bank_array.banks:
|
for name, csrs, mapaddr, rmap in bank_array.banks:
|
||||||
r += "\n/* "+name+" */\n"
|
r += "\n/* "+name+" */\n"
|
||||||
reg_base = csr_base + 0x800*mapaddr
|
reg_base = csr_base + 0x800*mapaddr
|
||||||
|
|
|
@ -4,8 +4,8 @@ def get_sdram_phy_header(sdram_phy):
|
||||||
if sdram_phy.phy_settings.memtype not in ["SDR", "DDR", "LPDDR", "DDR2"]:
|
if sdram_phy.phy_settings.memtype not in ["SDR", "DDR", "LPDDR", "DDR2"]:
|
||||||
raise NotImplementedError("The SDRAM PHY header generator only supports SDR, DDR, LPDDR and DDR2")
|
raise NotImplementedError("The SDRAM PHY header generator only supports SDR, DDR, LPDDR and DDR2")
|
||||||
|
|
||||||
r = "#ifndef __HW_SDRAM_PHY_H\n#define __HW_SDRAM_PHY_H\n"
|
r = "#ifndef __GENERATED_SDRAM_PHY_H\n#define __GENERATED_SDRAM_PHY_H\n"
|
||||||
r += "#include <hw/common.h>\n#include <hw/csr.h>\n#include <hw/flags.h>\n\n"
|
r += "#include <hw/common.h>\n#include <generated/csr.h>\n#include <hw/flags.h>\n\n"
|
||||||
|
|
||||||
r += "static void cdelay(int i);\n"
|
r += "static void cdelay(int i);\n"
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
|
|
||||||
#include <hw/mem.h>
|
#include <hw/mem.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
#include <net/microudp.h>
|
#include <net/microudp.h>
|
||||||
#include <net/tftp.h>
|
#include <net/tftp.h>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,7 @@ ENTRY(_start)
|
||||||
|
|
||||||
__DYNAMIC = 0;
|
__DYNAMIC = 0;
|
||||||
|
|
||||||
MEMORY {
|
INCLUDE generated/regions.ld
|
||||||
rom : ORIGIN = 0x00180000, LENGTH = 0x20000 /* 128K */
|
|
||||||
sram : ORIGIN = 0x10000000, LENGTH = 0x01000 /* 4K */
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <crc.h>
|
#include <crc.h>
|
||||||
|
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/mem.h>
|
#include <hw/mem.h>
|
||||||
#include <net/microudp.h>
|
#include <net/microudp.h>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/sdram_phy.h>
|
#include <generated/sdram_phy.h>
|
||||||
#include <hw/flags.h>
|
#include <hw/flags.h>
|
||||||
#include <hw/mem.h>
|
#include <hw/mem.h>
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ COMMONFLAGS = -Os -mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled -ms
|
||||||
-Wall -fno-builtin -nostdinc -DGIT_ID=$(GIT_ID) $(INCLUDES)
|
-Wall -fno-builtin -nostdinc -DGIT_ID=$(GIT_ID) $(INCLUDES)
|
||||||
CFLAGS = $(COMMONFLAGS) -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
|
CFLAGS = $(COMMONFLAGS) -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
|
||||||
CXXFLAGS = $(COMMONFLAGS) -fno-exceptions -ffreestanding
|
CXXFLAGS = $(COMMONFLAGS) -fno-exceptions -ffreestanding
|
||||||
LDFLAGS = -nostdlib -nodefaultlibs
|
LDFLAGS = -nostdlib -nodefaultlibs -L$(MSCDIR)/software/include
|
||||||
|
|
||||||
# compile and generate dependencies, based on
|
# compile and generate dependencies, based on
|
||||||
# http://scottmcpeak.com/autodepend/autodepend.html
|
# http://scottmcpeak.com/autodepend/autodepend.html
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -3,9 +3,7 @@ ENTRY(_start)
|
||||||
|
|
||||||
__DYNAMIC = 0;
|
__DYNAMIC = 0;
|
||||||
|
|
||||||
MEMORY {
|
INCLUDE generated/regions.ld
|
||||||
sdram : ORIGIN = 0x40000000, LENGTH = 0x08000000 /* 128M */
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
#include <hw/mem.h>
|
#include <hw/mem.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
void flush_cpu_icache(void)
|
void flush_cpu_icache(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
void time_init(void)
|
void time_init(void)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/flags.h>
|
#include <hw/flags.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
#include <crc.h>
|
#include <crc.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/flags.h>
|
#include <hw/flags.h>
|
||||||
#include <hw/mem.h>
|
#include <hw/mem.h>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/flags.h>
|
#include <hw/flags.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
#include "dvisampler0.h"
|
#include "dvisampler0.h"
|
||||||
#include "dvisampler1.h"
|
#include "dvisampler1.h"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/flags.h>
|
#include <hw/flags.h>
|
||||||
|
|
||||||
#include "dvisamplerX.h"
|
#include "dvisamplerX.h"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/flags.h>
|
#include <hw/flags.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
#include "pll.h"
|
#include "pll.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <hw/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/flags.h>
|
#include <hw/flags.h>
|
||||||
|
|
||||||
#include "dvisampler0.h"
|
#include "dvisampler0.h"
|
||||||
|
|
|
@ -45,6 +45,7 @@ class MiniSoC(SDRAMSoC):
|
||||||
def __init__(self, platform, with_memtest=False):
|
def __init__(self, platform, with_memtest=False):
|
||||||
SDRAMSoC.__init__(self, platform,
|
SDRAMSoC.__init__(self, platform,
|
||||||
clk_freq=(83 + Fraction(1, 3))*1000000,
|
clk_freq=(83 + Fraction(1, 3))*1000000,
|
||||||
|
cpu_reset_address=0x00180000,
|
||||||
sram_size=4096,
|
sram_size=4096,
|
||||||
l2_size=8192,
|
l2_size=8192,
|
||||||
with_memtest=with_memtest)
|
with_memtest=with_memtest)
|
||||||
|
|
Loading…
Reference in New Issue