Skip to content

Commit

Permalink
Fix multiple top levels with Icarus
Browse files Browse the repository at this point in the history
  • Loading branch information
olofk committed Nov 3, 2022
1 parent 4044f2d commit 457f7d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions edalize/icarus.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
all: $(VPI_MODULES) $(TARGET)
$(TARGET):
iverilog -s$(TOPLEVEL) -c $(TARGET).scr -o $@ $(IVERILOG_OPTIONS)
iverilog $(TOPLEVEL) -c $(TARGET).scr -o $@ $(IVERILOG_OPTIONS)
run: $(VPI_MODULES) $(TARGET)
vvp -n -M. -l icarus.log $(patsubst %.vpi,-m%,$(VPI_MODULES)) $(VVP_OPTIONS) $(TARGET) -fst $(EXTRA_OPTIONS)
Expand Down Expand Up @@ -109,7 +109,11 @@ def configure_main(self):
_vpi_modules = " ".join([m["name"] + ".vpi" for m in self.vpi_modules])
if _vpi_modules:
f.write("VPI_MODULES := {}\n".format(_vpi_modules))
f.write("TOPLEVEL := {}\n".format(self.toplevel))
f.write(
"TOPLEVEL := {}\n".format(
" ".join(["-s" + x for x in self.toplevel.split()])
)
)
f.write(
"IVERILOG_OPTIONS := {}\n".format(
" ".join(self.tool_options.get("iverilog_options", []))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_icarus/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
TARGET := test_icarus_0
VPI_MODULES := vpi1.vpi vpi2.vpi
TOPLEVEL := top_module
TOPLEVEL := -stop_module
IVERILOG_OPTIONS := some iverilog_options
VVP_OPTIONS :=
EXTRA_OPTIONS ?= +plusarg_bool=1 +plusarg_int=42 +plusarg_str=hello

all: $(VPI_MODULES) $(TARGET)

$(TARGET):
iverilog -s$(TOPLEVEL) -c $(TARGET).scr -o $@ $(IVERILOG_OPTIONS)
iverilog $(TOPLEVEL) -c $(TARGET).scr -o $@ $(IVERILOG_OPTIONS)

run: $(VPI_MODULES) $(TARGET)
vvp -n -M. -l icarus.log $(patsubst %.vpi,-m%,$(VPI_MODULES)) $(VVP_OPTIONS) $(TARGET) -fst $(EXTRA_OPTIONS)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_icarus/minimal/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
TARGET := test_icarus_minimal_0
TOPLEVEL := top
TOPLEVEL := -stop
IVERILOG_OPTIONS :=
VVP_OPTIONS :=

all: $(VPI_MODULES) $(TARGET)

$(TARGET):
iverilog -s$(TOPLEVEL) -c $(TARGET).scr -o $@ $(IVERILOG_OPTIONS)
iverilog $(TOPLEVEL) -c $(TARGET).scr -o $@ $(IVERILOG_OPTIONS)

run: $(VPI_MODULES) $(TARGET)
vvp -n -M. -l icarus.log $(patsubst %.vpi,-m%,$(VPI_MODULES)) $(VVP_OPTIONS) $(TARGET) -fst $(EXTRA_OPTIONS)
Expand Down

0 comments on commit 457f7d0

Please sign in to comment.