{"id":388715,"date":"2024-06-29T08:07:27","date_gmt":"2024-06-29T08:07:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=388715"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=388715","title":{"rendered":"<span>Clicker game by using FPGA and Verilog<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>Author<\/strong><\/p>\n<p>Bahdan Shakh (b.shakh@innopolis.university)<\/p>\n<h3>Introduction<\/h3>\n<p>   Games can give positive emotions and provide relaxation to a person. However, the main purpose of my project is to get a better understanding of the Verilog language. In addition, coding a game into FPGA will help to define the bounds of this programming language.<\/p>\n<p><strong>Hardware and software used:<\/strong>\u00a0<\/p>\n<ul>\n<li>\n<p>MAX 10 FPGA (and it&#8217;s power cable)<\/p>\n<\/li>\n<li>\n<p>\u200b7-Segment display (output device)<\/p>\n<\/li>\n<li>\n<p>Switches (input device)<\/p>\n<\/li>\n<li>\n<p>Quartus Prime Lite Edition 18.1<\/p>\n<\/li>\n<li>\n<p>Verilog\/SystemVerilog HDL <\/p>\n<\/li>\n<li>\n<p>Altera USB Blaster (USB Blaster transfers configuration data from PC to FPGA)<\/p>\n<\/li>\n<\/ul>\n<h3>Project description<\/h3>\n<p>    The game itself is a simple clicker game: a moving aiming point, represented by the DP led on a 7-segment display, a target, which is represented by a vertical line and an empty space, which consists of only the bottom line. At each second, the player is expected to determine whether the space inside of their aim represents a target or an empty space and move the switch into position 1 or 0 accordingly. After the second passes, FPGA checks if the player&#8217;s choice is correct and makes a decision based of player&#8217;s action. If the guess of a player is correct, game adds one point to their score, and subtracts one in other case.<\/p>\n<p>Game also features a pause menu, which is used to stop the game and view the score. Pause menu can be turned on and off via a switch.<\/p>\n<h3>Location of points of interest on the board<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/453\/ea0\/256\/453ea0256b28afcc8ea4d1cf6f95ecdc.png\" width=\"600\" height=\"436\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/453\/ea0\/256\/453ea0256b28afcc8ea4d1cf6f95ecdc.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>Schematic representation of the program<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0fc\/284\/e48\/0fc284e483c007ac7d762fab21bde932.png\" width=\"845\" height=\"611\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0fc\/284\/e48\/0fc284e483c007ac7d762fab21bde932.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>Project flow<\/h3>\n<p>      As predicted in the draft of the project (sent via email to TAs), one of the main problems was the lack of knowledge on operating 7-segment displays. However, while this problem only took a relatively small amount of time and documentation read, randomization was a much tougher problem. I decided to use random numbers in my game due to it being objectively boring and easy for a project. As such, I considered a few approaches to the pseudo-randomization, which I will briefly describe:<\/p>\n<ol>\n<li>\n<p>Mathematical operations on a set number<br \/>Pros: Does provide random values, relatively easy to make<br \/>Cons: The set of values will remain the same with each new launch <\/p>\n<\/li>\n<li>\n<p>Mathematical operations on an outside number from a sensor<br \/>Pros: Provides almost truly random values, does not repeat with new launch<br \/>Cons: Requires additional gadgets\/sensors (e.g. temperature)<\/p>\n<\/li>\n<li>\n<p>Mathematical operations on an outside number from a user<br \/>Pros: Provides almost truly random values, does not repeat with new launch<br \/>Cons: Gets stuck in a loop if user does not input anything<\/p>\n<\/li>\n<li>\n<p><strong>Mathematical operations on an outside number from a user with additional module for randomization on a set number (1) (chosen)<br \/><\/strong>Pros: Provides almost truly random values, does not repeat with new launch, provides new value with each update<br \/>Cons: Not found yet<\/p>\n<\/li>\n<\/ol>\n<p><a href=\"https:\/\/github.com\/bodashka\/CA-project\" rel=\"noopener noreferrer nofollow\"><strong>Source code<\/strong><\/a><\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>I described the key stages that I went through to implement a clicker game using an FPGA board, Quartus Prime software and Verilog hardware description language. This work has been  implemented in the scope of \u00abComputer Architecture\u00bb course in the <a href=\"https:\/\/innopolis.university\/en\/\" rel=\"noopener noreferrer nofollow\">Innopolis University<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/705338\/\"> https:\/\/habr.com\/ru\/articles\/705338\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>Author<\/strong><\/p>\n<p>Bahdan Shakh (b.shakh@innopolis.university)<\/p>\n<h3>Introduction<\/h3>\n<p>   Games can give positive emotions and provide relaxation to a person. However, the main purpose of my project is to get a better understanding of the Verilog language. In addition, coding a game into FPGA will help to define the bounds of this programming language.<\/p>\n<p><strong>Hardware and software used:<\/strong>\u00a0<\/p>\n<ul>\n<li>\n<p>MAX 10 FPGA (and it&#8217;s power cable)<\/p>\n<\/li>\n<li>\n<p>\u200b7-Segment display (output device)<\/p>\n<\/li>\n<li>\n<p>Switches (input device)<\/p>\n<\/li>\n<li>\n<p>Quartus Prime Lite Edition 18.1<\/p>\n<\/li>\n<li>\n<p>Verilog\/SystemVerilog HDL <\/p>\n<\/li>\n<li>\n<p>Altera USB Blaster (USB Blaster transfers configuration data from PC to FPGA)<\/p>\n<\/li>\n<\/ul>\n<h3>Project description<\/h3>\n<p>    The game itself is a simple clicker game: a moving aiming point, represented by the DP led on a 7-segment display, a target, which is represented by a vertical line and an empty space, which consists of only the bottom line. At each second, the player is expected to determine whether the space inside of their aim represents a target or an empty space and move the switch into position 1 or 0 accordingly. After the second passes, FPGA checks if the player&#8217;s choice is correct and makes a decision based of player&#8217;s action. If the guess of a player is correct, game adds one point to their score, and subtracts one in other case.<\/p>\n<p>Game also features a pause menu, which is used to stop the game and view the score. Pause menu can be turned on and off via a switch.<\/p>\n<h3>Location of points of interest on the board<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>Schematic representation of the program<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>Project flow<\/h3>\n<p>      As predicted in the draft of the project (sent via email to TAs), one of the main problems was the lack of knowledge on operating 7-segment displays. However, while this problem only took a relatively small amount of time and documentation read, randomization was a much tougher problem. I decided to use random numbers in my game due to it being objectively boring and easy for a project. As such, I considered a few approaches to the pseudo-randomization, which I will briefly describe:<\/p>\n<ol>\n<li>\n<p>Mathematical operations on a set number<br \/>Pros: Does provide random values, relatively easy to make<br \/>Cons: The set of values will remain the same with each new launch <\/p>\n<\/li>\n<li>\n<p>Mathematical operations on an outside number from a sensor<br \/>Pros: Provides almost truly random values, does not repeat with new launch<br \/>Cons: Requires additional gadgets\/sensors (e.g. temperature)<\/p>\n<\/li>\n<li>\n<p>Mathematical operations on an outside number from a user<br \/>Pros: Provides almost truly random values, does not repeat with new launch<br \/>Cons: Gets stuck in a loop if user does not input anything<\/p>\n<\/li>\n<li>\n<p><strong>Mathematical operations on an outside number from a user with additional module for randomization on a set number (1) (chosen)<br \/><\/strong>Pros: Provides almost truly random values, does not repeat with new launch, provides new value with each update<br \/>Cons: Not found yet<\/p>\n<\/li>\n<\/ol>\n<p><a href=\"https:\/\/github.com\/bodashka\/CA-project\" rel=\"noopener noreferrer nofollow\"><strong>Source code<\/strong><\/a><\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>I described the key stages that I went through to implement a clicker game using an FPGA board, Quartus Prime software and Verilog hardware description language. This work has been  implemented in the scope of \u00abComputer Architecture\u00bb course in the <a href=\"https:\/\/innopolis.university\/en\/\" rel=\"noopener noreferrer nofollow\">Innopolis University<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/705338\/\"> https:\/\/habr.com\/ru\/articles\/705338\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-388715","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/388715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=388715"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/388715\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=388715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=388715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=388715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}