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

Subversion Repositories zap

[/] [zap/] [trunk/] [src/] [rtl/] [cpu/] [zap_thumb_decoder.v] - Blame information for rev 43

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

Line No. Rev Author Line
1 26 Revanth
// -----------------------------------------------------------------------------
2
// --                                                                         --
3
// --                   (C) 2016-2018 Revanth Kamaraj.                        --
4
// --                                                                         -- 
5
// -- --------------------------------------------------------------------------
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           --
20
// -- 02110-1301, USA.                                                        --
21
// --                                                                         --
22
// -----------------------------------------------------------------------------
23
// --                                                                         --
24
// --  Implements a 16-bit instruction decoder. The 16-bit instruction set is --
25
// --  not logically organized so as to save on encoding and thus the code    -- 
26
// --  seem a bit complex.                                                    --
27
// --                                                                         --
28
// -----------------------------------------------------------------------------
29
 
30
 
31
`default_nettype none
32
 
33
module zap_thumb_decoder (
34
        // Clock and reset.
35
        input wire              i_clk,
36
        input wire              i_reset,
37
 
38
        // Code stall.
39
        input wire              i_clear_from_writeback,
40
        input wire              i_data_stall,
41
        input wire              i_clear_from_alu,
42
        input wire              i_stall_from_shifter,
43
        input wire              i_stall_from_issue,
44
        input wire              i_stall_from_decode,
45
        input wire              i_clear_from_decode,
46
 
47
        // Predictor status.
48
        input wire  [1:0]       i_taken,
49
 
50
        // Input from I-cache.
51
        // Instruction and valid qualifier.
52
        input wire [31:0]       i_instruction,
53
        input wire              i_instruction_valid,
54
 
55
        // Interrupts. Active high level sensitive signals.
56
        input wire              i_irq,
57
        input wire              i_fiq,
58
 
59
        // Aborts.
60
        input wire              i_iabort,
61
        output reg              o_iabort,
62
 
63
        // Ensure compressed mode is active (T bit).
64
        input wire              i_cpsr_ff_t,
65
 
66
        // Program counter.
67
        input wire      [31:0]  i_pc_ff,
68
        input wire      [31:0]  i_pc_plus_8_ff,
69
 
70
        //
71
        // Outputs to the ARM decoder.
72
        // 
73
 
74
        // Instruction, valid, undefined by this decoder and force 32-bit
75
        // align signals (requires memory to keep lower 2 bits as 00).
76
        output reg [34:0]       o_instruction,
77
        output reg              o_instruction_valid,
78
        output reg              o_und,
79
        output reg              o_force32_align,
80
 
81
        // PCs.
82
        output  reg [31:0]      o_pc_ff,
83
        output  reg [31:0]      o_pc_plus_8_ff,
84
 
85
        // Interrupt status output.
86
        output reg              o_irq,
87
        output reg              o_fiq,
88
 
89
        // Taken
90
        output reg      [1:0]   o_taken_ff
91
);
92
 
93
`include "zap_defines.vh"
94
`include "zap_localparams.vh"
95
`include "zap_functions.vh"
96
 
97
wire [34:0] instruction_nxt;
98
wire instruction_valid_nxt;
99
wire und_nxt;
100
wire force32_nxt;
101
wire irq_nxt;
102
wire fiq_nxt;
103
reg  [1:0] taken_nxt;
104
 
105
zap_predecode_compress u_zap_predecode_compress (
106
        .i_clk(i_clk),
107
        .i_instruction(i_instruction),
108
        .i_instruction_valid(i_instruction_valid),
109
        .i_irq(i_irq),
110
        .i_fiq(i_fiq),
111 38 Revanth
        .i_offset(o_instruction[11:0]),
112 26 Revanth
        .i_cpsr_ff_t(i_cpsr_ff_t),
113
        .o_instruction(instruction_nxt),
114
        .o_instruction_valid(instruction_valid_nxt),
115
        .o_und(und_nxt),
116
        .o_force32_align(force32_nxt),
117
        .o_irq(irq_nxt),
118
        .o_fiq(fiq_nxt)
119
);
120
 
121
always @ (posedge i_clk)
122
begin
123
        if ( i_reset )
124
        begin
125
                o_instruction_valid <= 1'd0;
126
                o_irq <= 0;
127
                o_fiq <= 0;
128
                o_und <= 0;
129
                o_iabort <= 0;
130
        end
131
        else if ( i_clear_from_writeback )
132
        begin
133
                o_instruction_valid <= 1'd0;
134
                o_irq <= 0;
135
                o_fiq <= 0;
136
                o_und <= 0;
137
                o_iabort <= 0;
138
        end
139
        else if ( i_data_stall )
140
        begin
141
        end
142
        else if ( i_clear_from_alu )
143
        begin
144
                o_instruction_valid <= 1'd0;
145
                o_irq <= 0;
146
                o_fiq <= 0;
147
                o_und <= 0;
148
                o_iabort <= 0;
149
        end
150
        else if ( i_stall_from_shifter ) begin end
151
        else if ( i_stall_from_issue )   begin end
152
        else if ( i_stall_from_decode )  begin end
153
        else if ( i_clear_from_decode )
154
        begin
155
                o_instruction_valid <= 1'd0;
156
                o_irq <= 0;
157
                o_fiq <= 0;
158
                o_und <= 0;
159
                o_iabort <= 0;
160
        end
161
        else // BUG FIX.
162
        begin
163
                o_iabort                <= i_iabort;
164
                o_instruction_valid     <= instruction_valid_nxt;
165
                o_instruction           <= instruction_nxt;
166
                o_und                   <= und_nxt;
167
                o_force32_align         <= force32_nxt;
168
                o_pc_ff                 <= i_pc_ff;
169
                o_pc_plus_8_ff          <= i_pc_plus_8_ff;
170
                o_irq                   <= irq_nxt;
171
                o_fiq                   <= fiq_nxt;
172
                o_taken_ff              <= i_taken;
173
        end
174
end
175
 
176 34 Revanth
// Helpful for debug.
177
zap_decompile u_zap_decompile (
178 43 Revanth
        .i_instruction  ({1'd0, o_instruction}),
179
        .i_dav          (o_instruction_valid),
180
        .o_decompile    ()
181 34 Revanth
);
182
 
183
 
184 43 Revanth
endmodule // zap_thumb_decoder
185
 
186 26 Revanth
`default_nettype wire

powered by: WebSVN 2.1.0

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