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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [rtl/] [common/] [FT64_shiftb.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_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 R2      6'h02
30
`define SHL     3'h0
31
`define SHR     3'h1
32
`define ASL     3'h2
33
`define ASR     3'h3
34
`define ROL     3'h4
35
`define ROR     3'h5
36
//`endif
37
`define HIGHWORDB    15:8
38
 
39
module FT64_shiftb(instr, a, b, res, ov);
40
parameter DMSB=7;
41
input [47:0] instr;
42
input [DMSB:0] a;
43
input [DMSB:0] b;
44
output [DMSB:0] res;
45
reg [DMSB:0] res;
46
output ov;
47
parameter ROTATE_INSN = 1;
48
 
49
wire [5:0] opcode = instr[5:0];
50
wire [3:0] shiftop = instr[35:33];
51
wire [2:0] bb = instr[29] ? instr[15:13] : b[2:0];
52
 
53
wire [15:0] shl = {8'd0,a} << bb[2:0];
54
wire [15:0] shr = {a,8'd0} >> bb[2:0];
55
 
56
assign ov = 1'b0;
57
 
58
always @*
59
case(opcode)
60
`R2:
61
        if (instr[7:6]==2'b01)
62
    case(shiftop)
63
    `SHL,`ASL:  res <= shl[DMSB:0];
64
    `SHR:       res <= shr[`HIGHWORDB];
65
    `ASR:       if (a[DMSB])
66
                res <= (shr[`HIGHWORDB]) | ~({8{1'b1}} >> bb[2:0]);
67
            else
68
                res <= shr[`HIGHWORDB];
69
    `ROL:       res <= ROTATE_INSN ? shl[DMSB:0]|shl[`HIGHWORDB] : 8'hDE;
70
    `ROR:       res <= ROTATE_INSN ? shr[DMSB:0]|shr[`HIGHWORDB] : 8'hDE;
71
    default: res <= 8'd0;
72
    endcase
73
default:        res <= 8'd0;
74
endcase
75
 
76
endmodule
77
 

powered by: WebSVN 2.1.0

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