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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64/] [rtl/] [common/] [FT64_shiftb.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_shiftb.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 SHIFTB  6'h1F
31
`define SHL     4'h0
32
`define SHR     4'h1
33
`define ASL     4'h2
34
`define ASR     4'h3
35
`define ROL     4'h4
36
`define ROR     4'h5
37
`define SHLI    4'h8
38
`define SHRI    4'h9
39
`define ASLI    4'hA
40
`define ASRI    4'hB
41
`define ROLI    4'hC
42
`define RORI    4'hD
43
//`endif
44
`define HIGHWORDB    15:8
45
 
46
module FT64_shiftb(instr, a, b, res, ov);
47
parameter DMSB=7;
48
input [31:0] instr;
49
input [DMSB:0] a;
50
input [DMSB:0] b;
51
output [DMSB:0] res;
52
reg [DMSB:0] res;
53
output ov;
54
parameter ROTATE_INSN = 1;
55
 
56
wire [5:0] opcode = instr[5:0];
57
wire [5:0] func = instr[31:26];
58
wire [3:0] shiftop = instr[25:22];
59
 
60
wire [15:0] shl = {8'd0,a} << b[2:0];
61
wire [15:0] shr = {a,8'd0} >> b[2:0];
62
 
63
assign ov = 1'b0;
64
 
65
always @*
66
case(opcode)
67
`RR:
68
    case(func)
69
    `SHIFTB:
70
        case(shiftop)
71
        `SHLI,`ASLI:    res <= shl[DMSB:0];
72
        `SHL,`ASL:      res <= shl[DMSB:0];
73
        `SHRI:  res <= shr[`HIGHWORDB];
74
        `SHR:   res <= shr[`HIGHWORDB];
75
        `ASRI:  if (a[DMSB])
76
                    res <= (shr[`HIGHWORDB]) | ~({8{1'b1}} >> b[2:0]);
77
                else
78
                    res <= shr[`HIGHWORDB];
79
        `ASR:   if (a[DMSB])
80
                    res <= (shr[`HIGHWORDB]) | ~({8{1'b1}} >> b[2:0]);
81
                else
82
                    res <= shr[`HIGHWORDB];
83
        `ROL:   res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDB] : 8'hDE;
84
        `ROLI:  res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDB] : 8'hDE;
85
        `ROR:   res <= ROTATE_INSN ? shr[DMSB:0]|shr[`HIGHWORDB] : 8'hDE;
86
        `RORI:  res <= ROTATE_INSN ? shr[DMSB:0]|shr[`HIGHWORDB] : 8'hDE;
87
        default: res <= 8'd0;
88
        endcase
89
    default:    res <= 8'd0;
90
    endcase
91
default:        res <= 8'd0;
92
endcase
93
 
94
endmodule
95
 

powered by: WebSVN 2.1.0

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