OpenCores
URL https://opencores.org/ocsvn/alternascope/alternascope/trunk

Subversion Repositories alternascope

[/] [alternascope/] [trunk/] [AdcDriver/] [d_Driver_RamBuffer.v] - Diff between revs 17 and 18

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 17 Rev 18
//==================================================================
//==================================================================
// File:    d_Driver_RamBuffer.v
// File:    d_Driver_RamBuffer.v
// Version: 0.01
// Version: 0.01
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Copyright Stephen Pickett
// Copyright Stephen Pickett
//   April 28, 2005
//   April 28, 2005
//------------------------------------------------------------------
//------------------------------------------------------------------
// Revisions:
// Revisions:
// Ver 0.01     Apr 28, 2005    Initial Release
// Ver 0.01     Apr 28, 2005    Initial Release
//
//
//==================================================================
//==================================================================
 
 
module ADCDataBuffer(
module ADCDataBuffer(
    CLK_64MHZ, MASTER_RST,
    CLK_64MHZ, MASTER_RST,
    CLK180_64MHZ,
    CLK180_64MHZ,
    TIME_BASE,
    TIME_BASE,
    RAM_ADDR, RAM_DATA, RAM_CLK,
    RAM_ADDR, RAM_DATA, RAM_CLK,
    ADC_DATA, ADC_CLK,
    ADC_DATA, ADC_CLK,
    TRIG_ADDR,
    TRIG_ADDR,
    VGA_WRITE_DONE,
    VGA_WRITE_DONE,
    TRIGGER_LEVEL,
    TRIGGER_LEVEL,
    sm_trig
    sm_trig
    );
    );
 
 
//==================================================================//
//==================================================================//
// PARAMETER DEFINITIONS                                            //
// PARAMETER DEFINITIONS                                            //
//==================================================================//
//==================================================================//
parameter ss_wait_for_trig  = 2'b00;
parameter ss_wait_for_trig  = 2'b00;
parameter ss_fill_mem_half  = 2'b01;
parameter ss_fill_mem_half  = 2'b01;
parameter ss_write_buffer   = 2'b11;
parameter ss_write_buffer   = 2'b11;
parameter ss_invalid        = 2'b10;
parameter ss_invalid        = 2'b10;
parameter P_trigger_level   = 8'h80;
parameter P_trigger_level   = 8'h80;
 
 
 
 
 
 
 
 
//==================================================================//
//==================================================================//
// VARIABLE DEFINITIONS                                             //
// VARIABLE DEFINITIONS                                             //
//==================================================================//
//==================================================================//
 
 
//----------------------//
//----------------------//
// INPUTS / OUTPUTS     //
// INPUTS / OUTPUTS     //
//----------------------//
//----------------------//
input        CLK_64MHZ;
input        CLK_64MHZ;
input        CLK180_64MHZ;
input        CLK180_64MHZ;
input        MASTER_RST;         // Global Asyncronous Reset
input        MASTER_RST;         // Global Asyncronous Reset
input[5:0]   TIME_BASE;          // The selected V/Div
input[5:0]   TIME_BASE;          // The selected V/Div
input[10:0]  RAM_ADDR;
input[10:0]  RAM_ADDR;
output[7:0]  RAM_DATA;
output[7:0]  RAM_DATA;
input        RAM_CLK;
input        RAM_CLK;
input[7:0]   ADC_DATA;
input[7:0]   ADC_DATA;
output       ADC_CLK;
output       ADC_CLK;
output[10:0] TRIG_ADDR;
output[10:0] TRIG_ADDR;
input        VGA_WRITE_DONE;
input        VGA_WRITE_DONE;
input[8:0]   TRIGGER_LEVEL;
input[8:0]   TRIGGER_LEVEL;
 
 
output[1:0] sm_trig;
output[1:0] sm_trig;
 
 
 
 
//----------------------//
//----------------------//
// WIRES / NODES        //
// WIRES / NODES        //
//----------------------//
//----------------------//
wire CLK_64MHZ, MASTER_RST, CLK180_64MHZ;
wire CLK_64MHZ, MASTER_RST, CLK180_64MHZ;
wire[5:0]  TIME_BASE;
wire[5:0]  TIME_BASE;
wire[10:0] RAM_ADDR;
wire[10:0] RAM_ADDR;
wire[7:0]  RAM_DATA;
wire[7:0]  RAM_DATA;
wire       RAM_CLK;
wire       RAM_CLK;
wire[7:0]  ADC_DATA;
wire[7:0]  ADC_DATA;
wire       ADC_CLK;
wire       ADC_CLK;
reg[10:0]  TRIG_ADDR;
reg[10:0]  TRIG_ADDR;
wire       VGA_WRITE_DONE;
wire       VGA_WRITE_DONE;
wire[8:0]  TRIGGER_LEVEL;
wire[8:0]  TRIGGER_LEVEL;
 
 
//----------------------//
//----------------------//
// VARIABLES            //
// VARIABLES            //
//----------------------//
//----------------------//
 
 
 
 
 
 
//==================================================================//
//==================================================================//
// 'SUB-ROUTINES'                                                   //
// 'SUB-ROUTINES'                                                   //
//==================================================================//
//==================================================================//
//------------------------------------------------------------------//
//------------------------------------------------------------------//
// Instanstiate the ADC                                             //
// Instanstiate the ADC                                             //
//------------------------------------------------------------------//
//------------------------------------------------------------------//
wire[7:0] DATA_FROM_ADC;
wire[7:0] DATA_FROM_ADC;
Driver_ADC ADC(
Driver_ADC ADC(
    .CLK_64MHZ(CLK_64MHZ),
    .CLK_64MHZ(CLK_64MHZ),
    .MASTER_RST(MASTER_RST),
    .MASTER_RST(MASTER_RST),
    .TIME_BASE(TIME_BASE),
    .TIME_BASE(TIME_BASE),
    .ADC_CLK(ADC_CLK),
    .ADC_CLK(ADC_CLK),
    .ADC_DATA(ADC_DATA),
    .ADC_DATA(ADC_DATA),
    .DATA_OUT(DATA_FROM_ADC)
    .DATA_OUT(DATA_FROM_ADC)
    );
    );
 
 
//------------------------------------------------------------------//
//------------------------------------------------------------------//
// Initialize the RAMs WE WILL NEED MORE!                           //
// Initialize the RAMs WE WILL NEED MORE!                           //
//   RAM is structured as follows:                                  //
//   RAM is structured as follows:                                  //
//     Dual-Access RAM                                              //
//     Dual-Access RAM                                              //
//     18kBits -> 2048Bytes + 1Parity/Byte                          //
//     18kBits -> 2048Bytes + 1Parity/Byte                          //
//     Access A: 8bit + 1parity (ADC_Write)                         //
//     Access A: 8bit + 1parity (ADC_Write)                         //
//     Access B: 8bit + 1parity (Read)                              //
//     Access B: 8bit + 1parity (Read)                              //
//------------------------------------------------------------------//
//------------------------------------------------------------------//
reg[10:0] ADDRA;
reg[10:0] ADDRA;
wire VCC, GND;
wire VCC, GND;
assign VCC = 1'b1;
assign VCC = 1'b1;
assign GND = 1'b0;
assign GND = 1'b0;
 
 
RAMB16_S9_S9 ADC_QuasiFifo_Buffer(
RAMB16_S9_S9 ADC_QuasiFifo_Buffer(
    .DOA(),                 .DOB(RAM_DATA),
    .DOA(),                 .DOB(RAM_DATA),
    .DOPA(),                .DOPB(),
    .DOPA(),                .DOPB(),
    .ADDRA(ADDRA),          .ADDRB(RAM_ADDR),
    .ADDRA(ADDRA),          .ADDRB(RAM_ADDR),
    .CLKA(CLK180_64MHZ),    .CLKB(RAM_CLK),
    .CLKA(CLK180_64MHZ),    .CLKB(RAM_CLK),
    .DIA(DATA_FROM_ADC),    .DIB(8'b0),
    .DIA(DATA_FROM_ADC),    .DIB(8'b0),
    .DIPA(GND),             .DIPB(GND),
    .DIPA(GND),             .DIPB(GND),
    .ENA(VCC),              .ENB(VCC),
    .ENA(VCC),              .ENB(VCC),
    .WEA(VCC),              .WEB(GND),
    .WEA(VCC),              .WEB(GND),
    .SSRA(GND),             .SSRB(GND)
    .SSRA(GND),             .SSRB(GND)
    );
    );
 
 
//==================================================================//
//==================================================================//
// FUNCTIONAL DEFINITIONS                                           //
// FUNCTIONAL DEFINITIONS                                           //
//==================================================================//
//==================================================================//
 
 
reg[1:0] sm_trig;
reg[1:0] sm_trig;
reg trigger_detected;
reg trigger_detected;
reg[9:0] cnt_1024bytes;
reg[9:0] cnt_1024bytes;
reg mem_half_full;
reg mem_half_full;
 
 
/* THE RAM WRITING TRIGGERING STATE MACHINE */
/* THE RAM WRITING TRIGGERING STATE MACHINE */
always @ (posedge CLK_64MHZ or posedge MASTER_RST) begin
always @ (posedge CLK_64MHZ or posedge MASTER_RST) begin
    if(MASTER_RST == 1'b1)
    if(MASTER_RST == 1'b1)
        sm_trig <= ss_wait_for_trig;
        sm_trig <= ss_wait_for_trig;
    else if(sm_trig == ss_wait_for_trig && trigger_detected == 1'b1)
    else if(sm_trig == ss_wait_for_trig && trigger_detected == 1'b1)
        sm_trig <= ss_fill_mem_half;
        sm_trig <= ss_fill_mem_half;
    else if(sm_trig == ss_fill_mem_half && mem_half_full == 1'b1)
    else if(sm_trig == ss_fill_mem_half && mem_half_full == 1'b1)
        sm_trig <= ss_write_buffer;
        sm_trig <= ss_write_buffer;
    else if(sm_trig == ss_write_buffer && /*trigger_detected == 1'b0 &&*/ VGA_WRITE_DONE == 1'b1)
    else if(sm_trig == ss_write_buffer && /*trigger_detected == 1'b0 &&*/ VGA_WRITE_DONE == 1'b1)
        sm_trig <= ss_wait_for_trig;
        sm_trig <= ss_wait_for_trig;
    else if(sm_trig == ss_invalid)
    else if(sm_trig == ss_invalid)
        sm_trig <= ss_wait_for_trig;
        sm_trig <= ss_wait_for_trig;
    else
    else
        sm_trig <= sm_trig;
        sm_trig <= sm_trig;
end
end
 
 
 
 
/* THIS PART DEALS WITH THE ADDRESS OF THE ADC BUFFER   */
/* THIS PART DEALS WITH THE ADDRESS OF THE ADC BUFFER   */
/* Write in a Circular Buffer soft of way               */
/* Write in a Circular Buffer soft of way               */
always @ (posedge ADC_CLK or posedge MASTER_RST) begin
always @ (posedge ADC_CLK or posedge MASTER_RST) begin
    if(MASTER_RST == 1'b1) begin
    if(MASTER_RST == 1'b1) begin
        ADDRA <= 11'b0;
        ADDRA <= 11'b0;
    end else if(sm_trig == ss_wait_for_trig || sm_trig == ss_fill_mem_half)
    end else if(sm_trig == ss_wait_for_trig || sm_trig == ss_fill_mem_half)
        ADDRA <= ADDRA + 1;
        ADDRA <= ADDRA + 1;
    else
    else
        ADDRA <= ADDRA;
        ADDRA <= ADDRA;
//        ADDRA <= ADDRA + 1;
//        ADDRA <= ADDRA + 1;
end
end
 
 
/* LATCHING THE TRIGGER  */
/* LATCHING THE TRIGGER  */
always @ (ADC_DATA) begin
always @ (ADC_DATA) begin
    if(ADC_DATA >= TRIGGER_LEVEL)
    if(ADC_DATA >= TRIGGER_LEVEL)
        trigger_detected = 1'b1;
        trigger_detected = 1'b1;
    else
    else
        trigger_detected = 1'b0;
        trigger_detected = 1'b0;
end
end
 
 
/* GATHERING 1024 MORE BYTES OF MEMORY */
/* GATHERING 1024 MORE BYTES OF MEMORY */
always @ (posedge ADC_CLK or posedge MASTER_RST) begin
always @ (posedge ADC_CLK or posedge MASTER_RST) begin
    if(MASTER_RST == 1'b1)
    if(MASTER_RST == 1'b1)
        cnt_1024bytes <= 10'b0;
        cnt_1024bytes <= 10'b0;
    else if(sm_trig == ss_fill_mem_half)
    else if(sm_trig == ss_fill_mem_half)
        cnt_1024bytes <= cnt_1024bytes + 1;
        cnt_1024bytes <= cnt_1024bytes + 1;
    else
    else
        cnt_1024bytes <= 10'b0;
        cnt_1024bytes <= 10'b0;
//        cnt_1024bytes <= cnt_1024bytes;
//        cnt_1024bytes <= cnt_1024bytes;
end
end
 
 
always @ (cnt_1024bytes) begin
always @ (cnt_1024bytes) begin
    if(cnt_1024bytes == 10'h3FF)
    if(cnt_1024bytes == 10'h3FF)
        mem_half_full = 1'b1;
        mem_half_full = 1'b1;
    else
    else
        mem_half_full = 1'b0;
        mem_half_full = 1'b0;
end
end
 
 
/* STORING THE TRIGGER ADDRESS */
/* STORING THE TRIGGER ADDRESS */
always @ (posedge trigger_detected or posedge MASTER_RST) begin
always @ (posedge trigger_detected or posedge MASTER_RST) begin
    if(MASTER_RST == 1'b1)
    if(MASTER_RST == 1'b1)
        TRIG_ADDR <= 11'd0;
        TRIG_ADDR <= 11'd0;
    else
    else
        TRIG_ADDR <= ADDRA;
        TRIG_ADDR <= ADDRA;
end
end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.