{"id":16478898,"url":"https://github.com/francoriba/alu_basys3","last_synced_at":"2026-02-10T21:04:12.849Z","repository":{"id":193362537,"uuid":"687228828","full_name":"francoriba/ALU_Basys3","owner":"francoriba","description":"Implementation of an arithmetic and logic unit in Verilog for the Basys3 board (Digilent). Computer Architecture 2023. FCEFyN, UNC, Argentina","archived":false,"fork":false,"pushed_at":"2023-10-13T21:23:49.000Z","size":1325,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-03T08:39:44.397Z","etag":null,"topics":["alu","computer-architecture","fcefyn","unc"],"latest_commit_sha":null,"homepage":"","language":"Verilog","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francoriba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-09-04T23:40:28.000Z","updated_at":"2025-04-08T22:18:18.000Z","dependencies_parsed_at":"2023-10-14T21:57:17.364Z","dependency_job_id":"654ee547-9126-4ad2-9c4b-a08dc20d2788","html_url":"https://github.com/francoriba/ALU_Basys3","commit_stats":null,"previous_names":["francoriba/alu_basys3"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/francoriba/ALU_Basys3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoriba%2FALU_Basys3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoriba%2FALU_Basys3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoriba%2FALU_Basys3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoriba%2FALU_Basys3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francoriba","download_url":"https://codeload.github.com/francoriba/ALU_Basys3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francoriba%2FALU_Basys3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29316451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T20:44:44.282Z","status":"ssl_error","status_checked_at":"2026-02-10T20:44:43.393Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["alu","computer-architecture","fcefyn","unc"],"created_at":"2024-10-11T12:50:29.542Z","updated_at":"2026-02-10T21:04:12.817Z","avatar_url":"https://github.com/francoriba.png","language":"Verilog","funding_links":[],"categories":[],"sub_categories":[],"readme":"Implementation of an arithmetic and logic unit in Verilog for the Basys3 board (Digilent). Computer Architecture 2023. FCEFyN, UNC, Argentina.\n\n# Goal\n- Impementation of an ALU in FPGA, specifically the Basys3 board.\n- The ALU takes 3 inputs, 2 of them are operands (8 bits) and the other is the opcode (6 bits).\n- 8 swiches are used to establish the bits states for each input.\n- As there are 8 swiches for 3 different inputs, 3 buttons of the board are used to select to wich input will correspond the value given by the 8 swiches.\n\n# Project structure\n\nThe figure below shows all the source files of this project. Simulation sources (yellow) are the testbench files for software testing of the \"controller\" and \"alu\" (green) modules.\n\n![](https://github.com/francoriba/ALU_Basys3/blob/main/docs/esquema.png)\n\n# ALU module\nThis module corresponds to the desing source file ``alu.v`` and contains the implementation of an Arithmetic and Logic Unit supporting 8 different operations distinguished by their 6 bit opcode:\u003cbr\u003e\n* ADD (100000)\n* SUB (100010)\n* AND (100100)\n* OR  (100101)\n* XOR (100110)\n* SRA (000011)\n* SRL (000010)\n* NOR (100111)\n\nThis module uses an ``always@(*)`` block wich allows to implement combinational logic with the goal of performing the right operation by decoding it with help of the opcode and a ``case`` conditional. \nAt any given time if one of the signals used inside the always block (i_op_1 or i_op2) change then this block will excecute again and the output (o_result) will change, as it would in a combinational circuit.\n\nThe figure below shows the generated desing of the ALU made by the RTL Analysis feature of the Vivado software. \n\n![](https://github.com/francoriba/ALU_Basys3/blob/main/docs/alu.png)\n\n# Controller module\nThis module corresponds to the desing source file ``controller.v`` and contains the necesary logic to assign the values of the switch ports to differents inputs depending on wich button was last pressed, again this is made by using a ``case`` conditional. The alu module is instanciated here using the corresponding values as input parameters.\n\nThe figure below shows the generated desing of the controller made by the RTL Analysis feature of the Vivado software. \n\n![](https://github.com/francoriba/ALU_Basys3/blob/main/docs/controller.png)\n\n# ALU Testbench\nThis module corresponds to the simulation source file ``tb_alu.v`` and implements a simulation for testing the output of the ALU when using randomly generated values for the operands.\n\nThe duration of the test can be changed, by default we have set it to #900, during this time there will be different iterations, in each iteration all operations will be tested, but also each iteration will have different randomly generated operands.\n\nThis is achieved by generating a clock signal with a period of 10 time units and using a variable as a counter. Each time an operation is completed the counter is incremented by one, the counter value is checked to see if it is divisible by the total amount of the operation (8) plus one, if this happens it means we have performed the 8 operations for 2 operands and it is time to reach new random operands and repeat all the operations again.\n\nIn addition, each time an operation is performed, the result is checked and error messages are displayed if the two values do not match.\n\nThe figure below shows an example of an error-free output.\n\n![](https://github.com/francoriba/ALU_Basys3/blob/main/docs/tb_alu_errorfree.png)\n\nThe figure below shows an example of an error output.\n\n![](https://github.com/francoriba/ALU_Basys3/blob/main/docs/tb_alu_error.png)\n\n# Controller Testbench\nThis module corresponds to the simulation source file ``tb_controller.v`` and implements a simulation for testing the controller module.\n\nAgain we set up a clock signal with a period of 10 time units and a variable to be used as a counter, this counter will be used to determine which cycle we are in.\nThere are 4 cycles:\n* 1st cycle: assign the first operand\n* 2nd cycle: assign second operand\n* 3rd cycle: allocate opcode\n* 4th cycle: check result\n\nUsing a new ``case`` condition, the value of the switches is randomly assigned and the \"button pressed\" is set depending on which cycle it is. For example, if the variable used as a counter has the value 1, then the value 001 is assigned to the button input variable and a random operand is set.\n\nThe figure below shows the time analysis of the simulation.\n![](https://github.com/francoriba/ALU_Basys3/blob/main/docs/time_analysis.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoriba%2Falu_basys3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancoriba%2Falu_basys3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancoriba%2Falu_basys3/lists"}