2020-11-23 07:40:54 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
#
|
|
|
|
# This file is part of LiteEth.
|
|
|
|
#
|
2023-06-13 08:13:03 -04:00
|
|
|
# Copyright (c) 2020-2023 Florent Kermarrec <florent@enjoy-digital.fr>
|
2020-11-23 07:40:54 -05:00
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
|
|
|
import os
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
from migen import *
|
|
|
|
|
2023-06-13 08:13:03 -04:00
|
|
|
from litex.gen import *
|
|
|
|
|
2022-05-02 07:09:28 -04:00
|
|
|
from litex_boards.platforms import digilent_genesys2
|
|
|
|
from litex_boards.targets.digilent_genesys2 import _CRG
|
2020-11-23 07:40:54 -05:00
|
|
|
|
|
|
|
from litex.soc.cores.clock import *
|
|
|
|
from litex.soc.interconnect.csr import *
|
|
|
|
from litex.soc.integration.soc_core import *
|
|
|
|
from litex.soc.integration.builder import *
|
|
|
|
|
|
|
|
from liteeth.phy.s7rgmii import LiteEthPHYRGMII
|
|
|
|
|
|
|
|
# Bench SoC ----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class BenchSoC(SoCCore):
|
|
|
|
def __init__(self, sys_clk_freq=int(50e6)):
|
2022-05-02 07:09:28 -04:00
|
|
|
platform = digilent_genesys2.Platform()
|
2020-11-23 07:40:54 -05:00
|
|
|
|
|
|
|
# SoCMini ----------------------------------------------------------------------------------
|
2020-11-23 11:11:36 -05:00
|
|
|
SoCMini.__init__(self, platform, clk_freq=sys_clk_freq,
|
|
|
|
ident = "LiteEth bench on Genesys2",
|
|
|
|
ident_version = True
|
|
|
|
)
|
2020-11-23 07:40:54 -05:00
|
|
|
|
|
|
|
# CRG --------------------------------------------------------------------------------------
|
2023-06-13 08:13:03 -04:00
|
|
|
self.crg = _CRG(platform, sys_clk_freq)
|
2020-11-23 07:40:54 -05:00
|
|
|
|
|
|
|
# Etherbone --------------------------------------------------------------------------------
|
2023-06-13 08:13:03 -04:00
|
|
|
self.ethphy = LiteEthPHYRGMII(
|
2020-11-23 07:40:54 -05:00
|
|
|
clock_pads = self.platform.request("eth_clocks"),
|
|
|
|
pads = self.platform.request("eth"),
|
|
|
|
with_hw_init_reset = False)
|
2020-11-25 09:13:55 -05:00
|
|
|
self.add_etherbone(phy=self.ethphy, buffer_depth=255)
|
2020-11-23 07:40:54 -05:00
|
|
|
|
2020-11-23 11:11:36 -05:00
|
|
|
# SRAM -------------------------------------------------------------------------------------
|
|
|
|
self.add_ram("sram", 0x20000000, 0x1000)
|
|
|
|
|
2020-11-23 07:40:54 -05:00
|
|
|
# Leds -------------------------------------------------------------------------------------
|
|
|
|
from litex.soc.cores.led import LedChaser
|
2023-06-13 08:13:03 -04:00
|
|
|
self.leds = LedChaser(
|
2020-11-23 07:40:54 -05:00
|
|
|
pads = platform.request_all("user_led"),
|
|
|
|
sys_clk_freq = sys_clk_freq)
|
|
|
|
|
|
|
|
# Main ---------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(description="LiteEth Bench on Genesys2")
|
|
|
|
parser.add_argument("--build", action="store_true", help="Build bitstream")
|
|
|
|
parser.add_argument("--load", action="store_true", help="Load bitstream")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
soc = BenchSoC()
|
|
|
|
builder = Builder(soc, csr_csv="csr.csv")
|
|
|
|
builder.build(run=args.build)
|
|
|
|
|
|
|
|
if args.load:
|
|
|
|
prog = soc.platform.create_programmer()
|
|
|
|
prog.load_bitstream(os.path.join(builder.gateware_dir, soc.build_name + ".bit"))
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|