Code Monkey home page Code Monkey logo

verilog_calculator_matrix_multiplication's Introduction

Verilog_Calculator_Matrix_Multiplication

This project shows how to make some basic matrix multiplication in Verilog.

Characteristics

There are some details about this implementation:

  1. Three by three matrixes are used.
  2. Each matrix input is a two byte container, so the maximum value (in decimal) it can hold is 65,535.

Scalability

If you need to increase the maximum value (65,535), then modify

reg [15:0] A1 [0:2][0:2];

to something like

reg [63:0] A1 [0:2][0:2];

in the case you want to work with 64 bits. Also remember to modify

input [143:0] A;

to

input [575:0] A;

(The value of 575 comes from having 9 spaces of 64 bits).

Similarly, if you need to modify the program to work with a n*n matrix, just modify

{A1[0][0],A1[0][1],A1[0][2],A1[1][0],A1[1][1],A1[1][2],A1[2][0],A1[2][1],A1[2][2]} = A;

in the calculator module to work with the correct amount of cells.

Visualization

This code was run in Xilinx ISE. When running the simulation, only the result was viewable as a one dimensional array. In order to fix this, in the simulation window:

  1. Add the matrixes from the Calculator.v to the simulation.
  2. Change the Radix to signed integer.
  3. Relaunch the simulation.

Run example

1D to 2D and 2D to 1D remapping

The transformation from 1D to 2D is done in the code

{A1[0][0],A1[0][1],A1[0][2],A1[1][0],A1[1][1],A1[1][2],A1[2][0],A1[2][1],A1[2][2]} = A;

where the 2D matrix A1 is populated from the 1D array A. Similarly, the remapping from 2D to 1D is done in

Result = {Res1[0][0],Res1[0][1],Res1[0][2],Res1[1][0],Res1[1][1],Res1[1][2],Res1[2][0],Res1[2][1],Res1[2][2]};

as 2D arrays cannot be outputs of modules.

verilog_calculator_matrix_multiplication's People

Contributors

pontazaricardo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

verilog_calculator_matrix_multiplication's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.