Пример #1
0
def sync_header():
    return [
        PatternVector(['1', 'X', '0', 'X', 'X']),
        PatternVector(['1', 'X', '1', 'X', 'X'],
                      opcode='repeat(5)',
                      comment='Sync header')
    ]
Пример #2
0
 def test_pattern_start(self):
     result = to_statements(sync_header())
     expected = to_statements([
         PatternVector(['1', 'X', '0', 'X', 'X']),
         PatternVector(['1', 'X', '1', 'X', 'X'],
                       opcode='repeat(5)',
                       comment='Sync header'),
     ])
     self.assertEqual(result, expected)
Пример #3
0
 def test_write_cmd(self):
     result = to_statements(write_cmd())
     expected = to_statements([
         PatternVector(['0', '0', 'X', '1'], comment='Write Command'),
         PatternVector(['0', '1', 'X', '1'], comment='Write Command'),
         PatternVector(['0', '0', 'X', '1'], comment='Write Command'),
         PatternVector(['0', '0', 'X', '1'], comment='Write Command'),
         PatternVector(['0', '0', 'X', '1'], comment='Write Command'),
     ])
     self.assertEqual(result, expected)
Пример #4
0
 def test_to_statements(self):
     vectors = [
         PatternVector(['1', 'X'], 'this is a comment', 'opcode1'),
         PatternVector(['V', '0'], 'another comment', 'opcode2'),
     ]
     expected_statement = '\n'.join([
         'opcode1        	-              	1	X; // this is a comment',
         'opcode2        	-              	V	0; // another comment'
     ])
     self.assertEqual(to_statements(vectors), expected_statement)
Пример #5
0
 def test_read_value_cmd(self):
     result = to_statements(read_value_cmd())
     expected = to_statements([
         PatternVector(['0', '0', 'X', '1'], comment='Read Value Command'),
         PatternVector(['0', '1', 'X', '1'], comment='Read Value Command'),
         PatternVector(['0', '0', 'X', '1'], comment='Read Value Command'),
         PatternVector(['0', '0', 'X', '1'], comment='Read Value Command'),
         PatternVector(['0', '0', 'X', '1'], comment='Read Value Command'),
     ])
     self.assertEqual(result, expected)
 def generate(self, pattern_content):
     vectors = [PatternVector(['0', 'X', 'X'], comment='Pattern Start', timeset=self.timeset_name)]
     for row in pattern_content:
         cmd = row['Command'].lower()
         if cmd == 'write':
             vectors += self._write(row['Data'])
         elif cmd == 'read':
             vectors += self._read()
         else:
             raise Exception(f"Invalid command {cmd}")
     vectors += [PatternVector(['0', 'X', 'X'], comment='Pattern End', opcode='halt')]
     return vectors
Пример #7
0
 def test_wait(self):
     result = to_statements(wait(3))
     expected_result = PatternVector(
         ['1', 'X', '0', 'X', 'X'],
         opcode=f'repeat(3)',
         comment=f'Wait for 3 Timesets').get_statement()
     self.assertEqual(result, expected_result)
Пример #8
0
def frame_end():
    return [PatternVector(['1', '0', 'X', '0'], comment='End of SPI 4W Frame', opcode='repeat(5)')]
Пример #9
0
 def _expect_writing_bits(self, bits_str, comment):
     return to_statements([
         PatternVector(['1', 'X', bit, 'X', 'X'], comment=comment)
         for bit in bits_str
     ])
Пример #10
0
 def test_get_statement(self):
     vector = PatternVector(['1', 'X'], 'this is comment', 'opcode', 'timeset0')
     expected_statement = 'opcode         	timeset0       	1	X; // this is comment'
     self.assertEqual(vector.get_statement(), expected_statement)
 def _write(self, data):
     bit_str = int_to_bits_msb_first(data, 8)
     vectors = []
     for i in range(0, 8):
         vectors.append(PatternVector(['1', bit_str[i], 'X'], comment=f'Write {data} (bit {i})'))
     return vectors
 def _read(self):
     return ([PatternVector(['0', 'X', 'X'], opcode='capture_start(DATA_Read)')]
           # reading 8 bits
           + [PatternVector(['0', 'X', 'V'], comment='Read', opcode='capture')] * 8
           + [PatternVector(['0', 'X', 'X'], opcode='capture_stop')]
     )
Пример #13
0
def pattern_end():
    return [PatternVector(['X', 'X', 'X', 'X'], comment='End of the pattern', opcode='halt')]
Пример #14
0
 def test_get_statement_default_params(self):
     vector = PatternVector(['1', 'X'])
     expected_statement = '               	-              	1	X;'
     self.assertEqual(vector.get_statement(), expected_statement)
Пример #15
0
def capture_stop():
    return [PatternVector(['1', '0', 'X', '1'], opcode='capture_stop')]
Пример #16
0
def pattern_start(timeset_name):
    return [PatternVector(['1', '0', 'X', '0'], comment='Start of the pattern', timeset=timeset_name)]
Пример #17
0
def wait(num_timeset):
    return [PatternVector(['1', '0', 'X', '0'], comment=f'Wait for {num_timeset} Timeset', opcode=f'repeat({num_timeset})')]
Пример #18
0
 def test_read_data(self):
     result = to_statements(read_data())
     expected = to_statements([PatternVector(['0', 'X', 'V', '1'], comment='Read', opcode='capture')] * 16)
     self.assertEqual(result, expected)
Пример #19
0
 def test_capture_stop(self):
     result = to_statements(capture_stop())
     expected = PatternVector(['1', '0', 'X', '1'], opcode='capture_stop').get_statement()
     self.assertEqual(result, expected)
Пример #20
0
 def test_frame_end(self):
     result = to_statements(frame_end())
     expected = PatternVector(['1', '0', 'X', '0'], comment='End of SPI 4W Frame', opcode='repeat(5)').get_statement()
     self.assertEqual(result, expected)
Пример #21
0
 def test_pattern_end(self):
     result = to_statements(pattern_end())
     expected = PatternVector(['X', 'X', 'X', 'X'], comment='End of the pattern', opcode='halt').get_statement()
     self.assertEqual(result, expected)
Пример #22
0
def capture_start():
    return [PatternVector(['1', '0', 'X', '0'], opcode='capture_start(DATA_Read)')]
Пример #23
0
 def test_pattern_start(self):
     result = to_statements(pattern_start('Test_Timeset'))
     expected = PatternVector(['1', '0', 'X', '0'], comment='Start of the pattern', timeset='Test_Timeset').get_statement()
     self.assertEqual(result, expected)
Пример #24
0
def _write_bits(bits_str, comment):
    return [PatternVector(['0', bit, 'X', '1'], comment=comment) for bit in bits_str]
Пример #25
0
 def test_write_address(self):
     result = to_statements(write_address('0x3cd'))
     # 0x3cd = 011 1100 1101 b
     expected = to_statements([
         PatternVector(['0', '0', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '1', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '1', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '1', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '1', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '0', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '0', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '1', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '1', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '0', 'X', '1'], comment='Address 0x3cd'),
         PatternVector(['0', '1', 'X', '1'], comment='Address 0x3cd'),
     ])
     self.assertEqual(result, expected)
Пример #26
0
def read_data():
    # capture 16 bits of data
    return [PatternVector(['0', 'X', 'V', '1'], comment='Read', opcode='capture')] * 16
Пример #27
0
 def test_write_data(self):
     result = to_statements(write_data('0xabcd'))
     # 0xabcd = 1010 1011 1100 1101 b
     expected = to_statements([
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '0', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '0', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '0', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '0', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '0', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '0', 'X', '1'], comment='Data 0xabcd'),
         PatternVector(['0', '1', 'X', '1'], comment='Data 0xabcd'),
     ])
     self.maxDiff = None
     self.assertEqual(result, expected)
Пример #28
0
def frame_start():
    return [PatternVector(['1', '0', 'X', '0'], comment='Start of SPI 4W Frame', opcode='repeat(5)')]
Пример #29
0
def wait(num_timesets):
    return [
        PatternVector(['1', 'X', '0', 'X', 'X'],
                      opcode=f'repeat({num_timesets})',
                      comment=f'Wait for {num_timesets} Timesets')
    ]