Skip to content

legorockband/CSC426_SnakeGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPE-426 Hardware Security Final Project - Snake Game

This repository contains a course project demonstrating a hardware trojan inserted into a custom RISC-V FPGA design for educational hardware security project.

This project:

  • Only targets a snake implementation on a RISC-V core on the Basys3 FPGA board

The trojan technique is demonstrated to study detection, mitigation, and secure hardware design practices.

Table of Contents

Introduction

This project is an implementation of a hardware trojan only on the Basys3 FPGA board.

It is best to run this project on WSL or Linux in order to run RISC-V toolchain.

Project Structure

  • Constraints: Constraints file for the Basys3 FPGA Board
  • imgs: documentation images
  • programs: C software for OTTER
    • scripts: scripts to setup OTTER tools
    • snake_game: Location of main program for this project. A simple snake game implementation on the OTTER
    • Extra tar files for initializes new projects
  • rtl: RTL of OTTER and VGA driver
  • sim: Location of OTTER testbench

Required Hardware and Software

Hardware

  • Basys3 FPGA Board
  • VGA Monitor
  • VGA Cable

Software

  • Vivado
  • RISC-V Toolchain

Game Controls

The controls are extremely simple.

When on the main menu, you can press the up or down button to scroll between START and EXIT. To confirm an option, you need to flip the rightmost switch (switch 0) to on. There are extra game options that can be set before selecting START. Using the leftmost switches (switch 12 to switch 15), you can increase the number of fruits that appear on the screen at a time. Switch 12 means 5 fruits and switch 15 means 2. If no fruit option switch is flipped on, the game defaults to 1 fruit. This option for fruit selection must be made before you start the game.

Once the game starts, use the left, right, up, and down buttons to move the snake in the pressed direction. Once a button is pressed, the snake will continue to move in that direction until another direction is pressed. Lastly there is a middle button that acts as a full reset of the program.

How to Setup Vivado Project

  1. Create your RTL project at the base repo
  2. Select RTL project
  3. Add sources from /rtl Add all of the System Verilog, Verilog, and memory files
  4. Add constraints file (peripherals already setup. Do not modify)
  5. Select correct FPGA board (xc7a35ticpg) board_select
  6. Once project is generated, add the sim file from the /sim folder
    • Similar to adding sources
    • Select "Added Source"
    • Select "Add or create simulation sources"

Once your Vivado project is setup, you can proceed to simulate, synthesize, and generate bit stream.

How to Setup RISC-V ToolChain

After cloning the project on your Linux or WSL machine, follow the directions to setup the toolchai.

  1. Install the otter toolchain from this google driver and move it to your home directory: https://drive.google.com/file/d/1yS3x0SlOr-eLZniw07J5MWeR3lJSSB8F/view?usp=sharing

    This includes the compiler required to run this project.

  2. untar: tar -xzf otter_tools_wsl.tgz

  3. Download dependecies

    • sudo apt update
    • sudo apt install -y libmpc3 libmpfr6 libgmp10 make
  4. Setup script for project

    • cd programs
    • source scripts/env.sh
  5. Build the snake game

    • cd programs/snake_game
    • make clean
    • make
  6. The snake game should already be in the RTL .mem file. If not, copy and paste contents from programs/snake_game/build/mem.txt to the .mem file on the RTL project. Generated the bit stream again and load on to the board.

  7. (Optional) If you want create your own software projects run (not necessary for this trojan) create_project_asm myproj

    • Or a C project, run create_project_c myproj
    • Be sure to change src/init.s to call _start instead of main for a C project

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors