Skip to content

Commit

Permalink
integration: cleanup config/constant handling
Browse files Browse the repository at this point in the history
sbourdeauducq committed Nov 8, 2016
1 parent 72556a6 commit 745ff12
Showing 3 changed files with 13 additions and 15 deletions.
9 changes: 0 additions & 9 deletions misoc/integration/config.py

This file was deleted.

12 changes: 8 additions & 4 deletions misoc/integration/cpu_interface.py
Original file line number Diff line number Diff line change
@@ -205,7 +205,10 @@ def get_csr_rust(regions, constants, with_access_functions=True):
r += " }\n\n"

for name, value in constants:
if isinstance(value, str):
if value is None:
value = "1"
rstype = "u32"
elif isinstance(value, str):
value = "\"" + value + "\""
rstype = "&'static str"
else:
@@ -223,9 +226,10 @@ def get_rust_cfg(regions, constants):
r += "--cfg has_"+name.lower()+"\n"
for name, value in constants:
if name.upper().startswith("CONFIG_"):
r += "--cfg '"+name.lower()[7:]+"=\""+str(value)+"\"'\n"
if isinstance(value, int) and value != 0:
r += "--cfg has_"+name.lower()[7:]+"\n"
if value is None:
r += "--cfg "+name.lower()[7:]+"\n"
else:
r += "--cfg '"+name.lower()[7:]+"=\""+str(value)+"\"'\n"
return r


7 changes: 5 additions & 2 deletions misoc/integration/soc_core.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from operator import itemgetter

from migen import *

from misoc.cores import lm32, mor1kx, tmpu, identifier, timer, uart
from misoc.interconnect import wishbone, csr_bus, wishbone2csr
from misoc.integration.config import Config


__all__ = ["mem_decoder", "SoCCore", "soc_core_args", "soc_core_argdict"]
@@ -56,7 +57,7 @@ def __init__(self, platform, clk_freq,
self._wb_masters = []
self._wb_slaves = []

self.config = Config()
self.config = dict()

self.csr_devices = [
"uart_phy",
@@ -190,6 +191,8 @@ def do_finalize(self):
self.add_csr_region(name + "_" + memory.name_override, (self.mem_map["csr"] + 0x800*mapaddr) | self.shadow_base, self.csr_data_width, memory)
for name, constant in self.csrbankarray.constants:
self._constants.append(((name + "_" + constant.name).upper(), constant.value.value))
for name, value in sorted(self.config.items(), key=itemgetter(0)):
self._constants.append(("CONFIG_" + name.upper(), value))

# Interrupts
for nr, name in enumerate(self.interrupt_devices):

0 comments on commit 745ff12

Please sign in to comment.