Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -------------------------------------------------------------------------------------------------- 

2# Copyright (c) Lukas Vik. All rights reserved. 

3# 

4# This file is part of the tsfpga project. 

5# https://tsfpga.com 

6# https://gitlab.com/tsfpga/tsfpga 

7# -------------------------------------------------------------------------------------------------- 

8 

9from os import makedirs 

10from os.path import exists 

11 

12from vunit.ostools import Process 

13 

14from tsfpga.sby_writer import SbyWriter 

15 

16 

17class YosysProject: 

18 """ 

19 Used for handling a Yosys poject, synthesized with GHDL. 

20 Currently supports formal verification, but has no real build support. 

21 """ 

22 

23 def __init__( 

24 self, 

25 top=None, 

26 generics=None, 

27 formal_settings=None, 

28 ): 

29 self.top = top 

30 self.generics = dict() if generics is None else generics 

31 self.formal_settings = formal_settings 

32 

33 def run_formal(self, project_path, src_files, compiled_libraries): 

34 if not exists(project_path): 

35 makedirs(project_path) 

36 

37 run_symbiyosys_sby = project_path / "run_symbiyosys.sby" 

38 SbyWriter.write_sby( 

39 output_path=run_symbiyosys_sby, 

40 top=self.top, 

41 formal_settings=self.formal_settings, 

42 compiled_libraries=compiled_libraries, 

43 src_files=src_files, 

44 generics=self.generics, 

45 ) 

46 

47 sby_cmd = ["sby", "--yosys", "yosys -m ghdl", "-f", str(run_symbiyosys_sby)] 

48 

49 try: 

50 proc = Process(sby_cmd) 

51 proc.consume_output() 

52 status = True 

53 except Process.NonZeroExitCode: 

54 status = False 

55 

56 return status