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

Subversion Repositories hive

[/] [hive/] [trunk/] [v01.10/] [vector_sr.v] - Blame information for rev 8

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

Line No. Rev Author Line
1 3 ericw
/*
2
--------------------------------------------------------------------------------
3
 
4
Module: vector_sr.v
5
 
6
Function:
7
- Vector I/O shift register.
8
 
9
Instantiates:
10
- Nothing.
11
 
12
Notes:
13
- Parameters for regs depth, data width, and async reset value.
14
- REGS=0 generates a wire.
15
 
16
--------------------------------------------------------------------------------
17
*/
18
 
19
 
20
module vector_sr
21
        #(
22
        parameter       integer                                 REGS                                    = 4,                    // number of registers
23
        parameter       integer                                 DATA_W                          = 2,                    // I/O data width
24
        parameter       [DATA_W-1:0]                     RESET_VAL                       = 0                      // regs async reset value
25
        )
26
        (
27
        // clocks & resets
28
        input           wire                                                    clk_i,                                                          // clock
29
        input           wire                                                    rst_i,                                                          // async. reset, active high
30
        // I/O
31
        input           wire    [DATA_W-1:0]             data_i,                                                         // data in
32
        output  wire    [DATA_W-1:0]             data_o                                                          // data out
33
        );
34
 
35
 
36
        /*
37
        ----------------------
38
        -- internal signals --
39
        ----------------------
40
        */
41
        genvar                                                                  i;
42
 
43
 
44
        /*
45
        ================
46
        == code start ==
47
        ================
48
        */
49
 
50
 
51
        // generate regs pipeline
52
        generate
53
                if ( REGS == 0 ) begin
54
                        assign data_o = data_i;
55
                end else begin
56
                        reg [DATA_W-1:0] stage[0:REGS-1];
57
                        for ( i=0; i<REGS; i=i+1 ) begin : loop
58
                                always @ ( posedge clk_i or posedge rst_i ) begin
59
                                        if ( rst_i ) begin
60
                                                stage[i] <= RESET_VAL;
61
                                        end else begin
62
                                                stage[i] <= ( i == REGS-1 ) ? data_i : stage[i+1];
63
                                        end
64
                                end
65
                        end  // endfor : loop
66
                        assign data_o = stage[0];
67
                end
68
        endgenerate
69
 
70
 
71
endmodule

powered by: WebSVN 2.1.0

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