// LLRF history buffers for test submodule // Larry Doolittle, LBNL, March 2003 // See history2k.v for its care and feeding // 2K x 14 buffer, programmable averaging `timescale 1ns / 1ns module hist4( clk40, in_data, trace_address, write_enable, clear, clk_host, host_dout, host_addr); input clk40; input [11:0] in_data; input [10:0] trace_address; input write_enable, clear; input clk_host; output [13:0] host_dout; input [11:0] host_addr; wire [13:0] recirc; // convert from offset binary, and then sign extend from 12 to 14 bits wire [13:0] extend_in = {{3{~in_data[11]}},in_data[10:0]}; wire [13:0] sum = clear ? in_data : (in_data+recirc); ramdp2048x14 trace1( .ADDRA(trace_address), .RSTA(1'b0), .ENA(1'b1), .WEA(write_enable), .CLKA(clk40), .DIA(sum), //.DOA(void), // read from host .ADDRB(host_addr[10:0]), .RSTB(1'b0), .ENB(1'b1), .WEB(1'b0), // host write not allowed .CLKB(clk_host), .DIB(14'b000000000000), // not used .DOB(host_dout)); // four-deep FIFO srl16x14e fifo( .Q(recirc), .A0(1'b1), .A1(1'b1), .A2(1'b0), .A3(1'b0), .CE(write_enable), .CLK(clk40), .D(sum)); endmodule