1 //////////////////////////////////////////////////////////////////////
7 //// Logs the signals 'trig0', 'data0', data1, ... ////
8 //// after a trigger event has occurred. ////
10 //// WB interface: ////
11 //// Write Address 0x0000, Arm the trigger ////
12 //// Read Address 0x0000 - 0x03ff, Read trig0 trace log ////
13 //// Read Address 0x0400 - 0x07ff, Read data0 trace log ////
14 //// Read Address 0x0800 - 0x0bff, Read data1 trace log ////
15 //// Read Address 0x0C00 - 0x0fff, Read data2 trace log ////
18 //// - Stefan Kristiansson, stefan.kristiansson@saunalahti.fi ////
20 //////////////////////////////////////////////////////////////////////
22 //// Copyright (C) 2011 Authors and OPENCORES.ORG ////
24 //// This source file may be used and distributed without ////
25 //// restriction provided that this copyright statement is not ////
26 //// removed from the file and that any derivative work contains ////
27 //// the original copyright notice and the associated disclaimer. ////
29 //// This source file is free software; you can redistribute it ////
30 //// and/or modify it under the terms of the GNU Lesser General ////
31 //// Public License as published by the Free Software Foundation; ////
32 //// either version 2.1 of the License, or (at your option) any ////
33 //// later version. ////
35 //// This source is distributed in the hope that it will be ////
36 //// useful, but WITHOUT ANY WARRANTY; without even the implied ////
37 //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
38 //// PURPOSE. See the GNU Lesser General Public License for more ////
41 //// You should have received a copy of the GNU Lesser General ////
42 //// Public License along with this source; if not, download it ////
43 //// from http://www.opencores.org/lgpl.shtml ////
45 //////////////////////////////////////////////////////////////////////
52 input wire [31:0] wb_dat_i,
53 input wire [13:2] wb_adr_i,
54 input wire [3:0] wb_sel_i,
58 output wire [31:0] wb_dat_o,
64 input wire [31:0] trig0_i,
65 input wire [31:0] data0_i,
66 input wire [31:0] data1_i,
67 input wire [31:0] data2_i
69 //--------------------------------------------------------------------------
71 //--------------------------------------------------------------------------
79 assign wb_dat_o = (wb_adr_i[13:12] == 2'b00) ? trig0_rd :
80 (wb_adr_i[13:12] == 2'b01) ? data0_rd :
81 (wb_adr_i[13:12] == 2'b10) ? data1_rd :
82 (wb_adr_i[13:12] == 2'b11) ? data2_rd :
86 always @(posedge wb_clk_i) begin
89 trigger <= 32'h00000000;
90 else if (wb_stb_i & wb_cyc_i & wb_we_i)
91 if (wb_adr_i == 0) begin
98 always @(posedge wb_clk_i)
103 else if (wb_cyc_i & wb_stb_i & !wb_ack_o)
110 //--------------------------------------------------------------------------
112 //--------------------------------------------------------------------------
117 always @(posedge wb_clk_i)
118 if (wb_rst_i | new_trig)
120 else if (trig0_i == trigger)
123 always @(posedge wb_clk_i)
124 if (wb_rst_i | new_trig)
126 else if (running & !(&mem_pos))
127 mem_pos <= mem_pos + 1;
129 always @(posedge wb_clk_i)
130 if (wb_rst_i | new_trig)
136 //--------------------------------------------------------------------------
137 // Logging logic (Block RAM's)
138 //--------------------------------------------------------------------------
139 reg [31:0] trig0_mem[1023:0];
140 reg [31:0] data0_mem[1023:0];
141 reg [31:0] data1_mem[1023:0];
142 reg [31:0] data2_mem[1023:0];
150 assign wr_addr = mem_pos;
151 assign wr_en = running & !done;
153 always @(posedge wb_clk_i) begin
160 always @(posedge wb_clk_i) begin
162 trig0_mem[wr_addr] <= trig0_q;
163 data0_mem[wr_addr] <= data0_q;
164 data1_mem[wr_addr] <= data1_q;
165 data2_mem[wr_addr] <= data2_q;
167 trig0_rd <= trig0_mem[wb_adr_i[11:2]];
168 data0_rd <= data0_mem[wb_adr_i[11:2]];
169 data1_rd <= data1_mem[wb_adr_i[11:2]];
170 data2_rd <= data2_mem[wb_adr_i[11:2]];