Skip to content

Commit a67e564

Browse files
da-gazzibelanoa
authored andcommitted
fix printing from all cores
1 parent 535e930 commit a67e564

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

tb/mock_uart.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module mock_uart #(
6060

6161
function void uart_tx(byte ch);
6262
if(ch==8'h0A) begin
63-
$display("[TB UART] %s", stringa);
63+
$display("[TB UART %2d] %s", UART_IDX, stringa);
6464
charnum = 0;
6565
stringa = '0;
6666
end else begin

tb/mock_uart_axi.sv

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,25 @@ module mock_uart_axi #(
1616
parameter int unsigned AxiIw = 0,
1717
parameter int unsigned AxiAw = 0,
1818
parameter int unsigned AxiDw = 0,
19-
parameter int unsigned AxiUw = 0
19+
parameter int unsigned AxiUw = 0,
20+
parameter logic [AxiAw-1:0] BaseAddr = 0,
21+
parameter int unsigned N_CORES = 8
22+
2023
)(
2124
input logic clk_i,
2225
input logic rst_ni,
2326
input logic test_i,
2427
AXI_BUS.Slave uart
2528
);
26-
27-
logic uart_penable;
28-
logic uart_pwrite;
29-
logic [AxiAw-1:0] uart_paddr;
30-
logic uart_psel;
31-
logic [31:0] uart_pwdata;
32-
logic [31:0] uart_prdata;
33-
logic uart_pready;
34-
logic uart_pslverr;
29+
30+
logic uart_penable;
31+
logic uart_pwrite;
32+
logic [AxiAw-1:0] uart_paddr;
33+
logic [N_CORES-1:0] uart_psel;
34+
logic [31:0] uart_pwdata;
35+
logic [N_CORES-1:0] [31:0] uart_prdata;
36+
logic [N_CORES-1:0] uart_pready;
37+
logic [N_CORES-1:0] uart_pslverr;
3538

3639
AXI_LITE #(
3740
.AXI_DATA_WIDTH(AxiDw),
@@ -77,12 +80,15 @@ module mock_uart_axi #(
7780
logic [AxiAw-1:0] end_addr;
7881
} rule_t;
7982

80-
rule_t [0:0] rule;
81-
assign rule[0] = '{0, '0, '1};
82-
83+
rule_t [0:N_CORES-1] rule;
84+
// each mock UART only has 2 words of address space
85+
for (genvar g=0; g<N_CORES; g++) begin
86+
assign rule[g] = '{g, BaseAddr + 8*g, BaseAddr + 8*(g+1)-1};
87+
end
88+
8389
axi_lite_to_apb_intf #(
84-
.NoApbSlaves (1),
85-
.NoRules (1),
90+
.NoApbSlaves (N_CORES),
91+
.NoRules (N_CORES),
8692
.AddrWidth (AxiAw),
8793
.DataWidth (32),
8894
.PipelineRequest (1'b0),
@@ -106,17 +112,22 @@ module mock_uart_axi #(
106112
);
107113

108114
/* pragma translate_off */
109-
mock_uart i_mock_uart0 (
110-
.clk_i ( clk_i ),
111-
.rst_ni ( rst_ni ),
112-
.penable_i ( uart_penable ),
113-
.pwrite_i ( uart_pwrite ),
114-
.paddr_i ( uart_paddr[31:0] ),
115-
.psel_i ( uart_psel ),
116-
.pwdata_i ( uart_pwdata ),
117-
.prdata_o ( uart_prdata ),
118-
.pready_o ( uart_pready ),
119-
.pslverr_o ( uart_pslverr )
120-
);
115+
for (genvar g=0; g<N_CORES; g++) begin
116+
// one mock UART per core
117+
mock_uart #(
118+
.UART_IDX( g )
119+
) i_mock_uart0 (
120+
.clk_i ( clk_i ),
121+
.rst_ni ( rst_ni ),
122+
.penable_i( uart_penable ),
123+
.pwrite_i ( uart_pwrite ),
124+
.paddr_i ( uart_paddr[31:0] - g*8 ), // Mock UART expects to be addressed starting at 0
125+
.psel_i ( uart_psel[g] ),
126+
.pwdata_i ( uart_pwdata ),
127+
.prdata_o ( uart_prdata[g] ),
128+
.pready_o ( uart_pready[g] ),
129+
.pslverr_o( uart_pslverr[g] )
130+
);
131+
end
121132

122133
endmodule

tb/pulp_cluster_tb.sv

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,12 @@ module pulp_cluster_tb;
176176
);
177177

178178
mock_uart_axi #(
179-
.AxiIw ( AxiIwMst ),
180-
.AxiAw ( AxiAw ),
181-
.AxiDw ( AxiDw ),
182-
.AxiUw ( AxiUw )
179+
.AxiIw ( AxiIwMst ),
180+
.AxiAw ( AxiAw ),
181+
.AxiDw ( AxiDw ),
182+
.AxiUw ( AxiUw ),
183+
.N_CORES ( 8 ),
184+
.BaseAddr( 32'h4000_0000 )
183185
) i_mock_uart (
184186
.clk_i ( s_clk ),
185187
.rst_ni ( s_rstn ),

0 commit comments

Comments
 (0)