2020
2121# Variants -----------------------------------------------------------------------------------------
2222
23- CPU_VARIANTS = ["minimal" , "standard" ]
23+ CPU_VARIANTS = ["minimal" , "standard" , "standard+atomic" , "standard+atomic+float+double" ]
2424
2525# GCC Flags ----------------------------------------------------------------------------------------
2626
3434 # i macfd
3535 "minimal" : "-march=rv32i2p0 -mabi=ilp32 " ,
3636 "standard" : "-march=rv32i2p0_m -mabi=ilp32 " ,
37+ "standard+atomic" : "-march=rv32i2p0_ma -mabi=ilp32 " ,
38+ "standard+atomic+float+double" : "-march=rv32i2p0_mafd -mabi=ilp32 " ,
3739}
3840
3941# CVA5 ----------------------------------------------------------------------------------------------
@@ -62,7 +64,7 @@ def args_fill(parser):
6264 cpu_group = parser .add_argument_group (title = "CPU options" )
6365 cpu_group .add_argument ("--cpu-count" , default = 1 , help = "Number of CPU(s) in the cluster." , type = int )
6466 cpu_group .add_argument ("--clint-base" , default = "0xf0010000" , help = "CLINT base address." )
65- cpu_group .add_argument ("--plic-base" , default = "0xf8000000 " , help = "PLIC base address." )
67+ cpu_group .add_argument ("--plic-base" , default = "0xf800_0000 " , help = "PLIC base address." )
6668 cpu_group .add_argument ("--bus-type" , default = "wishbone" , help = "Bus type can be either wishbone or axi" )
6769 cpu_group .add_argument ("--variant" , default = "Linux" , help = "The CPU type for now it has the linux type" )#TODO add other configs
6870
@@ -90,7 +92,10 @@ def mem_map(self):
9092 @property
9193 def gcc_flags (self ):
9294 flags = GCC_FLAGS [self .variant ]
93- flags += "-D__riscv_plic__"
95+ if (CVA5 .cpu_variant == "Linux" ):
96+ flags += "-D__riscv_plic__"
97+ else :
98+ flags += "-D__cva5__"
9499 return flags
95100
96101 def __init__ (self , platform , variant = "standard" ):
@@ -101,6 +106,7 @@ def __init__(self, platform, variant="standard"):
101106 self .interrupt = Signal (2 )
102107 self .periph_buses = [] # Peripheral buses (Connected to main SoC's bus).
103108 self .memory_buses = [] # Memory buses (Connected directly to LiteDRAM).
109+ self .reset = Signal ()
104110
105111 # CPU Instance.
106112 self .cpu_params = dict (
@@ -113,7 +119,7 @@ def __init__(self, platform, variant="standard"):
113119
114120 # Clk/Rst.
115121 i_clk = ClockSignal ("sys" ),
116- i_rst = ResetSignal ("sys" ),
122+ i_rst = ResetSignal ("sys" ) | self . reset ,
117123 )
118124
119125 if (CVA5 .bus_type == "wishbone" ):
@@ -209,67 +215,74 @@ def add_soc_components(self, soc):
209215 meip = Signal (int (self .cpu_params ["p_NUM_CORES" ]))
210216 eip = Signal (2 * int (self .cpu_params ["p_NUM_CORES" ]))
211217 es = Signal (2 , reset = 0 )
212- if (CVA5 .bus_type == "wishbone" ):
213- self .plicbus = plicbus = wishbone .Interface (data_width = 32 , address_width = 32 , addressing = "word" )
214- self .specials += Instance ("plic_wrapper" ,
215- p_NUM_SOURCES = 1 ,
216- p_NUM_TARGETS = 2 * int (self .cpu_params ["p_NUM_CORES" ]),
217- p_PRIORITY_W = 8 ,
218- p_REG_STAGE = 1 ,
219- p_AXI = 0 ,
220- i_clk = ClockSignal ("sys" ),
221- i_rst = ResetSignal ("sys" ),
222- i_irq_srcs = self .interrupt ,
223- i_edge_sensitive = es ,
224- o_eip = eip ,
225- i_wb_cyc = plicbus .cyc ,
226- i_wb_stb = plicbus .stb ,
227- i_wb_we = plicbus .we ,
228- i_wb_adr = plicbus .adr ,
229- i_wb_dat_i = plicbus .dat_w ,
230- o_wb_dat_o = plicbus .dat_r ,
231- o_wb_ack = plicbus .ack ,
218+
219+ if (CVA5 .cpu_variant == "Linux" ):
220+ if (CVA5 .bus_type == "wishbone" ):
221+ self .plicbus = plicbus = wishbone .Interface (data_width = 32 , address_width = 32 , addressing = "word" )
222+ self .specials += Instance ("plic_wrapper" ,
223+ p_NUM_SOURCES = 1 ,
224+ p_NUM_TARGETS = 2 * int (self .cpu_params ["p_NUM_CORES" ]),
225+ p_PRIORITY_W = 8 ,
226+ p_REG_STAGE = 1 ,
227+ p_AXI = 0 ,
228+ i_clk = ClockSignal ("sys" ),
229+ i_rst = ResetSignal ("sys" ),
230+ i_irq_srcs = self .interrupt ,
231+ i_edge_sensitive = es ,
232+ o_eip = eip ,
233+ i_wb_cyc = plicbus .cyc ,
234+ i_wb_stb = plicbus .stb ,
235+ i_wb_we = plicbus .we ,
236+ i_wb_adr = plicbus .adr ,
237+ i_wb_dat_i = plicbus .dat_w ,
238+ o_wb_dat_o = plicbus .dat_r ,
239+ o_wb_ack = plicbus .ack ,
240+ )
241+ else :
242+ self .plicbus = plicbus = axi .AXIInterface (data_width = 32 , address_width = 32 , id_width = 4 )
243+ self .specials += Instance ("plic_wrapper" ,
244+ p_NUM_SOURCES = 1 ,
245+ p_NUM_TARGETS = 2 * int (self .cpu_params ["p_NUM_CORES" ]),
246+ p_PRIORITY_W = 8 ,
247+ p_REG_STAGE = 1 ,
248+ p_AXI = 1 ,
249+ i_clk = ClockSignal ("sys" ),
250+ i_rst = ResetSignal ("sys" ),
251+ i_irq_srcs = self .interrupt ,
252+ i_edge_sensitive = es ,
253+ o_eip = eip ,
254+ i_s_axi_awvalid = plicbus .aw .valid ,
255+ i_s_axi_awaddr = plicbus .aw .addr ,
256+ i_s_axi_wvalid = plicbus .w .valid ,
257+ i_s_axi_wdata = plicbus .w .data ,
258+ i_s_axi_bready = plicbus .b .ready ,
259+ i_s_axi_arvalid = plicbus .ar .valid ,
260+ i_s_axi_araddr = plicbus .ar .addr ,
261+ i_s_axi_rready = plicbus .r .ready ,
262+ o_s_axi_awready = plicbus .aw .ready ,
263+ o_s_axi_wready = plicbus .w .ready ,
264+ o_s_axi_bvalid = plicbus .b .valid ,
265+ o_s_axi_arready = plicbus .ar .ready ,
266+ o_s_axi_rvalid = plicbus .r .valid ,
267+ o_s_axi_rdata = plicbus .r .data
268+ )
269+
270+ self .comb += [
271+ meip .eq (Cat (* [eip [i * 2 ] for i in range (int (self .cpu_params ["p_NUM_CORES" ]))])),
272+ seip .eq (Cat (* [eip [i * 2 + 1 ] for i in range (int (self .cpu_params ["p_NUM_CORES" ]))]))
273+ ]
274+
275+ self .cpu_params .update (
276+ i_seip = seip ,
277+ i_meip = meip
232278 )
279+ soc .bus .add_slave ("plic" , self .plicbus , region = SoCRegion (origin = self .plic_base , size = 0x40_0000 , cached = False ))
233280 else :
234- self .plicbus = plicbus = axi .AXIInterface (data_width = 32 , address_width = 32 , id_width = 4 )
235- self .specials += Instance ("plic_wrapper" ,
236- p_NUM_SOURCES = 1 ,
237- p_NUM_TARGETS = 2 * int (self .cpu_params ["p_NUM_CORES" ]),
238- p_PRIORITY_W = 8 ,
239- p_REG_STAGE = 1 ,
240- p_AXI = 1 ,
241- i_clk = ClockSignal ("sys" ),
242- i_rst = ResetSignal ("sys" ),
243- i_irq_srcs = self .interrupt ,
244- i_edge_sensitive = es ,
245- o_eip = eip ,
246- i_s_axi_awvalid = plicbus .aw .valid ,
247- i_s_axi_awaddr = plicbus .aw .addr ,
248- i_s_axi_wvalid = plicbus .w .valid ,
249- i_s_axi_wdata = plicbus .w .data ,
250- i_s_axi_bready = plicbus .b .ready ,
251- i_s_axi_arvalid = plicbus .ar .valid ,
252- i_s_axi_araddr = plicbus .ar .addr ,
253- i_s_axi_rready = plicbus .r .ready ,
254- o_s_axi_awready = plicbus .aw .ready ,
255- o_s_axi_wready = plicbus .w .ready ,
256- o_s_axi_bvalid = plicbus .b .valid ,
257- o_s_axi_arready = plicbus .ar .ready ,
258- o_s_axi_rvalid = plicbus .r .valid ,
259- o_s_axi_rdata = plicbus .r .data
281+ self .cpu_params .update (
282+ i_meip = self .interrupt [0 ]
260283 )
261284
262- self .comb += [
263- meip .eq (Cat (* [eip [i * 2 ] for i in range (int (self .cpu_params ["p_NUM_CORES" ]))])),
264- seip .eq (Cat (* [eip [i * 2 + 1 ] for i in range (int (self .cpu_params ["p_NUM_CORES" ]))]))
265- ]
266-
267- self .cpu_params .update (
268- i_seip = seip ,
269- i_meip = meip
270- )
271285
272- soc .bus .add_slave ("plic" , self .plicbus , region = SoCRegion (origin = self .plic_base , size = 0x40_0000 , cached = False ))
273286
274287 # CLINT
275288 if (CVA5 .cpu_variant == "Linux" ):
@@ -324,5 +337,9 @@ def add_soc_components(self, soc):
324337 i_msip = msip ,
325338 i_mtip = mtip
326339 )
340+ soc .bus .add_slave ("clint" , clintbus , region = SoCRegion (origin = self .clint_base , size = 0x1_0000 , cached = False ))
341+ else :
342+ self .cpu_params .update (
343+ i_mtip = self .interrupt [1 ]
344+ )
327345
328- soc .bus .add_slave ("clint" , clintbus , region = SoCRegion (origin = self .clint_base , size = 0x1_0000 , cached = False ))
0 commit comments