-
Notifications
You must be signed in to change notification settings - Fork 123
Refactor of current_mirror.py #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I have broken down the current_mirror function into multiple smaller functions as this will improve readability and re-usability of the smaller function. Also added docstrings to the functions to make them more clear to users.
harshkhandeparkar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments but this looks good otherwise
|
|
||
|
|
||
| #@cell | ||
| def create_interdigitized_fets(pdk: MappedPDK, device: str, numcols: int, with_dummy: bool, **kwargs) -> Component: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this pattern used elsewhere, in other circuits perhaps? If yes, then this function can be reused there as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know repo well enough right now, but yes if this pattern is being used elsewhere then it can be replaced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine. Let it be for now.
| raise ValueError(f"Invalid device type: {device}. Must be 'nfet' or 'pfet'.") | ||
|
|
||
|
|
||
| def route_interdigitized_fets(pdk: MappedPDK, interdigitized_fets: Component) -> Component: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to prefix the function name with an _ or __ since it is only used as a subfunction in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree with that. I'll make the changes.
| ) | ||
|
|
||
| return top_level | ||
| """An instantiable current mirror Component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems some of the documentation was removed. Is there a reason why it was shortened?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this would be better but in hindsight I think the initial documentation is a better choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More elaborate documentation never hurts.
| return component | ||
|
|
||
|
|
||
| def current_mirror( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested if this function still works the same? For a temporary check, you can instantiate a few current mirrors and compare the results to the older function and ensure they are the same.
However, it would be really good if you add a test in the CI. You can take a look at this file as an example.
I have broken down the current_mirror function into multiple smaller functions as this will improve readability and re-usability of the smaller function. Also added docstrings to the functions to make them more clear to users.