Exemplo n.º 1
0
def sync_header():
    return [
        PatternVector(['1', 'X', '0', 'X', 'X']),
        PatternVector(['1', 'X', '1', 'X', 'X'],
                      opcode='repeat(5)',
                      comment='Sync header')
    ]
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 8
0
def frame_end():
    return [PatternVector(['1', '0', 'X', '0'], comment='End of SPI 4W Frame', opcode='repeat(5)')]
Exemplo n.º 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
     ])
Exemplo n.º 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')]
     )
Exemplo n.º 13
0
def pattern_end():
    return [PatternVector(['X', 'X', 'X', 'X'], comment='End of the pattern', opcode='halt')]
Exemplo n.º 14
0
 def test_get_statement_default_params(self):
     vector = PatternVector(['1', 'X'])
     expected_statement = '               	-              	1	X;'
     self.assertEqual(vector.get_statement(), expected_statement)
Exemplo n.º 15
0
def capture_stop():
    return [PatternVector(['1', '0', 'X', '1'], opcode='capture_stop')]
Exemplo n.º 16
0
def pattern_start(timeset_name):
    return [PatternVector(['1', '0', 'X', '0'], comment='Start of the pattern', timeset=timeset_name)]
Exemplo n.º 17
0
def wait(num_timeset):
    return [PatternVector(['1', '0', 'X', '0'], comment=f'Wait for {num_timeset} Timeset', opcode=f'repeat({num_timeset})')]
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 22
0
def capture_start():
    return [PatternVector(['1', '0', 'X', '0'], opcode='capture_start(DATA_Read)')]
Exemplo n.º 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)
Exemplo n.º 24
0
def _write_bits(bits_str, comment):
    return [PatternVector(['0', bit, 'X', '1'], comment=comment) for bit in bits_str]
Exemplo n.º 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)
Exemplo n.º 26
0
def read_data():
    # capture 16 bits of data
    return [PatternVector(['0', 'X', 'V', '1'], comment='Read', opcode='capture')] * 16
Exemplo n.º 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)
Exemplo n.º 28
0
def frame_start():
    return [PatternVector(['1', '0', 'X', '0'], comment='Start of SPI 4W Frame', opcode='repeat(5)')]
Exemplo n.º 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')
    ]