Ejemplo n.º 1
0
 def test_output_file(self):
     outFile = apx.OutputFile('test1.out', 5)
     self.assertIsInstance(outFile.data, bytearray)
     self.assertEqual(len(outFile.data), 5)
     retval = outFile.write(2, b"\x01\x02\x03")
     self.assertEqual(retval, 3)
     self.assertEqual(outFile.data[2:5], b"\x01\x02\x03")
Ejemplo n.º 2
0
 def _createOutPortDataFile(self, node, compiler):
    offset=0
    init_data = bytearray()
    for port in node.providePorts:
       dataElement = port.dsg.resolve_data_element(node.dataTypes)
       packLen = port.dsg.packLen()
       self.mapOutPort(port, offset, packLen)
       self.createPackProg(port, dataElement, compiler)
       self.createOutPortValue(port)
       offset+=packLen
       if port.attr is not None and port.attr.initValue is not None:
          init_data.extend(dataElement.createInitData(port.attr.initValue))
       else:
          init_data.extend(bytes(packLen)) #initialize with zeros if no init value has been selected
    file_len=offset
    assert(len(init_data)==file_len)
    if file_len > 0:
       file = apx.OutputFile(node.name+'.out', file_len, init_data)
       return file
    return None
Ejemplo n.º 3
0
 def _createDefinitionFile(self, node_name, apx_text):
    apx_text_size = len(apx_text.encode('utf-8'))
    file = apx.OutputFile(node_name+'.apx', length=apx_text_size)
    file.write(0,bytes(apx_text, encoding='utf-8'))
    return file
Ejemplo n.º 4
0
 def _createDefinitionFile(self, node_name, apx_text):
     file = apx.OutputFile(node_name + '.apx', len(apx_text))
     file.write(0, bytes(apx_text, encoding='ascii'))
     return file