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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [wbuidleint.v] - Diff between revs 2 and 102

Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 102
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Filename:    wbuidleint.v
// Filename:    wbuidleint.v
//
//
// Project:     XuLA2 board
// Project:     FPGA library
//
//
// Purpose:     Creates an output for the interface, inserting idle words and
// Purpose:     Creates an output for the interface, inserting idle words and
//              words indicating an interrupt has taken place into the output
//              words indicating an interrupt has taken place into the output
//      stream.  Henceforth, the output means more than just bus transaction
//      stream.  Henceforth, the output means more than just bus transaction
//      results.  It may mean there is no bus transaction result to report,
//      results.  It may mean there is no bus transaction result to report,
//      or that an interrupt has taken place.
//      or that an interrupt has taken place.
//
//
//
//
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015, Gisselquist Technology, LLC
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) any later version.
//
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// for more details.
//
//
// License:     GPL, v3, as defined and found on www.gnu.org,
// License:     GPL, v3, as defined and found on www.gnu.org,
//              http://www.gnu.org/licenses/gpl.html
//              http://www.gnu.org/licenses/gpl.html
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
//
//
module  wbuidleint(i_clk, i_stb, i_codword, i_cyc, i_busy, i_int,
module  wbuidleint(i_clk, i_stb, i_codword, i_cyc, i_busy, i_int,
                o_stb, o_codword, o_busy,
                o_stb, o_codword, o_busy,
                i_tx_busy);
                i_tx_busy);
        input                   i_clk;
        input                   i_clk;
        // From the FIFO following the bus executor
        // From the FIFO following the bus executor
        input                   i_stb;
        input                   i_stb;
        input           [35:0]   i_codword;
        input           [35:0]   i_codword;
        // From the rest of the board
        // From the rest of the board
        input                   i_cyc, i_busy, i_int;
        input                   i_cyc, i_busy, i_int;
        // To the next stage
        // To the next stage
        output  reg             o_stb;
        output  reg             o_stb;
        output  reg     [35:0]   o_codword;
        output  reg     [35:0]   o_codword;
        output  reg             o_busy;
        output  reg             o_busy;
        // Is the next stage busy?
        // Is the next stage busy?
        input                   i_tx_busy;
        input                   i_tx_busy;
 
 
        reg     int_request, int_sent;
        reg     int_request, int_sent;
        initial int_request = 1'b0;
        initial int_request = 1'b0;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if((o_stb)&&(~i_tx_busy)&&(o_codword[35:30]==6'h4))
                if((o_stb)&&(~i_tx_busy)&&(o_codword[35:30]==6'h4))
                        int_request <= i_int;
                        int_request <= i_int;
                else
                else
                        int_request <= (int_request)||(i_int);
                        int_request <= (int_request)||(i_int);
 
 
 
 
        // Now, for the idle counter
        // Now, for the idle counter
        wire            idle_expired;
        wire            idle_expired;
        reg             idle_state;
        reg             idle_state;
        reg     [35:0]   idle_counter;
        reg     [35:0]   idle_counter;
        initial idle_counter = 36'h0000;
        initial idle_counter = 36'h0000;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if ((i_stb)||(o_stb))
                if ((i_stb)||(o_stb))
                        idle_counter <= 36'h000;
                        idle_counter <= 36'h000;
                else if (~idle_counter[35])
                else if (~idle_counter[35])
                        idle_counter <= idle_counter + 36'd43;
                        idle_counter <= idle_counter + 36'd43;
 
 
        initial idle_state = 1'b0;
        initial idle_state = 1'b0;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if ((o_stb)&&(~i_tx_busy)&&(o_codword[35:31]==5'h0))
                if ((o_stb)&&(~i_tx_busy)&&(o_codword[35:31]==5'h0))
                        idle_state <= 1'b1;
                        idle_state <= 1'b1;
                else if (~idle_counter[35])
                else if (~idle_counter[35])
                        idle_state <= 1'b0;
                        idle_state <= 1'b0;
 
 
        assign  idle_expired = (~idle_state)&&(idle_counter[35]);
        assign  idle_expired = (~idle_state)&&(idle_counter[35]);
 
 
        initial o_stb  = 1'b0;
        initial o_stb  = 1'b0;
        initial o_busy = 1'b0;
        initial o_busy = 1'b0;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if ((o_stb)&&(i_tx_busy))
                if ((o_stb)&&(i_tx_busy))
                begin
                begin
                        o_busy <= 1'b1;
                        o_busy <= 1'b1;
                end else if (o_stb) // and not i_tx_busy
                end else if (o_stb) // and not i_tx_busy
                begin
                begin
                        // Idle one clock before becoming not busy
                        // Idle one clock before becoming not busy
                        o_stb <= 1'b0;
                        o_stb <= 1'b0;
                        o_busy <= 1'b1;
                        o_busy <= 1'b1;
                end else if (o_busy)
                end else if (o_busy)
                        o_busy <= 1'b0;
                        o_busy <= 1'b0;
                else if (i_stb) // and (~o_busy)&&(~o_stb)
                else if (i_stb) // and (~o_busy)&&(~o_stb)
                begin // On a valid output, just send it out
                begin // On a valid output, just send it out
                        // We'll open this strobe, even if the transmitter
                        // We'll open this strobe, even if the transmitter
                        // is busy, just 'cause we might otherwise lose it
                        // is busy, just 'cause we might otherwise lose it
                        o_codword <= i_codword;
                        o_codword <= i_codword;
                        o_stb <= 1'b1;
                        o_stb <= 1'b1;
                        o_busy <= 1'b1;
                        o_busy <= 1'b1;
                end else if ((int_request)&&(~int_sent))
                end else if ((int_request)&&(~int_sent))
                begin
                begin
                        o_stb <= 1'b1;
                        o_stb <= 1'b1;
                        o_codword <= { 6'h4, 30'h0000 }; // interrupt codeword
                        o_codword <= { 6'h4, 30'h0000 }; // interrupt codeword
                        o_busy <= 1'b1;
                        o_busy <= 1'b1;
                end else if (idle_expired)
                end else if (idle_expired)
                begin // Strobe, if we're not writing or our
                begin // Strobe, if we're not writing or our
                        // last command wasn't an idle
                        // last command wasn't an idle
                        o_stb  <= 1'b1;
                        o_stb  <= 1'b1;
                        o_busy <= 1'b1;
                        o_busy <= 1'b1;
                        if (i_cyc)
                        if (i_cyc)
                                o_codword <= { 6'h1, 30'h0000 }; // idle codeword, bus busy
                                o_codword <= { 6'h1, 30'h0000 }; // idle codeword, bus busy
                        else
                        else
                                o_codword <= { 6'h0, 30'h0000 };
                                o_codword <= { 6'h0, 30'h0000 };
                end
                end
 
 
        initial int_sent = 1'b0;
        initial int_sent = 1'b0;
        always @(posedge i_clk)
        always @(posedge i_clk)
                if ((int_request)&&((~o_stb)&&(~o_busy)&&(~i_stb)))
                if ((int_request)&&((~o_stb)&&(~o_busy)&&(~i_stb)))
                        int_sent <= 1'b1;
                        int_sent <= 1'b1;
                else if (~i_int)
                else if (~i_int)
                        int_sent <= 1'b0;
                        int_sent <= 1'b0;
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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