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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [tbench/] [systemc/] [sc_cpu_if.h] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 antanguay
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "sc_cpu_if.h"                                     ////
4
////                                                              ////
5
////  This file is part of the "10GE MAC" project                 ////
6
////  http://www.opencores.org/cores/xge_mac/                     ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - A. Tanguay (antanguay@opencores.org)                  ////
10
////                                                              ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38
#ifndef CPU_IF_H
39
#define CPU_IF_H
40
 
41
#include "systemc.h"
42
 
43
#include "sc_scoreboard.h"
44
#include "sc_cpu_if.h"
45
 
46 29 antanguay
struct rmonStats_t {
47
    int tx_pkt_cnt;
48
    int rx_pkt_cnt;
49
 
50
    int tx_octets_cnt;
51
    int rx_octets_cnt;
52
};
53
 
54
 
55 2 antanguay
SC_MODULE(cpu_if) {
56
 
57
  public:
58
 
59
    //---
60
    // Ports
61
 
62
    sc_in<bool> wb_clk_i;
63
 
64
    sc_in<bool> wb_rst_i;
65
 
66
    sc_in<bool> wb_ack_o;
67
    sc_in<unsigned int> wb_dat_o;
68
    sc_in<bool> wb_int_o;
69
 
70
    sc_out<unsigned int> wb_adr_i;
71
    sc_out<bool> wb_cyc_i;
72
    sc_out<unsigned int> wb_dat_i;
73
    sc_out<bool> wb_stb_i;
74
    sc_out<bool> wb_we_i;
75
 
76
    //---
77
    // Types
78
 
79
    enum paramId {
80
        TX_ENABLE,
81
    };
82
 
83
    enum intId {
84
        INT_TXD_FIFO_OVFLOW = 0,
85
        INT_TXD_FIFO_UDFLOW = 1,
86
        INT_RXD_FIFO_OVFLOW = 2,
87
        INT_RXD_FIFO_UDFLOW = 3,
88
        INT_LOCAL_FAULT = 4,
89
        INT_REMOTE_FAULT = 5,
90
        INT_PAUSE_FRAME = 6,
91
        INT_CRC_ERROR = 7,
92
        INT_FRAGMENT_ERROR = 8,
93 29 antanguay
        INT_LENGHT_ERROR = 9,
94 2 antanguay
    };
95
 
96
    enum regId {
97
        CPUREG_CONFIG0 = 0x0,
98
 
99
        CPUREG_INT_PENDING = 0x8,
100
        CPUREG_INT_STATUS = 0xc,
101
        CPUREG_INT_MASK = 0x10,
102 29 antanguay
 
103
        CPUREG_STATSTXOCTETS = 0x80,
104
        CPUREG_STATSTXPKTS = 0x84,
105
 
106
        CPUREG_STATSRXOCTETS = 0x90,
107
        CPUREG_STATSRXPKTS = 0x94,
108 2 antanguay
    };
109
 
110
  private:
111
 
112
    //---
113
    // Variables
114
 
115
    scoreboard *sb;
116
    scoreboard::sbSourceId sb_id;
117
 
118
    sc_mutex bus_lock;
119 17 antanguay
    sc_semaphore bus_start;
120 2 antanguay
    sc_semaphore bus_done;
121
 
122
    uint bus_addr;
123
    uint bus_data;
124
    bool bus_write;
125
 
126
  public:
127
 
128
    //---
129
    // Variables
130
 
131
    //---
132
    // Functions
133
 
134
    void init();
135
    void connect_scoreboard(scoreboard *sbptr, scoreboard::sbSourceId sid);
136
    void set_param(cpu_if::paramId param, int value);
137
    void set_interrupt(cpu_if::intId intr);
138
    void set_interrupt_mask(cpu_if::intId intr, bool value);
139
    void enable_all_interrupts(void);
140 29 antanguay
    void get_rmon_stats(rmonStats_t *rmon_stats);
141 2 antanguay
 
142
    uint read(uint addr);
143
    void write(uint addr, uint data);
144
    void writebits(uint addr, uint hbit, uint lbit, uint value);
145
 
146
    //---
147
    // Threads
148
 
149
    void transactor();
150
    void monitor();
151
 
152 17 antanguay
    SC_CTOR(cpu_if): bus_start(0), bus_done(0) {
153 2 antanguay
 
154
        SC_CTHREAD (monitor, wb_clk_i.pos());
155
        SC_CTHREAD (transactor, wb_clk_i.pos());
156
 
157
    }
158
 
159
};
160
 
161
#endif

powered by: WebSVN 2.1.0

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