- This repository includes all the project files related to the development of a custom processor in Verilog HDL for image downsampling.
- The project was done by a team of 4 undergraduates at the Department of Electronic and Telecommunication Engineering, University of Moratuwa, Sri Lanka for UOM's EN3030 Circuits and Systems Design module.
- The primary objective of this project was to design a processor which can downsample a given
256x256greyscale 8-bit image. The coding was done using Verilog Hardware Description Language (HDL). Xilinx Vivadowas used as the analysis and synthesis tool for the design of the processor and for the simulation of Verilog HDL designs.
| Original Image | Filtered Image | Down Sampled Image |
|---|---|---|
![]() |
![]() |
![]() |
Converting the 8-bit Input Image to its Binary Values
IO_Codedirectory includes the python codeinput_create.pywhich converts the origanl input image to its binary values and save them in theinput.txttext file.- Copy this text file and paste it in your
<project_name>\<project_name>.sim\sim_1\behav\xsimfolder path of the vivado project created.
Compiling the Assembly Code
-
Compilerdirectory includes the text fileAssembly.txtwhich includes the assembly code for image filtering and down sampling. -
In
compiler_bin.pyandcompiler_ram.pypython code files it contains the opcodes of each instruction. -
Using
compiler_bin.py, you can get the binary values of the assembly code according to the opcodes . The binary values will save inoutput_bin.txt. -
You can assign the
8'dor16'dvalues for the assembly code to each memory location according to this opcodes usingcompiler_ram.py. This will createoutput_bin.txtas below.
ram[0] = 8'd38;
ram[1] = 16'd257;
ram[2] = 8'd9;
ram[3] = 8'd16;
:
:
:
ram[169] = 8'd37;
ram[170] = 8'd49;
ram[171] = 8'd132;
ram[172] = 8'd51;
- Copy everything in that
output_bin.txtfile by pressingCtrl + Aand paste in betweenbeginandend(line10to183) in theinstr_memory.vfile insrcdirectory. This file can be opened using the vivado 's bult-in editor. Once the lines are replaced, save the file and run the simulation again.
Executing the Test Bench
- To simulate the processor, open Vivado software and load the project. Once the project is loaded, run the simulation.
- Once the simulation is complete, it will generate a text file named
output_downscaled.txtin the<project_name>\<project_name>.sim\sim_1\behav\xsimdirectory. It contains the 1D binary representation of the resultatnt down sampled image of the original image that we have input to the simulation. - To obtain the filtered image binary data, replace
loadimwithendopinline 128in theAssembly.txtand follow the above steps.
Display the Outputs
- Copy and paste the
output_filtered.txtandoutput_downscaled.txtfiles in theIO_Codedirectory and run theshow.pypython code to display the results.
- You can use the
run.pycode in theIO_Codedirectory to filter and down sample the image using python. - Block Diagrams and Final Report are included in the
Block_DiagramandDocumentationfolders respectively.


