-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
litex: sim: Get sim working in litex-buildenv
Changes needed to get PLATFORM=sim to work again. The platforms/sim was basically copied from litex.boards.platforms.sim but then updated to properly handle sending the SimConfig details to the toolchain needed during building and running of the verilog backend.
- Loading branch information
Showing
3 changed files
with
70 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,62 @@ | ||
from litex.boards.platforms import sim | ||
from litex.boards.platforms.sim import * | ||
__all__ = ['SimPins', 'Platform'] | ||
from litex.build.generic_platform import * | ||
from litex.build.sim import SimPlatform | ||
|
||
from litex.build.sim.config import SimConfig | ||
|
||
class SimPins(Pins): | ||
def __init__(self, n): | ||
Pins.__init__(self, "s "*n) | ||
|
||
_io = [ | ||
("sys_clk", 0, SimPins(1)), | ||
("sys_rst", 0, SimPins(1)), | ||
("serial", 0, | ||
Subsignal("source_valid", SimPins(1)), | ||
Subsignal("source_ready", SimPins(1)), | ||
Subsignal("source_data", SimPins(8)), | ||
|
||
Subsignal("sink_valid", SimPins(1)), | ||
Subsignal("sink_ready", SimPins(1)), | ||
Subsignal("sink_data", SimPins(8)), | ||
), | ||
("eth_clocks", 0, | ||
Subsignal("none", SimPins(1)), | ||
), | ||
("eth", 0, | ||
Subsignal("source_valid", SimPins(1)), | ||
Subsignal("source_ready", SimPins(1)), | ||
Subsignal("source_data", SimPins(8)), | ||
|
||
Subsignal("sink_valid", SimPins(1)), | ||
Subsignal("sink_ready", SimPins(1)), | ||
Subsignal("sink_data", SimPins(8)), | ||
), | ||
("vga", 0, | ||
Subsignal("de", SimPins(1)), | ||
Subsignal("hsync", SimPins(1)), | ||
Subsignal("vsync", SimPins(1)), | ||
Subsignal("r", SimPins(8)), | ||
Subsignal("g", SimPins(8)), | ||
Subsignal("b", SimPins(8)), | ||
), | ||
] | ||
|
||
|
||
class Platform(SimPlatform): | ||
default_clk_name = "sys_clk" | ||
default_clk_period = 1000 # on modern computers simulate at ~ 1MHz | ||
|
||
def __init__(self): | ||
SimPlatform.__init__(self, "SIM", _io) | ||
|
||
def do_finalize(self, fragment): | ||
pass | ||
|
||
def build(self, fragment, **kwargs): | ||
scfg = SimConfig(default_clk="sys_clk") | ||
scfg.add_module("serial2console", "serial") | ||
if hasattr(fragment, 'localip'): | ||
scfg.add_module('ethernet', "eth", args={ "interface": "tap1", | ||
"ip": fragment.localip }) | ||
kwargs['sim_config'] = scfg | ||
return SimPlatform.build(self, fragment, **kwargs) |
This file contains 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
This file contains 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