def main(argv):
    if len(argv) != 1:
        raise app.UsageError('Unexpected arguments.')

    channel_creds = client_credentials.get_credentials()
    with grpc.secure_channel(f'localhost:{FLAGS.port}',
                             channel_creds) as channel:
        grpc.channel_ready_future(channel).result()
        stub = synthesis_service_pb2_grpc.SynthesisServiceStub(channel)

        run_characterization(stub)
Exemple #2
0
    def test_bisect_frequencies_infeasible(self):
        port, proc = self._start_server(['--max_frequency_ghz=2.0'])

        channel_creds = client_credentials.get_credentials()
        with grpc.secure_channel(f'localhost:{port}',
                                 channel_creds) as channel:
            result = synthesis_utils.bisect_frequency('verilog', 'main',
                                                      int(3e9), int(4e9),
                                                      int(0.1e9), channel)
        self.assertEqual(result.max_frequency_hz, 0)
        proc.terminate()
        proc.wait()
Exemple #3
0
    def test_bisect_frequencies_with_error(self):
        port, proc = self._start_server(
            ['--max_frequency_ghz=2.0', '--serve_errors'])

        channel_creds = client_credentials.get_credentials()
        with grpc.secure_channel(f'localhost:{port}',
                                 channel_creds) as channel:
            with self.assertRaises(grpc.RpcError):
                _ = synthesis_utils.bisect_frequency('verilog', 'main',
                                                     int(1.5e9), int(3e9),
                                                     int(0.1e9), channel)
        proc.terminate()
        proc.wait()
Exemple #4
0
    def _generate_sources(
            self, op: op_pb2.OpProto,
            operand_types: Iterable[xls_type_pb2.TypeProto],
            output_type: xls_type_pb2.TypeProto) -> Tuple[str, str]:
        """Generates XLS IR and netlist sources for a single LEC execution.

    This function creates IR and a netlist for the given op and argument/output
    types, suitable as inputs to a LEC operation.

    Currently, this only supports a single op (per the internal operation of
    op_module_generator). In the future, it will likely be useful to see how
    execution time scales with operation composition.

    Args:
      op: The XLS IR opcode for which to generate sources.
      operand_types: The types of the arguments to use for this op execution.
      output_type: The type of the operation output.

    Returns:
      A tuple of IR and netlist sources for executing the given operation as
      text.
    """
        op_name = op_pb2.OpProto.Name(op)[3:].lower()
        operand_type_strs = [
            self._proto_to_ir_type(ot) for ot in operand_types
        ]
        ir_text = op_module_generator.generate_ir_package(
            op_name, self._proto_to_ir_type(output_type), operand_type_strs,
            [], None)
        verilog_text = op_module_generator.generate_verilog_module(
            self._MODULE_NAME, ir_text).verilog_text

        creds = client_credentials.get_credentials()
        netlist_text = None
        with grpc.secure_channel(self._synthesis_server_address,
                                 creds) as channel:
            grpc.channel_ready_future(channel).result()
            stub = synthesis_service_pb2_grpc.SynthesisServiceStub(channel)

            request = synthesis_pb2.CompileRequest()
            logging.vlog(logging.INFO, 'Module text:\n %s', verilog_text)
            request.module_text = verilog_text
            request.top_module_name = self._MODULE_NAME
            # We're always going to be in a single cycle.
            request.target_frequency_hz = 1

            response = stub.Compile(request)
            netlist_text = response.netlist

        return (ir_text, netlist_text)
def main(argv):
    if len(argv) != 2:
        raise app.UsageError('Must specify verilog file.')

    with open(argv[1], 'r') as f:
        verilog_text = f.read()

    channel_creds = client_credentials.get_credentials()
    with grpc.secure_channel(f'localhost:{FLAGS.port}',
                             channel_creds) as channel:
        grpc.channel_ready_future(channel).result()
        stub = synthesis_service_pb2_grpc.SynthesisServiceStub(channel)

        request = synthesis_pb2.CompileRequest()
        request.module_text = verilog_text
        request.top_module_name = FLAGS.top
        request.target_frequency_hz = int(FLAGS.ghz * 1e9)
        logging.info('--- Request')
        logging.info(request)

        response = stub.Compile(request)
        print(response)