{"id":15662996,"url":"https://github.com/ysiraichi/enfield","last_synced_at":"2025-05-06T01:59:37.644Z","repository":{"id":73272476,"uuid":"114171922","full_name":"ysiraichi/enfield","owner":"ysiraichi","description":"An OpenQASM source-to-source Compiler.","archived":false,"fork":false,"pushed_at":"2019-02-25T17:24:55.000Z","size":20822,"stargazers_count":20,"open_issues_count":3,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-06T01:59:29.226Z","etag":null,"topics":["compiler","quantum-computing","qubit-allocation"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ysiraichi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-13T21:43:04.000Z","updated_at":"2024-08-21T11:26:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"128c8418-4b64-4e84-8ef1-c4fd275c638b","html_url":"https://github.com/ysiraichi/enfield","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysiraichi%2Fenfield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysiraichi%2Fenfield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysiraichi%2Fenfield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysiraichi%2Fenfield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ysiraichi","download_url":"https://codeload.github.com/ysiraichi/enfield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252606934,"owners_count":21775414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","quantum-computing","qubit-allocation"],"created_at":"2024-10-03T13:35:11.935Z","updated_at":"2025-05-06T01:59:37.615Z","avatar_url":"https://github.com/ysiraichi.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enfield\n\n[![Build Status](https://travis-ci.org/ysiraichi/enfield.svg?branch=master)](https://travis-ci.org/ysiraichi/enfield)\n\nThis project was built on top of [Bison](https://www.gnu.org/software/bison/) (v3.0.2),\n[Flex](https://github.com/westes/flex) (2.5.39),\nand [JsonCpp](https://github.com/open-source-parsers/jsoncpp) (v1.8.4).\n\nCheck out the [documentation here!!](https://ysiraichi.github.io/enfield/)\n\n## Building\n\nEnfield uses CMake. So, in order to build this project, issue the following commands:\n\n```\n$ mkdir build \u0026\u0026 cd build\n$ cmake ../ -DJSONCPP_ROOT=\u003cpath-to-jsoncpp-libs\u003e\n$ make\n```\n\nThe script for finding JsonCpp is simple, so you will have to explicitly show Enfield\nwhere you installed it (the prefix folder).\n\n## Testing\n\nEnfield uses the [Google test framework](https://github.com/google/googletest)\nto test its components.\nTo enable automated tests, you should issue the ```cmake``` command as follows:\n\n```\n$ cmake ../ -DENABLE_TESTS=on\n$ make \u0026\u0026 make test\n```\n\nIt is possible to specify the root folder of the GTest framework. In order to do that,\nyou should pass to ```cmake``` the option ```-DGTEST_ROOT=\u003cpath-to-gtest-libs\u003e```.\n\n## Compiling OpenQASM Programs\n\nSuppose that you compiled enfield inside ```$BUILD_DIR``` folder.\nThe enfield compiler will be located at ```$BUILD_DIR/tools```.\nThere you will find some programs, one of which is ```efd```, the compiler itself.\n\nThe only required argument for compiling an OpenQASM program is the program itself.\nIf you do not specify anything, enfield will compiile the input program with the\ndefault parameters.\nOne can check the available parameter, as well as the default ones by executing the\nfollowing command:\n\n```\n$ efd --help\n```\n\nThe general form for compiling programs is:\n\n```\n$ efd -i \u003cqasm-file\u003e --alloc \u003callocator\u003e --arch \u003carchitecture\u003e -o \u003coutput-file\u003e\n```\n\nFor example: if we wanted to compile program ```tests/files/qft.qasm``` for architecture\n```ibmqx2```, using allocator ```wpm```, while storing the compiled program inside\n```qft_ibmqx2.qasm```, we would have to execute the following:\n\n```\n$ efd -i tests/files/qft.qasm --alloc Q_wpm --arch A_ibmqx2 -o qft_ibmqx2.qasm\n```\n\nOne could add the ```-stats``` flag, in order for enfield to print statistical data\nof the compilation, such as the weighted cost, depth, and number of gates of the\ncompiled program.\n\nIt is also possible to feed the compiler a new architecture, and use it to compile\nthe same program.\nSo, for example, if we wanted to compile using architecture ```archfiles/tokyo.json```,\nwe would have to execute the following:\n\n```\n$ efd -i tests/files/qft.qasm --alloc Q_wpm --arch-file archfiles/tokyo.json -o qft_tokyo.qasm\n```\n\n## Hacking\n\nEven though this project is pretty new, it was designed to be extensible. So, here are\na few tips in order to implement your own algorithm to your desired architecture.\nBelow, I'll list some classes that are important to be aware of.\n\n(Note that this is a (really brief) 'begginers guide', so you can do more stuff once\nyou learn the code)\n\n* ```efd::QModule```: The core class of enfield. It holds the AST preprocessed to be\neasier to use, as well as some other useful methods for modifying the AST.\ni.e.: ```insertSwapAfter```; ```insertNodeAfter```; ```replaceAllRegsWith```, etc.\n\n* ```efd::Pass```: Enfield is a pass-based compiler.\nMuch like LLVM (but far from its user base), the transformations are implemented as\n```Pass``` for ```QModules```.\nThere are plenty (ugly, though) so that you can implement yours!\nGood luck;\n\n* ```efd::QbitAllocator```: This is the base class for implementing allocators.\nIn order to implement your own, you should extend this class and implement the method\n```allocate```.\nThis method is responsible for inserting swaps based on the ```QModule``` (that is\ngiven by parameter).\nAfter that, you have to surrender to the \"beauty\" of C++ macros, and modify the file\n```Allocators.def```, so that your allocator is available on command line;\n\n* ```Architectures.def```: Take a look in this file in order to create the specification\nof other architectures.\nYES!\nMore Macros!\nYou will have to specify your architecture in a JSON format.\nCheck the other architecture descriptions for a better understanding.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fysiraichi%2Fenfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fysiraichi%2Fenfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fysiraichi%2Fenfield/lists"}