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

Subversion Repositories wbuart32

[/] [wbuart32/] [trunk/] [bench/] [verilog/] [speechfifo.v] - Diff between revs 5 and 6

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 5 Rev 6
Line 59... Line 59...
`endif
`endif
                        o_uart_tx);
                        o_uart_tx);
        input           i_clk;
        input           i_clk;
        output  wire    o_uart_tx;
        output  wire    o_uart_tx;
 
 
 
        // Here we set i_setup to something appropriate to create a 115200 Baud
 
        // UART system from a 100MHz clock.  This also sets us to an 8-bit data
 
        // word, 1-stop bit, and no parity.  This will be overwritten by
 
        // i_setup, but at least it gives us something to start with/from.
 
        parameter       INITIAL_UART_SETUP = 30'd868;
 
 
        // The i_setup wires are input when run under Verilator, but need to
        // The i_setup wires are input when run under Verilator, but need to
        // be set internally if this is going to run as a standalone top level
        // be set internally if this is going to run as a standalone top level
        // test configuration.
        // test configuration.
`ifdef  OPT_STANDALONE
`ifdef  OPT_STANDALONE
        wire    [29:0]   i_setup;
        wire    [29:0]   i_setup;
 
        assign  i_setup = INITIAL_UART_SETUP;
        // Here we set i_setup to something appropriate to create a 115200 Baud
 
        // UART system from a 100MHz clock.  This also sets us to an 8-bit data
 
        // word, 1-stop bit, and no parity.
 
        assign  i_setup = 30'd868;
 
`else
`else
        input   [29:0]   i_setup;
        input   [29:0]   i_setup;
`endif
`endif
 
 
 
        reg             restart;
        reg             wb_stb;
        reg             wb_stb;
        reg     [1:0]    wb_addr;
        reg     [1:0]    wb_addr;
        reg     [31:0]   wb_data;
        reg     [31:0]   wb_data;
 
 
        wire            uart_stall, uart_ack;
        wire            uart_stall, uart_ack;
Line 99... Line 102...
        // element to a space so that if (for some reason) we broadcast past the
        // element to a space so that if (for some reason) we broadcast past the
        // end of our message, we'll at least be sending something useful.
        // end of our message, we'll at least be sending something useful.
        integer i;
        integer i;
        reg     [7:0]    message [0:2047];
        reg     [7:0]    message [0:2047];
        initial begin
        initial begin
                for(i=0; i<2048; i=i+1)
 
                        message[i] = 8'h20;
 
                $readmemh("speech.hex",message);
                $readmemh("speech.hex",message);
 
                for(i=1481; i<2048; i=i+1)
 
                        message[i] = 8'h20;
        end
        end
 
 
        // Let's keep track of time, and send our message over and over again.
        // Let's keep track of time, and send our message over and over again.
        // To do this, we'll keep track of a restart counter.  When this counter
        // To do this, we'll keep track of a restart counter.  When this counter
        // rolls over, we restart our message.
        // rolls over, we restart our message.
Line 119... Line 122...
 
 
        // Ok, now that we have a counter that tells us when to start over,
        // Ok, now that we have a counter that tells us when to start over,
        // let's build a set of signals that we can use to get things started
        // let's build a set of signals that we can use to get things started
        // again.  This will be the restart signal.  On this signal, we just
        // again.  This will be the restart signal.  On this signal, we just
        // restart everything.
        // restart everything.
        reg     restart;
 
        initial restart = 0;
        initial restart = 0;
        always @(posedge i_clk)
        always @(posedge i_clk)
        begin
 
                restart <= (restart_counter == 0);
                restart <= (restart_counter == 0);
        end
 
 
 
        // Our message index.  This is the address of the character we wish to
        // Our message index.  This is the address of the character we wish to
        // transmit next.  Note, there's a clock delay between setting this 
        // transmit next.  Note, there's a clock delay between setting this 
        // index and when the wb_data is valid.  Hence, we set the index on
        // index and when the wb_data is valid.  Hence, we set the index on
        // restart[0] to zero.
        // restart[0] to zero.
Line 173... Line 173...
                if (restart)
                if (restart)
                        wb_addr <= 2'b00;
                        wb_addr <= 2'b00;
                else // if (!uart_stall)??
                else // if (!uart_stall)??
                        wb_addr <= 2'b11;
                        wb_addr <= 2'b11;
 
 
 
        // Knowing when to stop sending the speech is important, but depends
 
        // upon an 11 bit comparison.  Since FPGA logic is best measured by the
 
        // number of inputs to an always block, we pull those 11-bits out of
 
        // the always block for wb_stb, and place them here on the clock prior.
 
        // If end_of_message is true, then we need to stop transmitting, and
 
        // wait for the next (restart) to get us started again.  We set that
 
        // flag hee.
 
        reg     end_of_message;
 
        initial end_of_message = 1'b1;
 
        always @(posedge i_clk)
 
                if (restart)
 
                        end_of_message <= 1'b0;
 
                else
 
                        end_of_message <= (msg_index >= 1481);
 
 
        // The wb_stb signal indicates that we wish to write, using the wishbone
        // The wb_stb signal indicates that we wish to write, using the wishbone
        // to our peripheral.  We have two separate types of writes.  First,
        // to our peripheral.  We have two separate types of writes.  First,
        // we wish to write our setup.  Then we want to drop STB and write
        // we wish to write our setup.  Then we want to drop STB and write
        // our data.  Once we've filled half of the FIFO, we wait for the FIFO
        // our data.  Once we've filled half of the FIFO, we wait for the FIFO
        // to empty before issuing a STB again and then fill up half the FIFO
        // to empty before issuing a STB again and then fill up half the FIFO
        // again.
        // again.
        initial wb_stb = 1'b0;
        initial wb_stb = 1'b0;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if (restart)
                if (restart)
 
                        // Start sending to the UART on a reset.  The first
 
                        // thing we'll send will be the configuration, but
 
                        // that's done elsewhere.  This just starts up the
 
                        // writes to the peripheral wbuart.
                        wb_stb <= 1'b1;
                        wb_stb <= 1'b1;
                else if (msg_index >= 1481)
                else if (end_of_message)
 
                        // Stop transmitting when we get to the end of our
 
                        // message.
                        wb_stb <= 1'b0;
                        wb_stb <= 1'b0;
                else if (tx_int)
                else if (tx_int)
 
                        // If we aren't at the end of the message, and tx_int
 
                        // tells us the FIFO is empty, then start writing into
 
                        // the FIFO>
                        wb_stb <= 1'b1;
                        wb_stb <= 1'b1;
                else if (txfifo_int)
                else if (txfifo_int)
 
                        // If we are writing into the FIFO, and it's less than
 
                        // half full (i.e. txfifo_int is true) then keep going.
                        wb_stb <= wb_stb;
                        wb_stb <= wb_stb;
                else
                else
 
                        // But once the FIFO gets to half full, stop.
                        wb_stb <= 1'b0;
                        wb_stb <= 1'b0;
 
 
        // We aren't using the receive interrupts, so we'll just mark them
        // We aren't using the receive interrupts, so we'll just mark them
        // here as ignored.
        // here as ignored.
        wire    ignored_rx_int, ignored_rxfifo_int;
        wire    ignored_rx_int, ignored_rxfifo_int;
 
 
        // Finally--the unit under test--now that we've set up all the wires
        // Finally--the unit under test--now that we've set up all the wires
        // to run/test it.
        // to run/test it.
        wbuart  #(30'h868)
        wbuart  #(INITIAL_UART_SETUP)
                wbuarti(i_clk, pwr_reset,
                wbuarti(i_clk, pwr_reset,
                        wb_stb, wb_stb, 1'b1, wb_addr, wb_data,
                        wb_stb, wb_stb, 1'b1, wb_addr, wb_data,
                        uart_stall, uart_ack, uart_data,
                        uart_stall, uart_ack, uart_data,
                        1'b1, o_uart_tx,
                        1'b1, o_uart_tx,
                        ignored_rx_int, tx_int,
                        ignored_rx_int, tx_int,

powered by: WebSVN 2.1.0

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