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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.2/] [rtl/] [EXE/] [Module_InstructionDecode.v] - Blame information for rev 127

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 diegovalve
`timescale 1ns / 1ps
2
`include "aDefinitions.v"
3
/**********************************************************************************
4
Theia, Ray Cast Programable graphic Processing Unit.
5
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
6
 
7
This program is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; either version 2
10
of the License, or (at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 
21
***********************************************************************************/
22
 
23
module InstructionDecode
24
(
25
input wire                                                                                      Clock,
26
input wire                                                                                      Reset,
27 60 diegovalve
input wire                                                                                      iInstructionAvailable,
28 24 diegovalve
input   wire[`INSTRUCTION_WIDTH-1:0]                     iEncodedInstruction,
29 60 diegovalve
input   wire[`DATA_ROW_WIDTH-1:0]                                iRamValue0,
30
input   wire[`DATA_ROW_WIDTH-1:0]                                iRamValue1,
31 24 diegovalve
output  wire[`DATA_ADDRESS_WIDTH-1:0]            oRamAddress0,oRamAddress1,
32
output  wire[`INSTRUCTION_OP_LENGTH-1:0] oOperation,
33 60 diegovalve
output  wire [`DATA_ROW_WIDTH-1:0]                       oSource0,oSource1,
34
output  wire [`DATA_ADDRESS_WIDTH-1:0]      oDestination,
35
input wire [`DATA_ROW_WIDTH-1:0]          iDataForward,
36
input wire [`DATA_ADDRESS_WIDTH-1:0]      iLastDestination,
37 24 diegovalve
 
38
`ifdef DEBUG
39
        input wire [`ROM_ADDRESS_WIDTH-1:0] iDebug_CurrentIP,
40
        output wire [`ROM_ADDRESS_WIDTH-1:0] oDebug_CurrentIP,
41
`endif
42 60 diegovalve
output wire                               oDataReadyForExe
43 24 diegovalve
 
44
);
45 60 diegovalve
wire wInmediateOperand;
46
wire [`DATA_ROW_WIDTH-1:0]       wSource0,wSource1;
47
wire wTriggerSource0DataForward,wTriggerSource1DataForward;
48
wire wSource0AddrssEqualsLastDestination,wSource1AddrssEqualsLastDestination;
49 24 diegovalve
 
50
`ifdef DEBUG
51
assign oDebug_CurrentIP = iDebug_CurrentIP;
52
`endif
53 60 diegovalve
//See if operation takes scalar argument
54
assign wInmediateOperand = iEncodedInstruction[`INSTRUCTION_IMM_BITPOS];
55 24 diegovalve
 
56 60 diegovalve
//Has the value of the first argument fetched from IMEM
57
assign wSource0 = iRamValue0;
58
//Has the value of the second argument fetched from IMEM, or the value of the
59
//destinatin register in case of scalar operation
60
assign wSource1 = ( wInmediateOperand ) ? {oRamAddress1,iEncodedInstruction[15:0] ,32'b0,32'b0} : iRamValue1; //{oRamAddress1,oRamAddress0,32'b0,32'b0} : iRamValue1;
61 24 diegovalve
 
62 60 diegovalve
//Data forwarding logic
63
assign wSource0AddrssEqualsLastDestination = (oRamAddress0 == iLastDestination) ? 1'b1: 1'b0;
64
assign wSource1AddrssEqualsLastDestination = (oRamAddress1 == iLastDestination) ? 1'b1: 1'b0;
65
assign wTriggerSource0DataForward = wSource0AddrssEqualsLastDestination;
66
assign wTriggerSource1DataForward = wSource1AddrssEqualsLastDestination && !wInmediateOperand;
67 24 diegovalve
 
68 60 diegovalve
//The data address to fetch from IMEM
69
assign oRamAddress1 = iEncodedInstruction[31:16];
70 24 diegovalve
 
71 60 diegovalve
//If operation takes a scalar value, then ask IMEM
72
//for the previous value of the destination ([47:32])
73
//and have this value ready at oRamAddress0
74
MUXFULLPARALELL_16bits_2SEL RAMAddr0MUX
75 24 diegovalve
 (
76 60 diegovalve
  .Sel( wInmediateOperand ),
77
  .I1( iEncodedInstruction[15:0] ),
78
  .I2( iEncodedInstruction[47:32] ),
79
  .O1( oRamAddress0 )
80 24 diegovalve
 );
81
 
82
 
83 60 diegovalve
//One clock cycle after the new instruction becomes
84
//available to IDU, it should be decoded and ready 
85
//for execution
86
FFD_POSEDGE_SYNCRONOUS_RESET # ( 1 ) FFD1
87
(
88
        .Clock( Clock ),
89
        .Reset( Reset ),
90
        .Enable(1'b1),
91
        .D( iInstructionAvailable ),
92
        .Q( oDataReadyForExe )
93
);
94 24 diegovalve
 
95
 
96 60 diegovalve
//Latch the Operation
97
FFD_POSEDGE_SYNCRONOUS_RESET # ( `INSTRUCTION_OP_LENGTH ) FFD3
98
(
99
        .Clock(Clock),
100
        .Reset(Reset),
101
        .Enable(iInstructionAvailable),
102
        .D(iEncodedInstruction[`INSTRUCTION_WIDTH-1:`INSTRUCTION_WIDTH-`INSTRUCTION_OP_LENGTH]),
103
        .Q(oOperation )
104
);
105
//Latch the Destination
106
FFD_POSEDGE_SYNCRONOUS_RESET # ( `DATA_ADDRESS_WIDTH ) FFD2
107
(
108
        .Clock(Clock),
109
        .Reset(Reset),
110
        .Enable(iInstructionAvailable),
111
        .D(iEncodedInstruction[47:32]),
112
        .Q(oDestination )
113
);
114 24 diegovalve
 
115
 
116 60 diegovalve
//Once we made a decicions if the Sources must be forwarded or not, a series of muxes
117 24 diegovalve
//are used to routed the correct data into the decoded Source outputs
118
 
119
MUXFULLPARALELL_96bits_2SEL Source0_Mux
120
(
121 60 diegovalve
        .Sel( wTriggerSource0DataForward ),
122 24 diegovalve
        .I1( wSource0  ),
123
        .I2( iDataForward ),
124
        .O1( oSource0 )
125
);
126
 
127
MUXFULLPARALELL_96bits_2SEL Source1_Mux
128
(
129 60 diegovalve
        .Sel( wTriggerSource1DataForward ),
130 24 diegovalve
        .I1( wSource1  ),
131
        .I2( iDataForward ),
132
        .O1( oSource1 )
133
);
134
 
135 60 diegovalve
endmodule
136 24 diegovalve
 

powered by: WebSVN 2.1.0

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