Skip to content

Commit

Permalink
Rust CSR: generate --cfg flags for extant regions and CONFIG_* consts.
Browse files Browse the repository at this point in the history
whitequark committed Oct 4, 2016
1 parent 8806d93 commit 3dc110a
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions misoc/integration/builder.py
Original file line number Diff line number Diff line change
@@ -103,6 +103,8 @@ def define(k, v):
f.write(cpu_interface.get_mem_rust(memory_regions, flash_boot_address))
with open(os.path.join(generated_dir, "csr.rs"), "w") as f:
f.write(cpu_interface.get_csr_rust(csr_regions, constants))
with open(os.path.join(generated_dir, "rust-cfg"), "w") as f:
f.write(cpu_interface.get_rust_cfg(csr_regions, constants))

if sdram_phy_settings is not None:
with open(os.path.join(generated_dir, "sdram_phy.h"), "w") as f:
10 changes: 10 additions & 0 deletions misoc/integration/cpu_interface.py
Original file line number Diff line number Diff line change
@@ -217,6 +217,16 @@ def get_csr_rust(regions, constants, with_access_functions=True):
return r


def get_rust_cfg(regions, constants):
r = ""
for name, origin, busword, obj in regions:
r += "--cfg has_"+name.lower()+"\n"
for name, value in constants:
if name.upper().startswith("CONFIG_"):
r += "--cfg '"+name.lower()[7:]+"=\""+str(value)+"\"'\n"
return r


def get_csr_csv(regions):
r = ""
for name, origin, busword, obj in regions:

0 comments on commit 3dc110a

Please sign in to comment.