Skip to content

Commit 989fd78

Browse files
Yvan Tortorellabelanoa
authored andcommitted
Use DPI to dynamically infer the entry point and set the boot address.
1 parent a83ac61 commit 989fd78

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tb/pulp_cluster_tb.sv

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
`include "axi/typedef.svh"
2222

2323
import "DPI-C" function read_elf(input string filename);
24+
import "DPI-C" function get_entry(output longint entry_ret);
2425
import "DPI-C" function byte get_section(output longint address, output longint len);
2526
import "DPI-C" context function byte read_section(input longint address, inout byte buffer[], input longint len);
2627

@@ -64,7 +65,7 @@ module pulp_cluster_tb;
6465
localparam bit[AxiAw-1:0] L2BaseAddr = 'h1C000000;
6566
localparam bit[AxiAw-1:0] L2Size = 'h00100000;
6667
localparam bit[AxiAw-1:0] BootAddr = L2BaseAddr + 'h8080;
67-
localparam bit[AxiAw-1:0] ClustReturnInt = 'h10200100;
68+
localparam bit[AxiAw-1:0] ClustReturnInt = ClustBase + ClustPeriphOffs + 'h100;
6869

6970
typedef logic [AxiAw-1:0] axi_addr_t;
7071
typedef logic [AxiDw-1:0] axi_data_t;
@@ -425,12 +426,14 @@ module pulp_cluster_tb;
425426

426427
// Load ELF binary file
427428
task load_binary;
428-
input string binary; // File name
429-
addr_t section_addr, section_len;
430-
byte buffer[];
429+
input string binary; // File name
430+
output addr_t entry_point;
431+
addr_t section_addr, section_len;
432+
byte buffer[];
431433

432434
// Read ELF
433435
void'(read_elf(binary));
436+
get_entry(entry_point);
434437
$display("[TB] Reading %s", binary);
435438
while (get_section(section_addr, section_len)) begin
436439
// Read Sections
@@ -472,6 +475,7 @@ module pulp_cluster_tb;
472475
// Start writing to SRAM
473476
logic [32:0] addr;
474477
logic [AxiDw-1:0] ret_val;
478+
logic [31:0] boot_addr;
475479

476480
initial begin
477481

@@ -486,7 +490,7 @@ module pulp_cluster_tb;
486490
if ( $value$plusargs ("APP=%s", binary));
487491
$display("[TB] Testing %s", binary);
488492

489-
load_binary(binary);
493+
load_binary(binary, boot_addr);
490494

491495
foreach (sections[addr]) begin
492496
$display("[TB] Writing %h with %0d words", addr << 3, sections[addr]); // word = 8 bytes here
@@ -534,7 +538,7 @@ module pulp_cluster_tb;
534538
aw_beat.ax_burst = axi_pkg::BURST_INCR;
535539
aw_beat.ax_size = 4'h3;
536540

537-
w_beat.w_data = BootAddr;
541+
w_beat.w_data = boot_addr;
538542
w_beat.w_strb = 'h1;
539543
w_beat.w_last = 'h1;
540544

0 commit comments

Comments
 (0)