-
Notifications
You must be signed in to change notification settings - Fork 6
Max instruction counting / verifying #72
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
db0b811
saving tests and readme edits
Json-To-String 4bfd641
moving ins sizes to global
Json-To-String 583c8de
sentence balance
Json-To-String b63bd32
removing extra comment and saving instruction tests
Json-To-String 342c49c
typo
Json-To-String 7b3e4ee
gave in and just made this a .py
Json-To-String 2f5a121
carter caught ins_from_buffer being used instead of ins_count
Json-To-String ffc9986
redoing instruction counts for 243 KB
Json-To-String d92f6c1
KB not Kb
Json-To-String 6d1f3bb
KB not Kb
Json-To-String 7851ef0
fixing clunkiness
Json-To-String 9caff2a
Delete testing/instruction-analysis.ipynb
Json-To-String d53a763
cleaned out individual tests, keeping general tests
Json-To-String dab516d
remove line about empirically determined
Json-To-String File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import numpy as np | ||
|
|
||
| class BinaryRoutines(): | ||
| """ | ||
| Class handler for `setb` command to send binary tables to the dds-sweeper | ||
| """ | ||
|
|
||
| def __init__(self, conn): | ||
| self.conn = conn | ||
| self.mirror_channels = False | ||
| self.debug_run = True | ||
| self.MAX_SIZE = 256 | ||
| self.instructions = None | ||
| self.timing_mode = None | ||
|
|
||
| def send(self, command: str, echo = True): | ||
| if command[-1] != '\n': | ||
| command += '\n' | ||
|
|
||
| self.conn.write(command.encode()) | ||
| if echo: | ||
| print(self.catch_response()) | ||
|
|
||
| def catch_response(self): | ||
| resp = self.conn.readline().decode().strip() | ||
| return resp | ||
|
|
||
| def assert_OK(self): | ||
| resp = self.conn.readline().decode().strip() | ||
| assert resp == 'ok', 'Expected "ok", received "%s"' % resp | ||
|
|
||
| def debug_on(self): | ||
| self.conn.write(b'debug on\n') | ||
| self.assert_OK() | ||
|
|
||
| def debug_off(self): | ||
| self.conn.write(b'debug off\n') | ||
| self.assert_OK() | ||
|
|
||
| def set_mode(self, sweep_mode: int, timing_mode: int, num_channels: int): | ||
| self.conn.write(b'reset\n') | ||
| self.assert_OK() | ||
|
|
||
| self.timing_mode = timing_mode | ||
| self.conn.write(b'mode %d %d \n' % (sweep_mode, timing_mode)) | ||
| self.assert_OK() | ||
| self.conn.write(b'setchannels %d\n' % num_channels) | ||
| self.assert_OK() | ||
| if self.debug_run == True: | ||
| print('sending commands to %d channels' % num_channels) | ||
|
|
||
| def allocate(self, start_address: int, instructions: np.ndarray): | ||
| self.conn.write(b'setb %d %d\n' % (start_address, len(instructions))) | ||
| response = self.conn.readline().decode() | ||
| if not response.startswith('ready'): | ||
| response += ''.join([r.decode() for r in self.conn.readlines()]) | ||
| raise Exception(f'setb command failed, response: {repr(response)}') | ||
| if self.debug_run == True: | ||
| print(f'Got response: {response}') | ||
|
|
||
| def table_to_memory(self, instructions: np.ndarray): | ||
| self.conn.write(instructions.tobytes()) | ||
| self.assert_OK(), 'table not written correctly' | ||
| if self.debug_run == True: | ||
| print('table written to memory') | ||
|
|
||
| def end_table(self, instructions: np.ndarray): | ||
| self.conn.write(b'set 4 %d\n' % len(instructions)) | ||
| self.assert_OK(), 'table not stopped correctly' | ||
| self.instructions = instructions | ||
| if self.debug_run == True: | ||
| print('table end command sent') | ||
|
|
||
| def start_routine(self, hwstart = False): | ||
| if hwstart: | ||
| self.conn.write(b'hwstart\n') | ||
| else: | ||
| self.conn.write(b'start\n') | ||
| self.assert_OK(), 'table did not start' | ||
| if self.debug_run == True: | ||
| print('table executed') | ||
|
|
||
| def read_table(self, indices = None): | ||
| self.conn.write(b'readtable\n') | ||
| for i in range(self.instructions.size + 2): # plus two to catch header and footer | ||
| resp = self.catch_response() | ||
| print(resp) | ||
| if "End of" in resp: | ||
| break | ||
| elif "Cannot" in resp: | ||
| break | ||
| elif len(resp) == 0: | ||
| break | ||
|
|
||
| def get_memory_layout(self): | ||
| self.conn.write(b'getmode\n') | ||
| mode = self.catch_response() | ||
| channels = self.catch_response() | ||
| memory_layout = self.catch_response() | ||
| print(f"mode {mode}") | ||
| print(channels) | ||
| print(memory_layout) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.