Fix kasli_soc-demo compilation error with cfg #250

Merged
sb10q merged 2 commits from morgan/artiq-zynq:bugfix into master 2023-08-30 15:33:45 +08:00
1 changed files with 0 additions and 2 deletions
Showing only changes of commit b5f58401c5 - Show all commits

View File

@ -310,7 +310,6 @@ class GenericMaster(SoCCore):
self.add_csr_group("grabber", self.grabber_csr_group) self.add_csr_group("grabber", self.grabber_csr_group)
self.rustc_cfg["has_virtual_leds"] = None
self.submodules.virtual_leds = virtual_leds.VirtualLeds() self.submodules.virtual_leds = virtual_leds.VirtualLeds()
self.csr_devices.append("virtual_leds") self.csr_devices.append("virtual_leds")
@ -483,7 +482,6 @@ class GenericSatellite(SoCCore):
self.add_csr_group("grabber", self.grabber_csr_group) self.add_csr_group("grabber", self.grabber_csr_group)
# no RTIO CRG here # no RTIO CRG here
self.rustc_cfg["has_virtual_leds"] = None
self.submodules.virtual_leds = virtual_leds.VirtualLeds() self.submodules.virtual_leds = virtual_leds.VirtualLeds()
self.csr_devices.append("virtual_leds") self.csr_devices.append("virtual_leds")
Outdated
Review

IIRC misoc does that by default for all CSR cores and those lines are not necessary?

IIRC misoc does that by default for all CSR cores and those lines are not necessary?

Running python src/gateware/kasli_soc.py -r build/pl.rs -c build/rustc-cfg -m build/mem.rs kasli-soc-satellite.json with the line omitted, the build/rust-cfg don't have the has_virtual_leds line

build/rust-cfg

has_drtio
has_drtio_routing
has_grabber
has_si5324
has_siphaser
hw_rev="v1.1"
ki_impl="csr"
rtio_frequency="125.0"
si5324_soft_reset
Running `python src/gateware/kasli_soc.py -r build/pl.rs -c build/rustc-cfg -m build/mem.rs kasli-soc-satellite.json` with the line omitted, the `build/rust-cfg` don't have the `has_virtual_leds` line ### build/rust-cfg ``` has_drtio has_drtio_routing has_grabber has_si5324 has_siphaser hw_rev="v1.1" ki_impl="csr" rtio_frequency="125.0" si5324_soft_reset ```
Outdated
Review
https://github.com/m-labs/misoc/blob/master/misoc/integration/cpu_interface.py#L305 Please find out what is going on.
Outdated
Review

You may want to check migen-axi as well - it might not share this code with misoc.

You may want to check migen-axi as well - it might not share this code with misoc.

Difference between artiq and artiq-zynq

  • In artiq repo, the rust-cfg is generated by calling f.write(cpu_interface.get_rust_cfg(soc.get_csr_regions(), soc.get_constants())) in the misoc/integration/build.py.

    • get_rust_cfg analyze the content of soc.get_csr_regions() and soc.get_constants() to carefully obtain the useful string and output it to the rust-cfg file
  • While in artiq-zynq, the write_rustc_cfg_file(soc, filename) is called to generated rust-cfg in src/gateware/kasli_soc.py

    • It copies the content of soc.rustc_cfg = dict() directly to rust-cfg file

rust cfg difference if using get_rust_cfg

  • The write_rustc_cfg_file(soc, filename) was modified to follow get_rust_cfg
  • Then run python src/gateware/kasli_soc.py -c build/rustc-cfg kasli-soc-satellite.json

rustc-cfg before modification

has_drtio
has_drtio_routing
has_grabber
has_si5324
has_siphaser
has_virtual_leds
hw_rev="v1.1"
ki_impl="csr"
rtio_frequency="125.0"
si5324_soft_reset

rustc-cfg after modification

has_cri_con
has_drtioaux0
has_drtioaux1
has_drtioaux2
has_drtioaux3
has_drtiorep0
has_drtiorep1
has_drtiorep2
has_drtiosat
has_grabber0
has_gt_drtio
has_identifier
has_routing_table
has_rtio
has_rtio_analyzer
has_rtio_dma
has_rtio_moninj
has_siphaser
has_sys_crg
has_virtual_leds
rtio_log_channel="54"

Relevant code snippet

kasli_soc.py before modification

...
def write_rustc_cfg_file(soc, filename):
    with open(filename, "w") as f:
        for k, v in sorted(soc.rustc_cfg.items(), key=itemgetter(0)):
            if v is None:
                f.write("{}\n".format(k))
            else:
                f.write("{}=\"{}\"\n".format(k, v))
...

kasli_soc.py after modification

...
def write_rustc_cfg_file(soc, filename):
    with open(filename, "w") as f:
        for name, origin, busword, obj in soc.get_csr_regions():
            f.write("{}".format("has_"+name.lower()+"\n"))
        for name, value in soc.get_constants():
            if name.upper().startswith("CONFIG_"):
                if value is None:
                    f.write("{}".format(name.lower()[7:]+"\n"))
                else:
                    f.write("{}".format(name.lower()[7:]+"=\""+str(value)+"\"\n"))
...
## Difference between artiq and artiq-zynq - In artiq repo, the rust-cfg is generated by calling `f.write(cpu_interface.get_rust_cfg(soc.get_csr_regions(), soc.get_constants()))` in the `misoc/integration/build.py`. - `get_rust_cfg` analyze the content of `soc.get_csr_regions()` and `soc.get_constants()` to carefully obtain the useful string and output it to the rust-cfg file - While in artiq-zynq, the `write_rustc_cfg_file(soc, filename)` is called to generated rust-cfg in `src/gateware/kasli_soc.py` - It copies the content of `soc.rustc_cfg = dict()` directly to rust-cfg file ## rust cfg difference if using `get_rust_cfg` - The `write_rustc_cfg_file(soc, filename)` was modified to follow `get_rust_cfg` - Then run `python src/gateware/kasli_soc.py -c build/rustc-cfg kasli-soc-satellite.json` ### rustc-cfg before modification ``` has_drtio has_drtio_routing has_grabber has_si5324 has_siphaser has_virtual_leds hw_rev="v1.1" ki_impl="csr" rtio_frequency="125.0" si5324_soft_reset ``` ### rustc-cfg after modification ``` has_cri_con has_drtioaux0 has_drtioaux1 has_drtioaux2 has_drtioaux3 has_drtiorep0 has_drtiorep1 has_drtiorep2 has_drtiosat has_grabber0 has_gt_drtio has_identifier has_routing_table has_rtio has_rtio_analyzer has_rtio_dma has_rtio_moninj has_siphaser has_sys_crg has_virtual_leds rtio_log_channel="54" ``` ## Relevant code snippet ### kasli_soc.py before modification ``` ... def write_rustc_cfg_file(soc, filename): with open(filename, "w") as f: for k, v in sorted(soc.rustc_cfg.items(), key=itemgetter(0)): if v is None: f.write("{}\n".format(k)) else: f.write("{}=\"{}\"\n".format(k, v)) ... ``` ### kasli_soc.py after modification ``` ... def write_rustc_cfg_file(soc, filename): with open(filename, "w") as f: for name, origin, busword, obj in soc.get_csr_regions(): f.write("{}".format("has_"+name.lower()+"\n")) for name, value in soc.get_constants(): if name.upper().startswith("CONFIG_"): if value is None: f.write("{}".format(name.lower()[7:]+"\n")) else: f.write("{}".format(name.lower()[7:]+"=\""+str(value)+"\"\n")) ... ```
Outdated
Review

Yeah we should try to avoid divergence with misoc.

Yeah we should try to avoid divergence with misoc.