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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64/] [rtl/] [common/] [FT64_shift.v] - Blame information for rev 43

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 43 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2016-2018  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
//      FT64_shift.v
10
//              
11
//
12
// This source file is free software: you can redistribute it and/or modify 
13
// it under the terms of the GNU Lesser General Public License as published 
14
// by the Free Software Foundation, either version 3 of the License, or     
15
// (at your option) any later version.                                      
16
//                                                                          
17
// This source file is distributed in the hope that it will be useful,      
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
20
// GNU General Public License for more details.                             
21
//                                                                          
22
// You should have received a copy of the GNU General Public License        
23
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
24
//                                                                          
25
//
26
// ============================================================================
27
//
28
//`ifndef SHL
29
`define VECTOR  6'h01
30
`define VSHL        6'h0C
31
`define VSHR        6'h0D
32
`define VASR        6'h0E
33
`define RR      6'h02
34
`define SHIFT   6'h0F
35
`define AMO             6'h2F
36
`define AMOSHL          6'h0C
37
`define AMOSHR          6'h0D
38
`define AMOASR          6'h0E
39
`define AMOROL          6'h0F
40
`define AMOSHLI         6'h2C
41
`define AMOSHRI         6'h2D
42
`define AMOASRI         6'h2E
43
`define AMOROLI         6'h2F
44
`define SHL     4'h0
45
`define SHR     4'h1
46
`define ASL     4'h2
47
`define ASR     4'h3
48
`define ROL     4'h4
49
`define ROR     4'h5
50
`define SHLI    4'h8
51
`define SHRI    4'h9
52
`define ASLI    4'hA
53
`define ASRI    4'hB
54
`define ROLI    4'hC
55
`define RORI    4'hD
56
//`endif
57
`define HIGHWORD    127:64
58
 
59
module FT64_shift(instr, a, b, res, ov);
60
parameter DMSB=63;
61
parameter SUP_VECTOR = 1;
62
input [31:0] instr;
63
input [DMSB:0] a;
64
input [DMSB:0] b;
65
output [DMSB:0] res;
66
reg [DMSB:0] res;
67
output ov;
68
parameter ROTATE_INSN = 1;
69
 
70
wire [5:0] opcode = instr[5:0];
71
wire [5:0] func = instr[31:26];
72
wire [3:0] shiftop = instr[25:22];
73
 
74
wire [127:0] shl = {64'd0,a} << b[5:0];
75
wire [127:0] shr = {a,64'd0} >> b[5:0];
76
 
77
assign ov = shl[127:64] != {64{a[63]}};
78
 
79
always @*
80
case(opcode)
81
`VECTOR:
82
    if (SUP_VECTOR)
83
        case(func)
84
        `VSHL:      res <= shl[DMSB:0];
85
        `VSHR:      res <= shr[`HIGHWORD];
86
        `VASR:      if (a[DMSB])
87
                        res <= (shr[`HIGHWORD]) | ~({64{1'b1}} >> b[5:0]);
88
                    else
89
                        res <= shr[`HIGHWORD];
90
        default:    res <= 64'd0;
91
        endcase
92
    else
93
        res <= 64'd0;
94
`RR:
95
    case(func)
96
    `SHIFT:
97
        case(shiftop)
98
        `SHLI,`ASLI:res <= shl[DMSB:0];
99
        `SHL,`ASL:      res <= shl[DMSB:0];
100
        `SHRI:  res <= shr[`HIGHWORD];
101
        `SHR:   res <= shr[`HIGHWORD];
102
        `ASRI:  if (a[DMSB])
103
                    res <= (shr[`HIGHWORD]) | ~({64{1'b1}} >> b[5:0]);
104
                else
105
                    res <= shr[`HIGHWORD];
106
        `ASR:   if (a[DMSB])
107
                    res <= (shr[`HIGHWORD]) | ~({64{1'b1}} >> b[5:0]);
108
                else
109
                    res <= shr[`HIGHWORD];
110
        `ROL:   res <= ROTATE_INSN ? shl[63:0]|shl[`HIGHWORD] : 64'hDEADDEADDEAD;
111
        `ROLI:  res <= ROTATE_INSN ? shl[63:0]|shl[`HIGHWORD] : 64'hDEADDEADDEAD;
112
        `ROR:   res <= ROTATE_INSN ? shr[63:0]|shr[`HIGHWORD] : 64'hDEADDEADDEAD;
113
        `RORI:  res <= ROTATE_INSN ? shr[63:0]|shr[`HIGHWORD] : 64'hDEADDEADDEAD;
114
        default: res <= 64'd0;
115
        endcase
116
    default:    res <= 64'd0;
117
    endcase
118
`AMO:
119
        case(func)
120
        `AMOSHL,`AMOSHLI:       res <= shl[DMSB:0];
121
        `AMOSHR,`AMOSHRI:       res <= shr[`HIGHWORD];
122
        `AMOASR,`AMOASRI:       if (a[DMSB])
123
                                res <= (shr[`HIGHWORD]) | ~({64{1'b1}} >> b[5:0]);
124
                                else
125
                                res <= shr[`HIGHWORD];
126
    `AMOROL:    res <= ROTATE_INSN ? shl[63:0]|shl[`HIGHWORD] : 64'hDEADDEADDEAD;
127
    `AMOROLI:   res <= ROTATE_INSN ? shl[63:0]|shl[`HIGHWORD] : 64'hDEADDEADDEAD;
128
        default:        res <= 64'd0;
129
        endcase
130
default:        res <= 64'd0;
131
endcase
132
 
133
endmodule
134
 

powered by: WebSVN 2.1.0

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