1 # This file is Copyright (c) 2019 Florent Kermarrec <florent@enjoy-digital.fr>
2 # This file is Copyright (c) 2019 Benjamin Herrenschmidt <benh@ozlabs.org>
9 from litex
import get_data_mod
10 from litex
.soc
.interconnect
import wishbone
11 from litex
.soc
.cores
.cpu
import CPU
14 CPU_VARIANTS
= ["standard"]
19 human_name
= "Microwatt"
22 gcc_triple
= ("powerpc64le-linux")
23 linker_output_format
= "elf64-powerpcle"
24 io_regions
= {0xc0000000: 0x10000000} # origin, length
28 return {"csr": 0xc0000000}
33 flags
+= "-mabi=elfv2 "
34 flags
+= "-msoft-float "
35 flags
+= "-mno-string "
36 flags
+= "-mno-multiple "
38 flags
+= "-mno-altivec "
39 flags
+= "-mlittle-endian "
40 flags
+= "-mstrict-align "
41 flags
+= "-D__microwatt__ "
44 def __init__(self
, platform
, variant
="standard"):
45 assert variant
in CPU_VARIANTS
, "Unsupported variant %s" % variant
46 self
.platform
= platform
47 self
.variant
= variant
49 self
.wb_insn
= wb_insn
= wishbone
.Interface(data_width
=64, adr_width
=28)
50 self
.wb_data
= wb_data
= wishbone
.Interface(data_width
=64, adr_width
=28)
51 self
.periph_buses
= [wb_insn
, wb_data
]
52 self
.memory_buses
= []
56 self
.cpu_params
= dict(
58 i_clk
= ClockSignal(),
59 i_rst
= ResetSignal() | self
.reset
,
61 # Wishbone instruction bus
62 i_wishbone_insn_dat_r
= wb_insn
.dat_r
,
63 i_wishbone_insn_ack
= wb_insn
.ack
,
64 i_wishbone_insn_stall
= wb_insn
.cyc
& ~wb_insn
.ack
, # No burst support
66 o_wishbone_insn_adr
= Cat(Signal(4), wb_insn
.adr
),
67 o_wishbone_insn_dat_w
= wb_insn
.dat_w
,
68 o_wishbone_insn_cyc
= wb_insn
.cyc
,
69 o_wishbone_insn_stb
= wb_insn
.stb
,
70 o_wishbone_insn_sel
= wb_insn
.sel
,
71 o_wishbone_insn_we
= wb_insn
.we
,
74 i_wishbone_data_dat_r
= wb_data
.dat_r
,
75 i_wishbone_data_ack
= wb_data
.ack
,
76 i_wishbone_data_stall
= wb_data
.cyc
& ~wb_data
.ack
, # No burst support
78 o_wishbone_data_adr
= Cat(Signal(4), wb_data
.adr
),
79 o_wishbone_data_dat_w
= wb_data
.dat_w
,
80 o_wishbone_data_cyc
= wb_data
.cyc
,
81 o_wishbone_data_stb
= wb_data
.stb
,
82 o_wishbone_data_sel
= wb_data
.sel
,
83 o_wishbone_data_we
= wb_data
.we
,
95 self
.add_sources(platform
)
97 def set_reset_address(self
, reset_address
):
98 assert not hasattr(self
, "reset_address")
99 self
.reset_address
= reset_address
100 assert reset_address
== 0x00000000
103 def add_sources(platform
):
105 get_data_mod("cpu", "microwatt").data_location
,
107 platform
.add_sources(sdir
,
108 # Common / Types / Helpers
110 "wishbone_types.vhdl",
119 # Instruction/Data Cache
134 "register_file.vhdl",
159 platform
.add_source(os
.path
.join(sdir
, "..", "microwatt_wrapper.vhdl"))
161 def do_finalize(self
):
162 self
.specials
+= Instance("microwatt_wrapper", **self
.cpu_params
)