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

Subversion Repositories xilinx_virtex_fp_library

[/] [xilinx_virtex_fp_library/] [trunk/] [SinglePathFPAdderMappedConversions/] [shifter.v] - Blame information for rev 15

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 constantin
 
2
 
3
`timescale 1ns / 1ps
4
//////////////////////////////////////////////////////////////////////////////////
5
// Company: 
6
// Engineer: 
7
// 
8
// Create Date:    18:00:33 10/15/2013 
9
// Design Name: 
10
// Module Name:    shifter 
11
// Project Name: 
12
// Target Devices: 
13
// Tool versions: 
14
// Description: 
15
//
16
// Dependencies: 
17
//
18
// Revision: 
19
// Revision 0.01 - File Created
20
// Additional Comments: 
21
//
22
//////////////////////////////////////////////////////////////////////////////////
23
 
24
module shifter #(       parameter                INPUT_SIZE = 13,
25
                                                parameter                SHIFT_SIZE = 4,
26
                                                parameter                OUTPUT_SIZE = 24, //>INPUT_SIZE
27
                                                parameter                DIRECTION = 1,
28
                                                parameter                PIPELINE = 1,
29
                                                parameter [7:0]          POSITION = 8'b00000000)
30
                                        (a, arith, shft, shifted_a);
31
 
32
        input [INPUT_SIZE-1:0]   a;
33
        input                    arith;
34
        input [SHIFT_SIZE-1:0]   shft;
35
        output [OUTPUT_SIZE-1:0] shifted_a;
36
 
37
 
38
 
39
        wire [OUTPUT_SIZE-1:0]   a_temp_d[SHIFT_SIZE:0];
40
        wire [OUTPUT_SIZE-1:0]   a_temp_q[SHIFT_SIZE:0];
41
 
42
        assign a_temp_q[0][OUTPUT_SIZE-1 : OUTPUT_SIZE-INPUT_SIZE] = a;
43
        assign a_temp_q[0][OUTPUT_SIZE-1-INPUT_SIZE : 0] = arith;
44
 
45
        generate
46
        begin : GENERATING
47
                genvar i;
48
                for (i = 0; i <= SHIFT_SIZE - 1; i = i + 1)
49
                begin : BARREL_SHIFTER_GENERATION
50
                        if (DIRECTION == 1)
51
                        begin : LEFT
52
                                //begin : 1st_check
53
                                        genvar j;
54
                                        for (j = 0; j <= OUTPUT_SIZE - 1; j = j + 1)
55
                                        begin : MUX_GEN_L
56
                                                if (j < 2 ** i)
57
                                                begin : ZERO_INS_L
58
                                                        assign a_temp_d[i][j] = (shft[i] == 1'b0) ? a_temp_q[i][j] : arith;
59
                                                end
60
 
61
                                                if (j >= 2 ** i)
62
                                                begin : BIT_INS_L
63
                                                        assign a_temp_d[i][j] = (shft[i] == 1'b0) ? a_temp_q[i][j] : a_temp_q[i][j-2**i];
64
                                                end
65
                                        end
66
                                //end
67
                                  end
68
 
69
                        if (DIRECTION == 0)
70
                        begin : RIGHT
71
                                //begin : 2nd_check
72
                                        genvar j;
73
                                        for (j = 0; j <= OUTPUT_SIZE - 1; j = j + 1)
74
                                        begin : MUX_GEN_R
75
                                                if (OUTPUT_SIZE - 1 < 2 ** i + j)
76
                                                begin : ZERO_INS_R
77
                                                        assign a_temp_d[i][j] = (shft[i] == 1'b0) ? a_temp_q[i][j] : arith;
78
                                                end
79
 
80
                                                if (OUTPUT_SIZE - 1 >= 2 ** i + j)
81
                                                begin : BIT_INS_R
82
                                                        assign a_temp_d[i][j] = (shft[i] == 1'b0) ? a_temp_q[i][j] : a_temp_q[i][j+2**i];
83
                                                end
84
                                        end
85
                                //end
86
                        end
87
 
88
                        if (PIPELINE != 0)
89
                        begin : PIPELINE_INSERTION
90
                                if (POSITION[i] == 1'b1)
91
                                begin : LATCH
92
                                        d_ff #(OUTPUT_SIZE) D_INS(.clk(clk), .rst(rst), .d(a_temp_d[i]), .q(a_temp_q[i + 1]));
93
                                end
94
 
95
                                if (POSITION[i] == 1'b0)
96
                                begin : NO_LATCH
97
                                        assign a_temp_q[i + 1] = a_temp_d[i];
98
                                end
99
                        end
100
 
101
                        if (PIPELINE == 0)
102
                        begin : NO_PIPELINE
103
                                assign a_temp_q[i + 1] = a_temp_d[i];
104
                        end
105
                end
106
        end
107
        endgenerate
108
 
109
        assign shifted_a = a_temp_q[SHIFT_SIZE];
110
 
111
endmodule
112
 

powered by: WebSVN 2.1.0

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