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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [rtl/] [common/] [FT64_shifth.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 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 R2      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 SHL     3'h0
40
`define SHR     3'h1
41
`define ASL     3'h2
42
`define ASR     3'h3
43
`define ROL     3'h4
44
`define ROR     3'h5
45
//`endif
46
`define HIGHWORDH    63:32
47
 
48
module FT64_shifth(instr, a, b, res, ov);
49
parameter DMSB=31;
50
input [47:0] instr;
51
input [DMSB:0] a;
52
input [DMSB:0] b;
53
output [DMSB:0] res;
54
reg [DMSB:0] res;
55
output ov;
56
parameter ROTATE_INSN = 1;
57
 
58
wire [5:0] opcode = instr[5:0];
59
wire [5:0] func = instr[31:26];
60
wire [3:0] shiftop = instr[35:33];
61
wire [4:0] bb = instr[29] ? instr[17:13] : b[4:0];
62
wire [63:0] shl = {32'd0,a} << bb;
63
wire [63:0] shr = {a,32'd0} >> bb;
64
 
65
assign ov = 1'b0;
66
 
67
always @*
68
case(opcode)
69
`R2:
70
  case(shiftop)
71
  `SHL,`ASL:    res <= shl[DMSB:0];
72
  `SHR: res <= shr[`HIGHWORDH];
73
  `ASR: if (a[DMSB])
74
              res <= (shr[`HIGHWORDH]) | ~({32{1'b1}} >> bb);
75
          else
76
              res <= shr[`HIGHWORDH];
77
  `ROL: res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDH] : 32'hDEADDEAD;
78
  `ROR: res <= ROTATE_INSN ? shr[DMSB:0]|shr[`HIGHWORDH] : 32'hDEADDEAD;
79
  default: res <= 32'd0;
80
  endcase
81
`AMO:
82
        case(func)
83
        `AMOSHL,`AMOSHLI:       res <= shl[DMSB:0];
84
        `AMOSHR,`AMOSHRI:       res <= shr[`HIGHWORDH];
85
        `AMOASR,`AMOASRI:       if (a[DMSB])
86
                                res <= (shr[`HIGHWORDH]) | ~({32{1'b1}} >> b[4:0]);
87
                                else
88
                                res <= shr[`HIGHWORDH];
89
    `AMOROL:    res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDH] : 32'hDEADDEAD;
90
    `AMOROLI:   res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDH] : 32'hDEADDEAD;
91
        default:        res <= 32'd0;
92
        endcase
93
default:        res <= 32'd0;
94
endcase
95
 
96
endmodule
97
 

powered by: WebSVN 2.1.0

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