121 static const uint32_t NIS_mask = 0x4045;
122 static const uint32_t AIS_mask = 0x27ba;
123 static const uint32_t NIS_bit = 1 << 16;
124 static const uint32_t AIS_bit = 1 << 15;
125 static const uint32_t IS_mask = NIS_mask | AIS_mask;
126 static const uint32_t IS_bits = NIS_bit | AIS_bit;
127 static const uint32_t BE_mask = 7;
130 EarlyReceive = 1 << 14,
132 EarlyTransmit = 1 << 10,
133 RxWatchdogTimeout = 1 << 9,
135 RxBufUnavailable = 1 << 7,
139 TxJabberTimeout = 1 << 3,
140 TxBufUnavailable = 1 << 2,
145 void setTxState(DwmacState::Tx
state)
147 m_dma_reg_status.ts =
state;
148 m_regstate_staled =
true;
151 void setRxState(DwmacState::Rx
state)
153 m_dma_reg_status.rs =
state;
154 m_regstate_staled =
true;
157 DwmacState::Tx getTxState()
const {
return m_dma_reg_status.ts; }
158 DwmacState::Rx getRxState()
const {
return m_dma_reg_status.rs; }
162 m_regstate_staled =
false;
169 m_dma_reg_status.value = 0;
172 void clear(uint32_t clear)
174 clear &= IS_mask | IS_bits;
176 if ((clear & NIS_mask) && !(clear & NIS_bit)) {
177 SCP_INFO(
"dwmac.h") <<
"Clearing normal interrupts without clearing NIS";
180 if ((clear & AIS_mask) && !(clear & AIS_bit)) {
181 SCP_INFO(
"dwmac.h") <<
"Clearing abnormal interrupts without clearing AIS";
184 m_interrupts &= ((~clear) & IS_mask);
186 if ((m_interrupts & NIS_mask) && (m_regmask & NIS_bit)) m_interrupts |= NIS_bit;
187 if ((m_interrupts & AIS_mask) && (m_regmask & AIS_bit)) m_interrupts |= AIS_bit;
189 m_regstate_staled =
true;
192 void fire(uint32_t interrupts)
194 interrupts &= m_regmask;
195 interrupts &= IS_mask;
197 if ((interrupts & NIS_mask) && (m_regmask & NIS_bit)) interrupts |= NIS_bit;
198 if ((interrupts & AIS_mask) && (m_regmask & AIS_bit)) interrupts |= AIS_bit;
199 m_interrupts |= interrupts;
200 m_regstate_staled =
true;
203 bool has_interrupts()
const {
return ((m_interrupts & m_regmask) != 0); }
205 void set_interrupts(uint32_t
mask) { m_regmask = (
mask & (IS_mask | IS_bits)); }
207 void set_status(uint32_t value) { clear(value & (IS_mask | IS_bits)); }
209 uint32_t interrupts()
const {
return m_regmask; }
211 uint32_t status()
const
213 if (m_regstate_staled) {
214 m_regstate = m_interrupts | m_dma_reg_status.value;
216 m_regstate_staled =
false;
222 mutable bool m_regstate_staled;
223 mutable uint32_t m_regstate;
226 uint32_t m_interrupts;
378class dwmac :
public sc_core::sc_module
381 bool warn_anregs =
true;
383 sc_core::sc_event m_tx_event;
384 sc_core::sc_event intr_wake;
388 void interrupts_fire(uint32_t interrupts);
389 void interrupts_clear(uint32_t interrupts);
403 static const uint32_t DMA_BUS_MODE = 0x1000;
404 static const uint32_t DMA_TX_POLL = 0x1004;
405 static const uint32_t DMA_RX_POLL = 0x1008;
406 static const uint32_t DMA_RX_DESC_LIST_ADDR = 0x100C;
407 static const uint32_t DMA_TX_DESC_LIST_ADDR = 0x1010;
408 static const uint32_t DMA_STATUS = 0x1014;
409 static const uint32_t DMA_OPERATION_MODE = 0x1018;
410 static const uint32_t DMA_INTERRUPTS = 0x101C;
411 static const uint32_t DMA_COUNTERS = 0x1020;
412 static const uint32_t DMA_RX_INT_WDT = 0x1024;
413 static const uint32_t DMA_AXI_BUS_MODE = 0x1028;
414 static const uint32_t DMA_CURRENT_TX_DESC = 0x1048;
415 static const uint32_t DMA_CURRENT_RX_DESC = 0x104C;
416 static const uint32_t DMA_CURRENT_TX_BUF = 0x1050;
417 static const uint32_t DMA_CURRENT_RX_BUF = 0x1054;
418 static const uint32_t HW_FEATURE = 0x1058;
434 uint32_t desc_size() {
return (bus_mode.atds == 0) ? 16 : 32; }
440 static const uint32_t DWMAC_VERSION_VALUE = 0x0010;
442 static const uint32_t DWMAC_CONFIGURATION = 0x0000;
443 static const uint32_t DWMAC_FRAME_FILTER = 0x0004;
444 static const uint32_t DWMAC_HASH_TABLE_HI = 0x0008;
445 static const uint32_t DWMAC_HASH_TABLE_LO = 0x000C;
446 static const uint32_t DWMAC_GMII_ADDRESS = 0x0010;
447 static const uint32_t DWMAC_GMII_DATA = 0x0014;
448 static const uint32_t DWMAC_FLOW_CONTROL = 0x0018;
449 static const uint32_t DWMAC_VLAN_TAG = 0x001C;
450 static const uint32_t DWMAC_VERSION = 0x0020;
451 static const uint32_t DWMAC_WAKE_UP_FILTER = 0x0028;
452 static const uint32_t DWMAC_PMT = 0x002C;
453 static const uint32_t DWMAC_INTERRUPT = 0x0038;
454 static const uint32_t DWMAC_INTERRUPT_MASK = 0x003C;
455 static const uint32_t DWMAC_AN_CONTROL = 0x00C0;
456 static const uint32_t DWMAC_AN_STATUS = 0x00C4;
457 static const uint32_t DWMAC_AN_ADVERTISEMENT = 0x00C8;
458 static const uint32_t DWMAC_AN_LINK_PARTNER_ABILITY = 0x00CC;
459 static const uint32_t DWMAC_AN_EXPANSION = 0x00D0;
460 static const uint32_t DWMAC_MAC0_HI = 0x0040;
461 static const uint32_t DWMAC_MAC0_LO = 0x0044;
462 static const uint32_t DWMAC_MACn = 0x0048;
463 static const uint32_t DWMAC_MMC_CONTROL = 0x0100;
464 static const uint32_t DWMAC_MMC_RX_INT = 0x0104;
465 static const uint32_t DWMAC_MMC_TX_INT = 0x0108;
466 static const uint32_t DWMAC_MMC_RX_INT_MASK = 0x010C;
467 static const uint32_t DWMAC_MMC_TX_INT_MASK = 0x0110;
468 static const uint32_t DWMAC_MMC_IPC_RX_INT_MASK = 0x0200;
469 static const uint32_t DWMAC_MMC_IPC_RX_INT = 0x0208;
471 static const uint32_t MACn_COUNT = 15;
473 uint32_t m_configuration;
474 uint32_t m_frame_filter;
475 uint32_t m_hash_table_hi;
476 uint32_t m_hash_table_lo;
478 uint32_t m_gmii_data;
479 uint32_t m_flow_control;
486 uint32_t m_axi_bus_mode;
489 sc_core::sc_out<bool> intr0, intr1;
490 tlm_utils::simple_target_socket<dwmac, DEFAULT_TLM_BUSWIDTH> socket;
498 m_backend->register_receive(
this, eth_rx_sc, eth_can_rx_sc);
503 static int eth_can_rx_sc(
void*
opaque) {
return 1; }
508 dwmac(sc_core::sc_module_name name);
514 void b_transport(tlm::tlm_generic_payload&
trans, sc_core::sc_time& delay)
516 unsigned char*
ptr =
trans.get_data_ptr();
519 trans.set_dmi_allowed(
false);
520 trans.set_response_status(tlm::TLM_OK_RESPONSE);
522 switch (
trans.get_command()) {
523 case tlm::TLM_WRITE_COMMAND:
526 case tlm::TLM_READ_COMMAND: