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

Subversion Repositories ecpu_alu

[/] [ecpu_alu/] [trunk/] [barrel_shifter/] [simple/] [barrel_shifter_simple.v] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 leonous
`timescale 1ns/1ps
2
module alu_barrel_shifter  (
3
                                x         ,
4
                                y         ,
5
                                z         ,
6
                                c         ,
7
                                clk       ,
8
                                direction
9
                              );
10
  parameter DWIDTH = 8;
11
 
12
  input       [DWIDTH-1:0]    x         ;
13
  input       [DWIDTH-1:0]    y         ;
14
  output      [DWIDTH-1:0]    z         ;
15
  output                      c         ;
16
  input                       clk       ;
17
  input                       direction ;
18
 
19
  reg         [DWIDTH-1:0]    z         ;
20
  reg                         c         ;
21
 
22
  reg         [DWIDTH-1:0]    y_tmp     ;
23
 
24
 
25
  always @(negedge clk)
26
  begin
27
 
28
    z = x;
29
    c = 0;
30
 
31
    for (y_tmp={{DWIDTH-3{1'b0}},y[2:0]}; y_tmp > 0; y_tmp = y_tmp - 1)
32
    begin
33
 
34
      `ifdef DEBUG_BARREL_SHIFTER
35
        $display ("[%0t] D%0d z=%0b", $time, y_tmp, z);
36
      `endif
37
       if (direction)
38
       begin
39
         z = {z[0], z[DWIDTH-1:1]};
40
         c = z[0]                 ;
41
       end
42
       else
43
       begin
44
         z = {z[DWIDTH-2:0], z[DWIDTH-1]} ;
45
         c = z[DWIDTH-2]                  ;
46
       end
47
    end
48
 
49
  end
50
 
51
endmodule

powered by: WebSVN 2.1.0

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