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

Subversion Repositories ecpu_alu

[/] [ecpu_alu/] [trunk/] [barrel_shifter/] [simple/] [barrel_shifter_simple.working_nosynth.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
                                direction
8
                              );
9
  parameter DWIDTH = 8;
10
 
11
  input       [DWIDTH-1:0]    x         ;
12
  input       [DWIDTH-1:0]    y         ;
13
  output      [DWIDTH-1:0]    z         ;
14
  output                      c         ;
15
  input                       direction ;
16
 
17
  reg         [DWIDTH-1:0]    z         ;
18
  reg                         c         ;
19
 
20
  reg         [DWIDTH-1:0]    y_tmp     ;
21
 
22
 
23
  initial
24
  begin
25
    c = 1'b0;
26
    y_tmp = 'd0; // initialise for simulation purposes
27
  end
28
 
29
  always @(x or y or direction)
30
  begin
31
 
32
    z = x;
33
    c = 0;
34
    for (y_tmp={{DWIDTH-3{1'b0}},y[2:0]}; y_tmp > 0; y_tmp = y_tmp - 1)
35
    begin
36
 
37
      `ifdef DEBUG_BARREL_SHIFTER
38
        $display ("[%0t] D%0d z=%0b", $time, y_tmp, z);
39
      `endif
40
       if (direction)
41
       begin
42
         z = {z[0], z[DWIDTH-1:1]};
43
         c = z[0]                 ;
44
       end
45
       else
46
       begin
47
         z = {z[DWIDTH-2:0], z[DWIDTH-1]} ;
48
         c = z[DWIDTH-2]                  ;
49
       end
50
    end
51
 
52
  end
53
 
54
endmodule

powered by: WebSVN 2.1.0

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