示例#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')
    ]