Skip to content

Conversation

@AUTProgram
Copy link

I have added the files for automatic generation of the device database.

Run "python kasli_test.py" with a valid device_db to generate a device_db_check file that explicitly contains the device_db dictionary.

eems.py and device_db_generation.py contain the functions necessary for creation of the devices_config dictionary (information about what was actually built on target) and the device_db dictionary.

This is a basic version, extra functionality can be added via additional arguments.

@hartytp
Copy link

hartytp commented Apr 5, 2018

Thanks @AUTProgram!

FYI @jordens @sbourdeauducq

Copy link

@hartytp hartytp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @AUTProgram! Overall, that's a really good start and if I never have to manually type out a device db again it's too soon.

A mixture of stylistic/structural comments there, but nothing too major.

Have you run the code and checked it works?

I would separate this into two PRs: one for the infrastructure, and one that adds a version of Kasli that uses the infrastructure.

@@ -0,0 +1,139 @@
#Read devices_config from file generated when bitstream was built
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this kind of thing, I'd use a docstring rather than a comment. That way, users can find the documentation for a function func using help(func) and it can be automatically included into the proper documentation. PEP 8 has some advice on docstrings, but you can also see how they are used elsewhere in artiq/migen/misoc. NB any non-trivial arguments/return values should be documented using param: ... etc.

On the other hand, if the documentation is too trivial to be in a docstring then it's probably not worth the comment either!

def devices_config_to_file(devices_config, filename):
with open(filename, "w") as f:
f.write("devices_config = ")
json.dump(devices_config, f, indent=4) No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing new line at end of file (PEP 8)


self.add_rtio(rtio_channels)

cleanup_devices_config(devices_config)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this function? It might be clearer/nicer to have devices_config_to_file filter out non-serialisable things like phys when saving, rather than calling a cleanup function first.

Copy link
Author

@AUTProgram AUTProgram Apr 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that depends on whether in the future there might ever be other functions that use devices_config, but have a problem with non-serialisable entries. If those functions are called before devices_config_to_file, they would also need extra code for filtering. I guess right now it would be more concise to have it all in devices_config_to_file, so I'll merge the two.


#Create PHYs and rtio channels for a dio device and return dictionary with information
#about those channels
def eem_dio(cls, eem, name):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as these functions are already in a module named eems do they need to begin with eem_? i.e. depending on how the user decides to import them, they can already be called using eems.dio etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are already functions called _dio, _urukul etc in the files provided for the kasli target, so I wanted to distinguish my functions from those

@@ -0,0 +1,44 @@
from artiq.gateware.targets.kasli import (_MasterBase, _SatelliteBase, _dio,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports _dio, _uruku?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I will remove those


core_addr = "core_addr" #IP address of host

core_device = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all standard boilerplate. I'd be tempted to add a function to generate it, like core_device(addr, has_DMA=True, ...)

}
}

#Provide information for each device and channel. The keys of peripherals
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text should go in the doctoring for create_device_db

if device == device_id:
info = custom_info
break
else:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code work (I haven't tried it myself yet)? Maybe I'm being daft, but what is that else in response to? The whitespace looks off...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, scratch that. I didn't know python had that feature...

name: {
"type": "local",
"module": "artiq.coredevice.ad9912",
"class": "AD9912",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a parameter to allow us to choose either the AD9910 or AD9912 versions of Urukul (there are two hw revisions with different DDS chips on).

"module": "artiq.coredevice.ad9912",
"class": "AD9912",
"arguments": {
"pll_n": 10,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ref clock frequency and pll multiplication factor need to be selectable via parameters (we will use 125MHz, but other people will use 100MHz).

from artiq.build_soc import build_artiq_soc
from artiq import __version__ as artiq_version

from artiq.gateware.targets.kasli import (_dio, _urukul)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those won't exist in the future. Don't rely on that. That's also the reason they have underscores. They should be refactored and become part of this endeavor to generate RTIO PHYs and the device_db.


import json

#Create PHYs and rtio channels for a dio device and return dictionary with information
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will want to split this so that the definition of the RTIO channels and the device_db tooling is not in a single file for all EEMs but split.

#Create PHYs and rtio channels for an urukul device and return dictionary with information
#about those channels
def eem_urukul(cls, eem, eem_aux, name):
info = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to push all this info down into the PHYs themselves and introduce other classes that maintain the rest of the metadata that spans multiple PHYs.
If you really need thi dict-of-dict-and-lists, then at least document it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants