Project Documentation: Lightweight RISC Processor with XOR Cryptograph
Overview
This project involves creating a simple RISC processor capable of performing arithmetic operations
(add, subtract, multiply, divide) and secure XOR-based encryption/decryption. The processor
communicates via UART and runs on an FPGA. This documentation includes all the necessary
Verilog code, testbench, and integration steps.
Instruction Set Architecture (ISA)
The ISA includes the following instructions:
| Opcode | Instruction | Description | Example |
|--------|-------------|--------------------------|-----------------|
| 0000 | LOAD | Load value into register | LOAD R1, 0x12 |
| 0001 | STORE | Store value in memory | STORE R1, 0x12 |
| 0010 | ADD | Add two registers | ADD R1, R2, R3 |
| 0011 | SUB | Subtract two registers | SUB R1, R2, R3 |
| 0100 | MUL | Multiply two registers | MUL R1, R2, R3 |
| 0101 | DIV | Divide two registers | DIV R1, R2, R3 |
| 0110 | XOR | XOR two registers | XOR R1, R2, R3 |
| 1111 | HALT | Stop execution | HALT |
Processor Core (risc_core.v)
module risc_core(
input clk,
input reset,
input [7:0] instruction, // Instruction from memory
output reg [7:0] result, // Result output
input [7:0] data_in, // Data input for LOAD/STORE
output reg [7:0] data_out, // Data output for STORE
output reg [3:0] mem_addr // Memory address output
);
// ... (rest of the code omitted for brevity)
endmodule
Memory Module (memory.v)
module memory(
input clk,
input [3:0] address,
input write_enable,
input [7:0] data_in,
output reg [7:0] data_out
);
// ... (rest of the code omitted for brevity)
endmodule
UART Communication Module (uart.v)
module uart(
input clk,
input rx,
output tx,
input [7:0] data_in,
output reg [7:0] data_out
);
// ... (rest of the code omitted for brevity)
endmodule
Top-Level Design (top_module.v)
module top_module(
input clk,
input reset,
input rx,
output tx
);
// ... (rest of the code omitted for brevity)
endmodule
Testbench (testbench.v)
module testbench;
reg clk;
reg reset;
reg rx;
wire tx;
// ... (rest of the code omitted for brevity)
endmodule
Implementation Steps
1. Open your FPGA Design Tool (e.g., Vivado or Quartus).
2. Create a new project and add all Verilog files.
3. Define FPGA board constraints for UART pins.
4. Simulate the design using the testbench.
5. Synthesize, implement, and generate the bitstream file.
6. Program the FPGA and use a terminal (e.g., PuTTY) to test UART communication.