Created
February 18, 2019 09:09
-
-
Save xobs/69bcf5b947926da89171c10ac7aff58e to your computer and use it in GitHub Desktop.
Sample CSR failing simulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# This variable defines all the external programs that this module | |
# relies on. lxbuildenv reads this variable in order to ensure | |
# the build will finish without exiting due to missing third-party | |
# programs. | |
LX_DEPENDENCIES = ["riscv", "icestorm", "yosys"] | |
# Import lxbuildenv to integrate the deps/ directory | |
import lxbuildenv | |
# Disable pylint's E1101, which breaks completely on migen | |
#pylint:disable=E1101 | |
#from migen import * | |
from migen import Module, Signal, Instance, ClockDomain, If, run_simulation | |
from migen.genlib.resetsync import AsyncResetSynchronizer | |
from litex.build.lattice.platform import LatticePlatform | |
from litex.build.generic_platform import Pins, IOStandard, Misc, Subsignal | |
from litex.soc.integration import SoCCore | |
from litex.soc.integration.builder import Builder | |
from litex.soc.integration.soc_core import csr_map_update | |
from litex.soc.interconnect import wishbone | |
from litex.soc.interconnect.csr import CSR, CSRStorage, AutoCSR | |
def counter_test(dut): | |
for i in range(20): | |
yield | |
class TestCSR(Module, AutoCSR): | |
def __init__(self): | |
self.counter = Signal(8) | |
self.submodules.test_value = CSRStorage(write_from_dev=True) | |
self.sync += [ | |
self.test_value.we.eq(1), | |
self.counter.eq(self.counter+1), | |
self.test_value.dat_w.eq(self.counter), | |
] | |
def main(): | |
dut = TestCSR() | |
run_simulation(dut, counter_test(dut), vcd_name="csr-test.vcd") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment