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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [icarus_version/] [rtl/] [Collaterals.v] - Diff between revs 175 and 176

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

Rev 175 Rev 176
`ifndef COLLATERALS_V
`ifndef COLLATERALS_V
`define COLLATERALS_V
`define COLLATERALS_V
 
 
`timescale 1ns / 1ps
`timescale 1ns / 1ps
`include "aDefinitions.v"
`include "aDefinitions.v"
/**********************************************************************************
/**********************************************************************************
Theia, Ray Cast Programable graphic Processing Unit.
Theia, Ray Cast Programable graphic Processing Unit.
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
 
 
This program is free software; you can redistribute it and/or
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
of the License, or (at your option) any later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 
***********************************************************************************/
***********************************************************************************/
 
 
//----------------------------------------------------
//----------------------------------------------------
module FFD_POSEDGE_SYNCRONOUS_RESET # ( parameter SIZE=`WIDTH )
module FFD_POSEDGE_SYNCRONOUS_RESET # ( parameter SIZE=`WIDTH )
(
(
        input wire                              Clock,
        input wire                              Clock,
        input wire                              Reset,
        input wire                              Reset,
        input wire                              Enable,
        input wire                              Enable,
        input wire [SIZE-1:0]    D,
        input wire [SIZE-1:0]    D,
        output reg [SIZE-1:0]    Q
        output reg [SIZE-1:0]    Q
);
);
 
 
 
 
always @ (posedge Clock)
always @ (posedge Clock)
begin
begin
        if ( Reset )
        if ( Reset )
                Q <= {SIZE{1'b0}};
                Q <= {SIZE{1'b0}};
        else
        else
        begin
        begin
                if (Enable)
                if (Enable)
                        Q <= D;
                        Q <= D;
        end
        end
 
 
end//always
end//always
 
 
endmodule
endmodule
//------------------------------------------------
//------------------------------------------------
module UPCOUNTER_POSEDGE # (parameter SIZE=`WIDTH)
module UPCOUNTER_POSEDGE # (parameter SIZE=`WIDTH)
(
(
input wire Clock, Reset,
input wire Clock, Reset,
input wire [SIZE-1:0] Initial,
input wire [SIZE-1:0] Initial,
input wire Enable,
input wire Enable,
output reg [SIZE-1:0] Q
output reg [SIZE-1:0] Q
);
);
 
 
 
 
  always @(posedge Clock )
  always @(posedge Clock )
  begin
  begin
      if (Reset)
      if (Reset)
        Q <= Initial;
        Q <= Initial;
      else
      else
                begin
                begin
                if (Enable)
                if (Enable)
                        Q <= Q + 1;
                        Q <= Q + 1;
 
 
                end
                end
  end
  end
 
 
endmodule
endmodule
 
 
//----------------------------------------------------------------------
//----------------------------------------------------------------------
 
 
module SELECT_1_TO_N # ( parameter SEL_WIDTH=4, parameter OUTPUT_WIDTH=16 )
module SELECT_1_TO_N # ( parameter SEL_WIDTH=4, parameter OUTPUT_WIDTH=16 )
 (
 (
 input wire [SEL_WIDTH-1:0] Sel,
 input wire [SEL_WIDTH-1:0] Sel,
 input wire  En,
 input wire  En,
 output wire [OUTPUT_WIDTH-1:0] O
 output wire [OUTPUT_WIDTH-1:0] O
 );
 );
 
 
reg[OUTPUT_WIDTH-1:0] shift;
reg[OUTPUT_WIDTH-1:0] shift;
 
 
always @ ( * )
always @ ( * )
begin
begin
        if (~En)
        if (~En)
                shift = 1;
                shift = 1;
        else
        else
                shift = (1 <<   Sel);
                shift = (1 <<   Sel);
 
 
 
 
end
end
 
 
assign O = ( ~En ) ? 0 : shift ;
assign O = ( ~En ) ? 0 : shift ;
 
 
//assign O = En & (1 << Sel);
//assign O = En & (1 << Sel);
 
 
endmodule
endmodule
 
 
//----------------------------------------------------------------------
//----------------------------------------------------------------------
 
module MUXFULLPARALELL_GENERIC #(parameter  WIDTH = `WIDTH, parameter  CHANNELS = 4, parameter SELBITS = 2)
 
(
 
 
 
    input wire   [(CHANNELS*WIDTH)-1:0]      in_bus,
 
    input wire   [SELBITS-1:0]    sel,
 
 
 
    output wire [WIDTH-1:0]                 out
 
    );
 
 
 
genvar ig;
 
 
 
wire    [WIDTH-1:0] input_array [0:CHANNELS-1];
 
 
 
assign  out = input_array[sel];
 
 
 
generate
 
    for(ig=0; ig<CHANNELS; ig=ig+1)
 
         begin: array_assignments
 
        assign  input_array[ig] = in_bus[(ig*WIDTH)+:WIDTH];
 
    end
 
endgenerate
 
 
 
 
 
 
 
endmodule
 
//----------------------------------------------------------------------
module MUXFULLPARALELL_2SEL_GENERIC # ( parameter SIZE=`WIDTH )
module MUXFULLPARALELL_2SEL_GENERIC # ( parameter SIZE=`WIDTH )
 (
 (
 input wire [1:0] Sel,
 input wire [1:0] Sel,
 input wire [SIZE-1:0]I1, I2, I3,I4,
 input wire [SIZE-1:0]I1, I2, I3,I4,
 output reg [SIZE-1:0] O1
 output reg [SIZE-1:0] O1
 );
 );
 
 
always @( * )
always @( * )
 
 
  begin
  begin
 
 
    case (Sel)
    case (Sel)
 
 
      2'b00: O1 = I1;
      2'b00: O1 = I1;
      2'b01: O1 = I2;
      2'b01: O1 = I2;
                2'b10: O1 = I3;
                2'b10: O1 = I3;
                2'b11: O1 = I4;
                2'b11: O1 = I4;
                default: O1 = SIZE;
                default: O1 = SIZE;
 
 
    endcase
    endcase
 
 
  end
  end
 
 
endmodule
endmodule
 
 
//--------
//--------
module CIRCULAR_SHIFTLEFT_POSEDGE_EX # ( parameter SIZE=`WIDTH )
module CIRCULAR_SHIFTLEFT_POSEDGE_EX # ( parameter SIZE=`WIDTH )
( input wire Clock,
( input wire Clock,
  input wire Reset,
  input wire Reset,
  input wire[SIZE-1:0] Initial,
  input wire[SIZE-1:0] Initial,
  input wire      Enable,
  input wire      Enable,
  output wire[SIZE-1:0] O
  output wire[SIZE-1:0] O
);
);
 
 
reg [SIZE-1:0] tmp;
reg [SIZE-1:0] tmp;
 
 
 
 
  always @(posedge Clock)
  always @(posedge Clock)
  begin
  begin
  if (Reset)
  if (Reset)
                tmp <= Initial;
                tmp <= Initial;
        else
        else
        begin
        begin
                if (Enable)
                if (Enable)
                begin
                begin
                        if (tmp[SIZE-1])
                        if (tmp[SIZE-1])
                        begin
                        begin
                                tmp <= Initial;
                                tmp <= Initial;
                        end
                        end
                        else
                        else
                        begin
                        begin
                                tmp <= tmp << 1;
                                tmp <= tmp << 1;
                        end
                        end
                end
                end
        end
        end
  end
  end
 
 
 
 
    assign O  = tmp;
    assign O  = tmp;
endmodule
endmodule
//------------------------------------------------
//------------------------------------------------
module MUXFULLPARALELL_3SEL_WALKINGONE # ( parameter SIZE=`WIDTH )
module MUXFULLPARALELL_3SEL_WALKINGONE # ( parameter SIZE=`WIDTH )
 (
 (
 input wire [2:0] Sel,
 input wire [2:0] Sel,
 input wire [SIZE-1:0]I1, I2, I3,
 input wire [SIZE-1:0]I1, I2, I3,
 output reg [SIZE-1:0] O1
 output reg [SIZE-1:0] O1
 );
 );
 
 
always @( * )
always @( * )
 
 
  begin
  begin
 
 
    case (Sel)
    case (Sel)
 
 
      3'b001: O1 = I1;
      3'b001: O1 = I1;
      3'b010: O1 = I2;
      3'b010: O1 = I2;
      3'b100: O1 = I3;
      3'b100: O1 = I3;
      default: O1 = SIZE;
      default: O1 = SIZE;
 
 
    endcase
    endcase
 
 
  end
  end
 
 
endmodule
endmodule
//------------------------------------------------
//------------------------------------------------
module SHIFTLEFT_POSEDGE # ( parameter SIZE=`WIDTH )
module SHIFTLEFT_POSEDGE # ( parameter SIZE=`WIDTH )
( input wire Clock,
( input wire Clock,
  input wire Reset,
  input wire Reset,
  input wire[SIZE-1:0] Initial,
  input wire[SIZE-1:0] Initial,
  input wire      Enable,
  input wire      Enable,
  output wire[SIZE-1:0] O
  output wire[SIZE-1:0] O
);
);
 
 
reg [SIZE-1:0] tmp;
reg [SIZE-1:0] tmp;
 
 
 
 
  always @(posedge Clock)
  always @(posedge Clock)
  begin
  begin
  if (Reset)
  if (Reset)
                tmp <= Initial;
                tmp <= Initial;
        else
        else
        begin
        begin
                if (Enable)
                if (Enable)
                        tmp <= tmp << 1;
                        tmp <= tmp << 1;
        end
        end
  end
  end
 
 
 
 
    assign O  = tmp;
    assign O  = tmp;
endmodule
endmodule
//------------------------------------------------
//------------------------------------------------
//------------------------------------------------
//------------------------------------------------
module CIRCULAR_SHIFTLEFT_POSEDGE # ( parameter SIZE=`WIDTH )
module CIRCULAR_SHIFTLEFT_POSEDGE # ( parameter SIZE=`WIDTH )
( input wire Clock,
( input wire Clock,
  input wire Reset,
  input wire Reset,
  input wire[SIZE-1:0] Initial,
  input wire[SIZE-1:0] Initial,
  input wire      Enable,
  input wire      Enable,
  output wire[SIZE-1:0] O
  output wire[SIZE-1:0] O
);
);
 
 
reg [SIZE-1:0] tmp;
reg [SIZE-1:0] tmp;
 
 
 
 
  always @(posedge Clock)
  always @(posedge Clock)
  begin
  begin
  if (Reset || tmp[SIZE-1])
  if (Reset || tmp[SIZE-1])
                tmp <= Initial;
                tmp <= Initial;
        else
        else
        begin
        begin
                if (Enable)
                if (Enable)
                        tmp <= tmp << 1;
                        tmp <= tmp << 1;
        end
        end
  end
  end
 
 
 
 
    assign O  = tmp;
    assign O  = tmp;
endmodule
endmodule
//-----------------------------------------------------------
//-----------------------------------------------------------
/*
/*
        Sorry forgot how this flop is called.
        Sorry forgot how this flop is called.
        Any way Truth table is this
        Any way Truth table is this
 
 
        Q       S       Q_next R
        Q       S       Q_next R
        0        0        0                 0
        0        0        0                 0
        0        1       1                0
        0        1       1                0
        1       0        1                0
        1       0        1                0
        1       1       1                0
        1       1       1                0
        X       X       0                 1
        X       X       0                 1
 
 
        The idea is that it toggles from 0 to 1 when S = 1, but if it
        The idea is that it toggles from 0 to 1 when S = 1, but if it
        gets another S = 1, it keeps the output to 1.
        gets another S = 1, it keeps the output to 1.
*/
*/
module FFToggleOnce_1Bit
module FFToggleOnce_1Bit
(
(
        input wire Clock,
        input wire Clock,
        input wire Reset,
        input wire Reset,
        input wire Enable,
        input wire Enable,
        input wire S,
        input wire S,
        output reg Q
        output reg Q
 
 
);
);
 
 
 
 
reg Q_next;
reg Q_next;
 
 
always @ (negedge Clock)
always @ (negedge Clock)
begin
begin
        Q <= Q_next;
        Q <= Q_next;
end
end
 
 
always @ ( posedge Clock )
always @ ( posedge Clock )
begin
begin
        if (Reset)
        if (Reset)
                Q_next <= 0;
                Q_next <= 0;
        else if (Enable)
        else if (Enable)
                Q_next <= (S && !Q) || Q;
                Q_next <= (S && !Q) || Q;
        else
        else
                Q_next <= Q;
                Q_next <= Q;
end
end
endmodule
endmodule
 
 
//-----------------------------------------------------------
//-----------------------------------------------------------
 
 
 
 
module FFD32_POSEDGE
module FFD32_POSEDGE
(
(
        input wire Clock,
        input wire Clock,
        input wire[31:0] D,
        input wire[31:0] D,
        output reg[31:0] Q
        output reg[31:0] Q
);
);
 
 
        always @ (posedge Clock)
        always @ (posedge Clock)
                Q <= D;
                Q <= D;
 
 
endmodule
endmodule
 
 
//------------------------------------------------
//------------------------------------------------
module MUXFULLPARALELL_96bits_2SEL
module MUXFULLPARALELL_96bits_2SEL
 (
 (
 input wire Sel,
 input wire Sel,
 input wire [95:0]I1, I2,
 input wire [95:0]I1, I2,
 output reg [95:0] O1
 output reg [95:0] O1
 );
 );
 
 
 
 
 
 
always @( * )
always @( * )
 
 
  begin
  begin
 
 
    case (Sel)
    case (Sel)
 
 
      1'b0: O1 = I1;
      1'b0: O1 = I1;
      1'b1: O1 = I2;
      1'b1: O1 = I2;
 
 
    endcase
    endcase
 
 
  end
  end
 
 
endmodule
endmodule
 
 
//------------------------------------------------
//------------------------------------------------
module MUXFULLPARALELL_16bits_2SEL
module MUXFULLPARALELL_16bits_2SEL
 (
 (
 input wire Sel,
 input wire Sel,
 input wire [15:0]I1, I2,
 input wire [15:0]I1, I2,
 output reg [15:0] O1
 output reg [15:0] O1
 );
 );
 
 
 
 
 
 
always @( * )
always @( * )
 
 
  begin
  begin
 
 
    case (Sel)
    case (Sel)
 
 
      1'b0: O1 = I1;
      1'b0: O1 = I1;
      1'b1: O1 = I2;
      1'b1: O1 = I2;
 
 
    endcase
    endcase
 
 
  end
  end
 
 
endmodule
endmodule
 
 
//--------------------------------------------------------------
//--------------------------------------------------------------
 
 
  module FFT1
  module FFT1
  (
  (
   input wire D,
   input wire D,
   input wire Clock,
   input wire Clock,
   input wire Reset ,
   input wire Reset ,
   output reg Q
   output reg Q
 );
 );
 
 
  always @ ( posedge Clock or posedge Reset )
  always @ ( posedge Clock or posedge Reset )
  begin
  begin
 
 
        if (Reset)
        if (Reset)
        begin
        begin
    Q <= 1'b0;
    Q <= 1'b0;
   end
   end
        else
        else
        begin
        begin
                if (D)
                if (D)
                        Q <=  ! Q;
                        Q <=  ! Q;
        end
        end
 
 
  end//always
  end//always
 
 
 endmodule
 endmodule
//--------------------------------------------------------------
//--------------------------------------------------------------
 
 
`endif
`endif
 
 

powered by: WebSVN 2.1.0

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