Cocotb

From Robin

Revision as of 10:28, 6 December 2023 by Yngveha (Talk | contribs)
Jump to: navigation, search

Contents

For å kjøre Cocotb (etter installasjon - )

Om cocotb

Cocotb sørger for at vi linker simulator (her: GHDL eller Questa) med python. Under simulering kjøres vekselvis simulator eller python fil- de kjører ikke samtidig. De triggerne (await..) vi bruker i python testbenken bestemmer når simulatoren overlater roret til python koden. Etter simuleringen er ferdig så ramser cocotb opp kjøreresultatet.

Kjøre cocotb

  • I folderen med makefile, kjør
make

Makefil

Makefila sørger for kompilering og kjøring av Cocotb, samt evt kjøring av GUI eller lagring av waveform fil

  • tb_<modulnavn>.py må inneholde python-testbenken
  • Makefile for GHDL
# Makefile for GHDL
# defaults
SIM ?= ghdl
TOPLEVEL_LANG ?= vhdl
# VHDL 2008
EXTRA_ARGS +=--std=08
# TOPLEVEL is the name of the toplevel module in your VHDL file
TOPLEVEL = first
VHDL_SOURCES += $(PWD)/../lab1/$(TOPLEVEL).vhd
#VHDL_SOURCES += $(PWD)/../../hdl/*.vhdl
SIM_ARGS +=--wave=$(TOPLEVEL).ghw
# MODULE is the basename of the Python test file
MODULE = tb_$(TOPLEVEL)
# include cocotb's make rules to take care of the simulator setup
include $(shell cocotb-config --makefiles)/Makefile.sim
# removing generated binary of top entity and .o-file on make clean
clean::
-@rm -f $(TOPLEVEL)
-@rm -f e~$(TOPLEVEL).o
  • Makefile for Questa
    • MERK: Dette oppretter folderen /sim_build/
      • Hvis den finnes fra før kan det gi problemer
      • /sim_build/ kan trygt slettes
# Makefile

# defaults
#SIM ?= ghdl
SIM ?= questa
TOPLEVEL_LANG ?= vhdl   
#GUI  Starter modelsim GUI
GUI =1 

# VHDL 2008
#EXTRA_ARGS +=--std=08 

# TOPLEVEL is the name of the toplevel module in your VHDL file
TOPLEVEL ?= qcount

#VHDL_SOURCES += $(PWD)/../src/$(TOPLEVEL).vhd*
VHDL_SOURCES += $(PWD)/../src/*.vhd*

# SIM_ARGS is Simulation arguments. --wave determines name and type of waveform  
#SIM_ARGS+=--vcd=$(TOPLEVEL).vcd

# legges til i sim_build/ runsim.do --  
# add log -r *
# vcd file wave.vcd 
# vcd add -r /*
# run -all
# quit -sim

# -g<GENERIC> is used to set generics defined in the toplevel entity
# SIM_ARGS +=-gWIDTH=4

# MODULE is the basename of the Python test file
MODULE ?= tb_min

# include cocotb's make rules to take care of the simulator setup
include $(shell cocotb-config --makefiles)/Makefile.sim

# removing generated binary of top entity and .o-file on make clean
clean::
	-@rm -f $(TOPLEVEL)
	-@rm -f e~$(TOPLEVEL).o

WSL

For å starte windows explorer under WSL (i katalogen du står i)

explorer.exe .
# ikke glem punktumet
Personal tools
Front page