-
Notifications
You must be signed in to change notification settings - Fork 0
/
myplatform.py
47 lines (38 loc) · 1.73 KB
/
myplatform.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#
# This file is part of LiteX.
#
# Copyright (c) 2020 Pepijn de Vos <[email protected]>
# Copyright (c) 2015-2018 Florent Kermarrec <[email protected]>
# SPDX-License-Identifier: BSD-2-Clause
import os
from litex.build.generic_platform import GenericPlatform
from litex.build.gowin import common
import mygowin as gowin #Change for sv support
# GowinPlatform ------------------------------------------------------------------------------------
class GowinPlatform(GenericPlatform):
_bitstream_ext = ".fs"
_supported_toolchains = ["gowin", "apicula"]
def __init__(self, device, *args, toolchain="gowin", devicename=None, **kwargs):
GenericPlatform.__init__(self, device, *args, **kwargs)
if not devicename:
idx = device.find('-')
likely_name = f"{device[:idx]}-{device[idx+3]}"
raise ValueError(f"devicename not provided, maybe {likely_name}?")
self.devicename = devicename
if toolchain == "gowin":
self.toolchain = gowin.GowinToolchain()
elif toolchain == "apicula":
raise ValueError("Apicula toolchain needs more work")
else:
raise ValueError(f"Unknown toolchain {toolchain}")
def get_verilog(self, *args, special_overrides=dict(), **kwargs):
so = dict(common.gowin_special_overrides)
so.update(special_overrides)
return GenericPlatform.get_verilog(self, *args,
special_overrides = so,
attr_translate = self.toolchain.attr_translate,
**kwargs)
def build(self, *args, **kwargs):
return self.toolchain.build(self, *args, **kwargs)
def add_period_constraint(self, clk, period):
self.toolchain.add_period_constraint(self, clk, period)