54a4fe6050f97ee5081b853c2dc15e528d44c70f
1 # BlackParrot Chip core support for the LiteX SoC.
3 # Authors: Sadullah Canakci & Cansu Demirkiran <{scanakci,cansu}@bu.edu>
4 # Copyright (c) 2019, Boston University
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
14 # * Redistributions in binary form must reproduce the above
15 # copyright notice, this list of conditions and the following
16 # disclaimer in the documentation and/or other materials provided
17 # with the distribution.
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 from litex
import get_data_mod
36 from litex
.soc
.interconnect
import axi
37 from litex
.soc
.interconnect
import wishbone
38 from litex
.soc
.cores
.cpu
import CPU
, CPU_GCC_TRIPLE_RISCV64
40 CPU_VARIANTS
= ["standard", "sim"]
43 "standard": "-march=rv64ima -mabi=lp64 ",
44 "sim": "-march=rv64ima -mabi=lp64 ",
47 class BlackParrotRV64(CPU
):
49 human_name
= "BlackParrotRV64[ia]"
50 variants
= CPU_VARIANTS
53 gcc_triple
= CPU_GCC_TRIPLE_RISCV64
54 linker_output_format
= "elf64-littleriscv"
56 io_regions
= {0x50000000: 0x10000000} # origin, length
64 "main_ram" : 0x80000000,
69 flags
= "-mno-save-restore "
70 flags
+= GCC_FLAGS
[self
.variant
]
71 flags
+= "-D__blackparrot__ "
74 def __init__(self
, platform
, variant
="standard"):
75 self
.platform
= platform
76 self
.variant
= variant
78 self
.idbus
= idbus
= wishbone
.Interface(data_width
=64, adr_width
=37)
79 self
.periph_buses
= [idbus
]
80 self
.memory_buses
= []
82 self
.cpu_params
= dict(
84 i_clk_i
= ClockSignal(),
85 i_reset_i
= ResetSignal() | self
.reset
,
88 i_wbm_dat_i
= idbus
.dat_r
,
89 o_wbm_dat_o
= idbus
.dat_w
,
90 i_wbm_ack_i
= idbus
.ack
,
91 i_wbm_err_i
= idbus
.err
,
93 o_wbm_adr_o
= idbus
.adr
,
94 o_wbm_stb_o
= idbus
.stb
,
95 o_wbm_cyc_o
= idbus
.cyc
,
96 o_wbm_sel_o
= idbus
.sel
,
97 o_wbm_we_o
= idbus
.we
,
98 o_wbm_cti_o
= idbus
.cti
,
99 o_wbm_bte_o
= idbus
.bte
,
102 # Add verilog sources
106 self
.add_sources(platform
, variant
)
109 print(RED
+ "Please set environment variables first, refer to readme file under litex/soc/cores/cpu/blackparrot for details!")
113 def set_reset_address(self
, reset_address
):
114 assert not hasattr(self
, "reset_address")
115 self
.reset_address
= reset_address
116 assert reset_address
== 0x70000000, "cpu_reset_addr hardcoded to 7x00000000!"
119 def add_sources(platform
, variant
="standard"):
120 vdir
= os
.path
.abspath(os
.path
.dirname(__file__
))
121 bp_litex_dir
= os
.path
.join(vdir
,"bp_litex")
122 filename
= os
.path
.join(bp_litex_dir
, {
123 "standard": "flist.fpga",
124 "sim" : "flist.verilator"
126 with
open(filename
) as openfileobject
:
127 for line
in openfileobject
:
129 if (temp
[0] == '/' and temp
[1] == '/'):
131 elif ("+incdir+" in temp
) :
135 a
= os
.popen('echo '+ str(dir_
))
137 vdir
= dir_start
[:-1] + line
[s2
:-1]
138 platform
.add_verilog_include_path(vdir
)
139 elif (temp
[0]=='$') :
142 a
= os
.popen('echo '+ str(dir_
))
144 vdir
= dir_start
[:-1]+ line
[s2
:-1]
145 platform
.add_source(vdir
, "systemverilog")
146 elif (temp
[0] == '/'):
147 assert("No support for absolute path for now")
149 def do_finalize(self
):
150 assert hasattr(self
, "reset_address")
151 self
.specials
+= Instance("ExampleBlackParrotSystem", **self
.cpu_params
)