blob: 791f7c744ef689724722f320dde165b15b5a9bde [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001#!/bin/bash
2
3# Copyright lowRISC contributors.
4# Licensed under the Apache License, Version 2.0, see LICENSE for details.
5# SPDX-License-Identifier: Apache-2.0
6
7# This script converts all SystemVerilog RTL files to Verilog and then
8# runs Yosys.
9#
10# The following tools are required:
11# - sv2v: SystemVerilog-to-Verilog converter from github.com/zachjs/sv2v
12# - yosys: synthesis tool from github.com/YosysHQ/yosys
13#
14# Usage:
15# syn_yosys.sh 2>&1 | tee syn.std
16
17#-------------------------------------------------------------------------
18# use fusesoc to generate file list
19#-------------------------------------------------------------------------
20\rm -Rf build
21fusesoc --cores-root .. sim --build-only formal > /dev/null 2>&1
22
23# copy all files into directory "syn_out"
24\rm -Rf syn_out
25mkdir syn_out
26cp build/formal_0/src/*/*/*.sv build/formal_0/src/*/*/*/*.sv syn_out
27
28#-------------------------------------------------------------------------
29# convert all RTL files to Verilog
30#-------------------------------------------------------------------------
31cd syn_out
32
33# TODO: delete below file for now because sv2v currently crashes with it
34\rm -f hmac_pkg.sv
35
36for file in *.sv; do
37 module=`basename -s .sv $file`
38 echo $file
39 sv2v --oneunit *_pkg.sv prim_assert.sv $file > ${module}.v
40done
41
42# remove *pkg.v files (they are empty files and not needed)
43\rm -Rf *_pkg.v
44
45#-------------------------------------------------------------------------
46# run yosys
47#-------------------------------------------------------------------------
48
49# for now, read in each verilog file into Yosys and only output errors
50# and warnings
51for file in *.v; do
52 yosys -QTqp "read_verilog ${file}"
53done
54
55cd -
56
57# TODOs:
58# - add LEC to check if generated Verilog is equivalent to original SV
59# - add full yosys synthesis for all modules
60# - add final LEC check (RTL-versus-netlist)