Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fmlmeter: add memory address capture support

  • Loading branch information...
commit cb312e3a94201c510e814d5a44b97f16d98d0550 1 parent 2a9a0e3
@sbourdeauducq sbourdeauducq authored
View
6 boards/milkymist-one/rtl/system.v
@@ -1300,7 +1300,8 @@ always @(posedge clk50) phy_clk <= ~phy_clk;
//---------------------------------------------------------------------------
`ifdef ENABLE_FMLMETER
fmlmeter #(
- .csr_addr(4'h9)
+ .csr_addr(4'h9),
+ .fml_depth(`SDRAM_DEPTH)
) fmlmeter (
.sys_clk(sys_clk),
.sys_rst(sys_rst),
@@ -1311,7 +1312,8 @@ fmlmeter #(
.csr_do(csr_dr_fmlmeter),
.fml_stb(fml_stb),
- .fml_ack(fml_ack)
+ .fml_ack(fml_ack),
+ .fml_adr(fml_adr)
);
`else
assign csr_dr_fmlmeter = 32'd0;
View
74 cores/fmlmeter/rtl/fmlmeter.v
@@ -1,6 +1,6 @@
/*
* Milkymist SoC
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,7 +16,8 @@
*/
module fmlmeter #(
- parameter csr_addr = 4'h0
+ parameter csr_addr = 4'h0,
+ parameter fml_depth = 26
) (
input sys_clk,
input sys_rst,
@@ -27,55 +28,88 @@ module fmlmeter #(
output reg [31:0] csr_do,
input fml_stb,
- input fml_ack
+ input fml_ack,
+ input [fml_depth-1:0] fml_adr
);
/* Register the signals we probe to have a minimal impact on timing */
reg fml_stb_r;
reg fml_ack_r;
+reg [fml_depth-1:0] fml_adr_r;
always @(posedge sys_clk) begin
fml_stb_r <= fml_stb;
fml_ack_r <= fml_ack;
+ fml_adr_r <= fml_adr;
end
-reg en; // @ 00
-reg [31:0] stb_count; // @ 04
-reg [31:0] ack_count; // @ 08
+reg counters_en; // @ 00
+reg [31:0] stb_count; // @ 04
+reg [31:0] ack_count; // @ 08
+reg [12:0] capture_wadr; // @ 0c
+reg [11:0] capture_radr; // @ 10
+reg [fml_depth-1:0] capture_do; // @ 14
+
+reg [fml_depth-1:0] capture_mem[0:4095];
+wire capture_en = ~capture_wadr[12];
+wire capture_we = capture_en & fml_stb_r & fml_ack_r;
+wire [11:0] capture_adr = capture_we ? capture_wadr[11:0] : capture_radr;
+wire [fml_depth-1:0] capture_di = fml_adr_r;
+
+always @(posedge sys_clk) begin
+ if(capture_we)
+ capture_mem[capture_adr] <= capture_di;
+ capture_do <= capture_mem[capture_adr];
+end
wire csr_selected = csr_a[13:10] == csr_addr;
always @(posedge sys_clk) begin
if(sys_rst) begin
- en <= 1'b0;
+ counters_en <= 1'b0;
stb_count <= 32'd0;
ack_count <= 32'd0;
+
+ capture_wadr <= 13'd4096;
+ capture_radr <= 12'd0;
csr_do <= 32'd0;
end else begin
- if(en) begin
+ if(counters_en) begin
if(fml_stb_r)
stb_count <= stb_count + 32'd1;
if(fml_ack_r)
ack_count <= ack_count + 32'd1;
end
+
+ if(capture_we)
+ capture_wadr <= capture_wadr + 13'd1;
csr_do <= 32'd0;
if(csr_selected) begin
if(csr_we) begin
- /* Assume all writes are for the ENABLE register
- * (others are read-only)
- */
- en <= csr_di[0];
- if(csr_di[0]) begin
- stb_count <= 32'd0;
- ack_count <= 32'd0;
- end
+ case(csr_a[2:0])
+ 3'b000: begin
+ counters_en <= csr_di[0];
+ if(csr_di[0]) begin
+ stb_count <= 32'd0;
+ ack_count <= 32'd0;
+ end
+ end
+ // 3'b001 stb_count is read-only
+ // 3'b010 ack_count is read-only
+ 3'b011: capture_wadr <= 13'd0;
+ 3'b100: capture_radr <= csr_di[11:0];
+ // 3'b101 capture_do is read-only
+ endcase
end
- case(csr_a[1:0])
- 2'b00: csr_do <= en;
- 2'b01: csr_do <= stb_count;
- 2'b10: csr_do <= ack_count;
+ case(csr_a[3:0])
+ 3'b000: csr_do <= counters_en;
+ 3'b001: csr_do <= stb_count;
+ 3'b010: csr_do <= ack_count;
+ 3'b011: csr_do <= capture_wadr;
+ 3'b100: csr_do <= capture_radr;
+ 3'b101: csr_do <= capture_do;
endcase
end
end
View
22 software/demo/memstats.c
@@ -28,15 +28,15 @@ void memstats_init()
{
last_stb_count = 0;
last_ack_count = 0;
- CSR_FMLMETER_ENABLE = FMLMETER_ENABLE;
+ CSR_FMLMETER_COUNTERS_ENABLE = FMLMETER_COUNTERS_ENABLE;
}
void memstats_tick()
{
- CSR_FMLMETER_ENABLE = 0;
+ CSR_FMLMETER_COUNTERS_ENABLE = 0;
last_stb_count = CSR_FMLMETER_STBCOUNT;
last_ack_count = CSR_FMLMETER_ACKCOUNT;
- CSR_FMLMETER_ENABLE = FMLMETER_ENABLE;
+ CSR_FMLMETER_COUNTERS_ENABLE = FMLMETER_COUNTERS_ENABLE;
}
unsigned int memstat_occupancy()
@@ -59,3 +59,19 @@ unsigned int memstat_amat()
else
return (last_stb_count-last_ack_count)/d;
}
+
+void memstat_capture_start()
+{
+ CSR_FMLMETER_CAPTURE_WADR = 0;
+}
+
+int memstat_capture_ready()
+{
+ return CSR_FMLMETER_CAPTURE_WADR > 4095;
+}
+
+unsigned int memstat_capture_get(int index)
+{
+ CSR_FMLMETER_CAPTURE_RADR = index;
+ return CSR_FMLMETER_CAPTURE_DATA;
+}
View
6 software/demo/memstats.h
@@ -1,6 +1,6 @@
/*
* Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,4 +24,8 @@ unsigned int memstat_occupancy(); /* < Memory bus occupancy in % */
unsigned int memstat_net_bandwidth(); /* < Net bandwidth computed on data actually transferred, Mb/s */
unsigned int memstat_amat(); /* < Average Memory Access Time, in 1/100 cycles */
+void memstat_capture_start();
+int memstat_capture_ready();
+unsigned int memstat_capture_get(int index);
+
#endif /* __MEMSTATS_H */
View
24 software/demo/shell.c
@@ -1,6 +1,6 @@
/*
* Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -311,9 +311,27 @@ static void stats()
}
}
+static void memcapture()
+{
+ int i, j;
+ char buffer[16];
+
+ if(memstat_capture_ready()) {
+ for(i=0;i<4096;i++) {
+ /* send to UART only */
+ sprintf(buffer, "%08x\n", memstat_capture_get(i));
+ j = 0;
+ while(buffer[j])
+ uart_write(buffer[j++]);
+ }
+ memstat_capture_start();
+ } else
+ puts("Still capturing");
+}
+
static void help()
{
- puts("Milkymist(tm) demonstration program (PROOF OF CONCEPT ONLY!)\n");
+ puts("Milkymist(tm) SoC demonstration program\n");
puts("Available commands:");
puts("cons - switch console mode");
puts("ls - list files on the memory card");
@@ -326,6 +344,7 @@ static void help()
puts("renderi - render console input");
puts("stop - stop renderer");
puts("stats - print system stats");
+ puts("memcapture - capture memory transactions");
puts("version - display version");
puts("reboot - system reset");
puts("reconf - reload FPGA configuration");
@@ -978,6 +997,7 @@ static void do_command(char *c)
} else if(strcmp(command, "stop") == 0) renderer_stop();
else if(strcmp(command, "vmode") == 0) vmode(param1);
else if(strcmp(command, "stats") == 0) stats();
+ else if(strcmp(command, "memcapture") == 0) memcapture();
else if(strcmp(command, "version") == 0) puts(VERSION);
else if(strcmp(command, "reboot") == 0) reboot();
else if(strcmp(command, "reconf") == 0) reconf();
View
14 software/include/hw/fmlmeter.h
@@ -1,6 +1,6 @@
/*
* Milkymist SoC (Software)
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,11 +20,15 @@
#include <hw/common.h>
-#define CSR_FMLMETER_ENABLE MMPTR(0xe0009000)
+#define CSR_FMLMETER_COUNTERS_ENABLE MMPTR(0xe0009000)
-#define FMLMETER_ENABLE (0x01)
+#define FMLMETER_COUNTERS_ENABLE (0x01)
-#define CSR_FMLMETER_STBCOUNT MMPTR(0xe0009004)
-#define CSR_FMLMETER_ACKCOUNT MMPTR(0xe0009008)
+#define CSR_FMLMETER_STBCOUNT MMPTR(0xe0009004)
+#define CSR_FMLMETER_ACKCOUNT MMPTR(0xe0009008)
+
+#define CSR_FMLMETER_CAPTURE_WADR MMPTR(0xe000900c)
+#define CSR_FMLMETER_CAPTURE_RADR MMPTR(0xe0009010)
+#define CSR_FMLMETER_CAPTURE_DATA MMPTR(0xe0009014)
#endif /* __HW_FMLMETER_H */
Please sign in to comment.
Something went wrong with that request. Please try again.