{"id":22898935,"url":"https://github.com/dwarfmaster/netlist-compiler","last_synced_at":"2025-04-01T01:54:04.762Z","repository":{"id":148100091,"uuid":"70744084","full_name":"dwarfmaster/netlist-compiler","owner":"dwarfmaster","description":"Compile netlist to equivalent programs","archived":false,"fork":false,"pushed_at":"2017-01-14T11:20:16.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T02:48:17.685Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dwarfmaster.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":"2016-10-12T21:41:39.000Z","updated_at":"2016-10-12T21:45:10.000Z","dependencies_parsed_at":"2023-05-19T04:00:24.415Z","dependency_job_id":null,"html_url":"https://github.com/dwarfmaster/netlist-compiler","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/dwarfmaster%2Fnetlist-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarfmaster%2Fnetlist-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarfmaster%2Fnetlist-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarfmaster%2Fnetlist-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwarfmaster","download_url":"https://codeload.github.com/dwarfmaster/netlist-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246569009,"owners_count":20798341,"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":[],"created_at":"2024-12-14T00:35:25.757Z","updated_at":"2025-04-01T01:54:04.733Z","avatar_url":"https://github.com/dwarfmaster.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NetList compiler\n\nCompiles a netlist to gasm for 64bits Linux machines.\n\n## How to use\nType `make` generates the compiler `compile-net` from Haskell. Then\nyou can use the script `compile.sh` to generate a program from a netlist.\nIt expects a path to the netlist as first argument. It also requires for\n`helper.c` and `compile-net` to be in the same directory. The generated\nprogram will have the same basename (minus eventually the `.net`) as the\nnetlist, with the `out` extension.\n\nThe generated program expects two arguments (they are NOT optional). The first\none is a path to a file, which will be loaded as the ROM. The second one is the\nsize of the RAM in bytes. An optional third argument can specify a number of\npasses in the simulation.\n\nWhen they are inputs variables, their values must be entered in hexadecimal,\nseparated by returns, in the order the variables where in the netlist. The\noutput variables will have their values written, one per line, in hexadecimal,\nin the order they were in the netlist.\n\n## NetList syntax\nThe netlist file must begin with the `INPUT` token, followed by the names\nof the input variables, separated by commas. Then it expects the `OUTPUT`\ntoken, followed by the list of output variables.\n\nAfterward there must be the `VAR` token, followed by the list of all the\nvariables used in the program. It is possible to specify here the size of the\nvariable by postponing its name by `: size`. Variables are of size 1 by\ndefault. Variables have a maximum size of 64.\n\nThen comes the IN token, followed by a list of statements, one per line. A\nstatement describes how to compute a variable. A statement has the form\n`var = command arguments`. There must one and only one statement for every\nvariable. Because every arguments must be computed before var is computed \n(unless otherwise stated in the following list), there cannot be circular\ndependencies.\n\nHere is the list of accepted commands :\n - If there simply is the name of a variable or a constant after the `=`,\n   the computed variable is set to its value. The two variables must have the\n   same size and the constant must be small enough to be stored on the\n   variable.\n - `AND|OR|XOR|NAND v1 v2` : computes a binary operator between two\n   variables. They must be of the same size as the result.\n - `NOT v` : computes the bit by bit negation of `v`, which must be of\n   the same size as the result.\n - `REG v` : computes the value of the variable `v` at the end of the\n   previous pass. `v` must be of the same size as the result.\n - `MUX v1 v2 s` : `s` must be of size 1. Returns `v1` if `s`\n   is 1 and `v2` otherwise. `v1` and `v2` must be of the same size\n   as the result.\n - `CONCAT v1 v2` : The size of the result must be the sum of the sizes of\n   `v1` and `v2`. `v1` will be the the least significant bits of\n   the results and `v2` the most significant ones.\n - `SLICE i1 i2 v` : `i1` and `i2` must be integers, and the\n   result must be of size `i2 - i1 + 1`. It returns a slice of `v`,\n   in little endian order, ie `SLICE 0 1 v` returns the two least\n   significant bits of `v`.\n - `SELECT i v` : the result must be of size 1. Selects the `i`-eme bit of\n   `v`, starting with the least significant one.\n - `ROM as ws ra` : `as` and `ws` are integers. `as` is the address size, thus\n   the size of the variable `ra`. `ws` is the size of the word read, thus the\n   size of the result. To know how the rom is loaded, refer to the *How to use*\n   section. Access is in little endian order : `ROM 2 4 0` will give the 4\n   least significat bits of `ROM 2 8 0`. Furthermore, `ws` must always be a\n   power of two. The address is in *word size* unit.\n - `RAM as ws ra e wa d` : `ws` is the word size, so the size of the result and\n   of `d`. `as` is the address size, thus the size of `ra` and `wa`. Finally\n   `e` is a bit. The first three arguments work exactly as with `ROM`. The\n   three last ones allow to write to the RAM. `e` enables the writing if set\n   to 1. `wa` is the write address and `d` is the data written. Please note\n   that the write action only takes effect at the end of the pass. Because of\n   that, the three last arguments are not dependencies of the command. The\n   addresses are in *word size* unit.\n\nThe RAM and the registers are initialised to 0.\n\nFor examples of valid netlists, see the folder `test`.\n\n## Dependencies\nTo compile `compile-net`, the following utilities are needed :\n - [make](https://www.gnu.org/software/make/)\n - [ghc](https://www.haskell.org/ghc/)\n - [parsec](https://hackage.haskell.org/package/parsec)\n - [fgl](https://hackage.haskell.org/package/fgl)\n\nTo use it, you will need :\n - [gcc](https://gcc.gnu.org/)\n - [bash](https://www.gnu.org/software/bash/) or any shell-compliant program\n\n## Portability\nWhile the compiler can be used on any system with an haskell installation, the\ngenerated program is Linux specific : indeed, it relies on the Linux calling\nconvention. This means it may work on other UNIXes like \\*BSD or Mac OS X but\nnot on Windows.\n\n## Problems during the implementation\nThe main difficulty was getting the calling convention right (sending the right\narguments, saving the registers, placing `%rsp`, getting the return ...), which\nis why only one calling convention is supported.\n\nThe other hurdle to overcome was getting clear on big-endian/little-endian when\nreading or writing the memory (both ROM and RAM), and proposing a consistent\nimplementation.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwarfmaster%2Fnetlist-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwarfmaster%2Fnetlist-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwarfmaster%2Fnetlist-compiler/lists"}