1987e29a8858f606754d910e7f8024a15bb29a47
1 from migen
.fhdl
.std
import *
2 from migen
.bus
import wishbone
3 from migen
.bus
.transactions
import *
4 from migen
.sim
.generic
import run_simulation
6 from liteeth
.common
import *
7 from liteeth
.core
import LiteEthUDPIPCore
8 from liteeth
.core
.etherbone
import LiteEthEtherbone
10 from liteeth
.test
.common
import *
11 from liteeth
.test
.model
import phy
, mac
, arp
, ip
, udp
, etherbone
13 ip_address
= 0x12345678
14 mac_address
= 0x12345678abcd
18 self
.submodules
.phy_model
= phy
.PHY(8, debug
=True)
19 self
.submodules
.mac_model
= mac
.MAC(self
.phy_model
, debug
=True, loopback
=False)
20 self
.submodules
.arp_model
= arp
.ARP(self
.mac_model
, mac_address
, ip_address
, debug
=False)
21 self
.submodules
.ip_model
= ip
.IP(self
.mac_model
, mac_address
, ip_address
, debug
=True, loopback
=False)
22 self
.submodules
.udp_model
= udp
.UDP(self
.ip_model
, ip_address
, debug
=True, loopback
=False)
23 self
.submodules
.etherbone_model
= etherbone
.Etherbone(self
.udp_model
, debug
=True)
25 self
.submodules
.core
= LiteEthUDPIPCore(self
.phy_model
, mac_address
, ip_address
, 100000)
26 self
.submodules
.etherbone
= LiteEthEtherbone(self
.core
.udp
, 20000)
28 self
.submodules
.sram
= wishbone
.SRAM(1024)
29 self
.submodules
.interconnect
= wishbone
.InterconnectPointToPoint(self
.etherbone
.wishbone
.bus
, self
.sram
.bus
)
33 # use sys_clk for each clock_domain
34 self
.clock_domains
.cd_eth_rx
= ClockDomain()
35 self
.clock_domains
.cd_eth_tx
= ClockDomain()
37 self
.cd_eth_rx
.clk
.eq(ClockSignal()),
38 self
.cd_eth_rx
.rst
.eq(ResetSignal()),
39 self
.cd_eth_tx
.clk
.eq(ClockSignal()),
40 self
.cd_eth_tx
.rst
.eq(ResetSignal()),
43 def gen_simulation(self
, selfp
):
44 selfp
.cd_eth_rx
.rst
= 1
45 selfp
.cd_eth_tx
.rst
= 1
47 selfp
.cd_eth_rx
.rst
= 0
48 selfp
.cd_eth_tx
.rst
= 0
54 #packet = etherbone.EtherbonePacket()
56 #self.etherbone_model.send(packet)
59 writes
= etherbone
.EtherboneWrites(base_addr
=0x1000)
61 writes
.add(etherbone
.EtherboneWrite(i
))
62 record
= etherbone
.EtherboneRecord()
63 record
.writes
= writes
71 record
.byte_enable
= 0
75 packet
= etherbone
.EtherbonePacket()
76 packet
.records
= [record
]
79 self
.etherbone_model
.send(packet
)
83 if __name__
== "__main__":
84 run_simulation(TB(), ncycles
=1024, vcd_name
="my.vcd", keep_files
=True)