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

Subversion Repositories hive

[/] [hive/] [trunk/] [v04.05/] [thread_ring.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 ericw
/*
2
--------------------------------------------------------------------------------
3
 
4
Module : thread_ring.v
5
 
6
--------------------------------------------------------------------------------
7
 
8
Function:
9
- Processor thread pipeline.
10
 
11
Instantiates:
12
- Nothing.
13
 
14
Notes:
15
- 8 stage pipeline.
16
- Counter in stage 0 ensures long-term correct operation.
17
 
18
--------------------------------------------------------------------------------
19
*/
20
 
21
module thread_ring
22
        #(
23
        parameter       integer                                                 THREADS                 = 8,    // threads
24
        parameter       integer                                                 THRD_W                  = 3     // thread width
25
        )
26
        (
27
        // clocks & resets
28
        input                   wire                                                            clk_i,  // clock
29
        input                   wire                                                            rst_i,  // async. reset, active high
30
        // threads
31
        output          wire    [THRD_W-1:0]                     thrd_0_o,
32
        output          wire    [THRD_W-1:0]                     thrd_1_o,
33
        output          wire    [THRD_W-1:0]                     thrd_2_o,
34
        output          wire    [THRD_W-1:0]                     thrd_3_o,
35
        output          wire    [THRD_W-1:0]                     thrd_4_o,
36
        output          wire    [THRD_W-1:0]                     thrd_5_o,
37
        output          wire    [THRD_W-1:0]                     thrd_6_o,
38
        output          wire    [THRD_W-1:0]                     thrd_7_o
39
        );
40
 
41
 
42
        /*
43
        ----------------------
44
        -- internal signals --
45
        ----------------------
46
        */
47
        reg                                     [THRD_W-1:0]                     thrd[0:THREADS-1];
48
        localparam                      [THRD_W-1:0]                     THRD_OS = 'd5;
49
 
50
 
51
        /*
52
        ================
53
        == code start ==
54
        ================
55
        */
56
 
57
 
58
        // pipeline thread
59
        integer j;
60
        always @ ( posedge clk_i or posedge rst_i ) begin
61
                if ( rst_i ) begin
62
                        for ( j = 0; j < THREADS; j = j + 1 ) begin
63
                                thrd[j] <= THRD_OS - j[THRD_W-1:0];
64
                        end
65
                end else begin
66
                        for ( j = 0; j < THREADS; j = j + 1 ) begin
67
                                if ( j == 0 ) thrd[j] <= thrd[j] + 1'b1;  // note: counter terminus
68
                                else thrd[j] <= thrd[j-1];
69
                        end
70
                end
71
        end
72
 
73
        // output thrd
74
        assign thrd_0_o = thrd[0];
75
        assign thrd_1_o = thrd[1];
76
        assign thrd_2_o = thrd[2];
77
        assign thrd_3_o = thrd[3];
78
        assign thrd_4_o = thrd[4];
79
        assign thrd_5_o = thrd[5];
80
        assign thrd_6_o = thrd[6];
81
        assign thrd_7_o = thrd[7];
82
 
83
 
84
endmodule

powered by: WebSVN 2.1.0

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