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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64/] [rtl/] [common/] [FT64_shifth.v] - Blame information for rev 47

Go to most recent revision | 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_shifth.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 RR      6'h02
30
`define AMO             6'h2F
31
`define AMOSHL          6'h0C
32
`define AMOSHR          6'h0D
33
`define AMOASR          6'h0E
34
`define AMOROL          6'h0F
35
`define AMOSHLI         6'h2C
36
`define AMOSHRI         6'h2D
37
`define AMOASRI         6'h2E
38
`define AMOROLI         6'h2F
39
`define SHIFTH  6'h3F
40
`define SHL     4'h0
41
`define SHR     4'h1
42
`define ASL     4'h2
43
`define ASR     4'h3
44
`define ROL     4'h4
45
`define ROR     4'h5
46
`define SHLI    4'h8
47
`define SHRI    4'h9
48
`define ASLI    4'hA
49
`define ASRI    4'hB
50
`define ROLI    4'hC
51
`define RORI    4'hD
52
//`endif
53
`define HIGHWORDH    63:32
54
 
55
module FT64_shifth(instr, a, b, res, ov);
56
parameter DMSB=31;
57
input [31:0] instr;
58
input [DMSB:0] a;
59
input [DMSB:0] b;
60
output [DMSB:0] res;
61
reg [DMSB:0] res;
62
output ov;
63
parameter ROTATE_INSN = 1;
64
 
65
wire [5:0] opcode = instr[5:0];
66
wire [5:0] func = instr[31:26];
67
wire [3:0] shiftop = instr[25:22];
68
 
69
wire [63:0] shl = {32'd0,a} << b[4:0];
70
wire [63:0] shr = {a,32'd0} >> b[4:0];
71
 
72
assign ov = 1'b0;
73
 
74
always @*
75
case(opcode)
76
`RR:
77
    case(func)
78
    `SHIFTH:
79
        case(shiftop)
80
        `SHLI,`ASLI:    res <= shl[DMSB:0];
81
        `SHL,`ASL:      res <= shl[DMSB:0];
82
        `SHRI:  res <= shr[`HIGHWORDH];
83
        `SHR:   res <= shr[`HIGHWORDH];
84
        `ASRI:  if (a[DMSB])
85
                    res <= (shr[`HIGHWORDH]) | ~({32{1'b1}} >> b[4:0]);
86
                else
87
                    res <= shr[`HIGHWORDH];
88
        `ASR:   if (a[DMSB])
89
                    res <= (shr[`HIGHWORDH]) | ~({32{1'b1}} >> b[4:0]);
90
                else
91
                    res <= shr[`HIGHWORDH];
92
        `ROL:   res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDH] : 32'hDEADDEAD;
93
        `ROLI:  res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDH] : 32'hDEADDEAD;
94
        `ROR:   res <= ROTATE_INSN ? shr[DMSB:0]|shr[`HIGHWORDH] : 32'hDEADDEAD;
95
        `RORI:  res <= ROTATE_INSN ? shr[DMSB:0]|shr[`HIGHWORDH] : 32'hDEADDEAD;
96
        default: res <= 32'd0;
97
        endcase
98
    default:    res <= 32'd0;
99
    endcase
100
`AMO:
101
        case(func)
102
        `AMOSHL,`AMOSHLI:       res <= shl[DMSB:0];
103
        `AMOSHR,`AMOSHRI:       res <= shr[`HIGHWORDH];
104
        `AMOASR,`AMOASRI:       if (a[DMSB])
105
                                res <= (shr[`HIGHWORDH]) | ~({32{1'b1}} >> b[4:0]);
106
                                else
107
                                res <= shr[`HIGHWORDH];
108
    `AMOROL:    res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDH] : 32'hDEADDEAD;
109
    `AMOROLI:   res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDH] : 32'hDEADDEAD;
110
        default:        res <= 32'd0;
111
        endcase
112
default:        res <= 32'd0;
113
endcase
114
 
115
endmodule
116
 

powered by: WebSVN 2.1.0

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