banner

Sunday, July 10, 2022

standard matrix multiplication with multiple MAC

 #include <stdio.h>


int main() {


//elements we took mat1: 2X3 and  mat2: 3X2

    int mac=4;

    int a[8][8]= {4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,};


    int b[8][8]= {4,1,2,3,1,2,5,6,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,

                  4,1,2,3,1,2,4,5,};


    int c[]= {0,0,0,0};


    int d[8][8]= {0,0,0,0};


    int ra=8,ca=8,rb=8,cb=8;

    

    int w1=0,x1,y1,z1,i,j,k,l=0,w2,x2,y2,z2,x3,y3,z3,x4,y4,z4;

    

    for (i=0; i<ra; i++){


        for (j=0; j<cb; j++){


            for (k=0; k<ca; k=k+mac){


                x1= a[i][l];

                y1= b[l][j];

               // z= c[i][j];

                printf("i=%d, k=%d, j=%d , l=%d\n",i,k,j,l);

                z1=w1;

                w1= (x1 * y1)+z1;

                printf("w1=%d, x1=%d, y1=%d, z1=%d \n",w1,x1,y1,z1);

                 l++;

                x2= a[i][l];

                y2= b[l][j];

                 printf("i=%d, k=%d, j=%d , l=%d\n",i,k,j,l);

                z2=w1;

                w1=x2 *y2+z2;

                printf("w1=%d, x2=%d, y2=%d, z2=%d \n",w1,x2,y2,z2);

                l++;

                x3= a[i][l];

                y3= b[l][j];

                 printf("i=%d, k=%d, j=%d , l=%d\n",i,k,j,l);

                z3=w1;

                w1=x3 *y3+z3;

                printf("w1=%d, x2=%d, y2=%d, z2=%d \n",w1,x3,y3,z3);

                l++;

                x4= a[i][l];

                y4= b[l][j];

                 printf("i=%d, k=%d, j=%d , l=%d\n",i,k,j,l);

                z4=w1;

                w1=x4 *y4+z4;

                printf("w1=%d, x2=%d, y2=%d, z2=%d \n",w1,x4,y4,z4);

                l++;

            }

            

            if (k==ca) {k=0;;d[i][j]=w1;l=0; w1=0;c[l]=0;}

            printf("d[%d][%d]:%d\n",i,j,d[i][j]);

        }


       if (j==cb) j=0; 


    }


    return 0;


}




Thursday, July 7, 2022

standard matrix multiplication code in basic c language

 #include <stdio.h>

int main() {

//elements we took mat1: 2X3 and  mat2: 3X2

    int a[2][3]= {4,1,2,3,1,2};

    int b[3][2]= {4,1,2,3,1,2};

    int c[2][2]= {0,0,0,0};

    int d[2][2]= {0,0,0,0};

    int ca=3,ra=2,cb=2,rb=3;

    int w,x,y,z,i,j,k;

    for (i=0; i<ra; i++){

        for (j=0; j<cb; j++){

            for (k=0; k<ca; k++){

                x= a[i][k];

                y= b[k][j];

               // z= c[i][j];

                printf("i=%d, k=%d, j=%d\n",i,k,j);

                z=w;

                w= (x * y)+z;

                printf("w=%d, x=%d, y=%d, z=%d \n",w,x,y,z);

            }

            if (k==ca) {k=0;d[i][j]=w;w=0;}

            printf("d[%d][%d]:%d\n",i,j,d[i][j]);

        }

       if (j==cb) j=0; 

    }

    return 0;

}

programiz link: https://www.programiz.com/c-programming/online-compiler/




Sunday, March 7, 2021

ARM CORTEX M0+ Interfacing part

 

**************************************************************************

 ARM Cortex M0 +

 **************************************************************************

########################################################
Embedded C - Interfacing

########################################################

Part 1- Basic Interfacing codes

**************************************************************************

LED blinking

**************************************************************************

 * Steps to realize basic embedded C code to blink green LED with some finite delay.

Without header file MKL25Z4.h 

# How to simulate the basic LED blinking embedded C code on FRDM KL25Z freedom board

With header file MKL25Z4.h

# Write Embedded C code to blink green LED with MKL25Z4.h library on KL25Z FRDM board.

 

Part-2

# Write the embedded C code to blink all three green, red and blue the LEDs on the FRDM-KL25Z4 after 500ms.

**************************************************************************

Switch and LED

**************************************************************************

* Steps to realize the interfacing of switch and LED with KL25Z FRDM board.

# Write the simple switch and LED interfacing code in Embedded C on KL25Z FRDM board.

 **************************************************************************

Linear search

 **************************************************************************

 * Write embedded C code for FRDMKL25Z to perform linear search of the number 25 from list of 10 elements size 32-bit. If search result true then lit green LED else red LED for 100ms.

 **************************************************************************

Simple calculator

 **************************************************************************

 * Write Embedded C code for FRDMKL25Z to interface four switches to perform the operation mentioned in below table and store the results to the locations.

SW1

SW2

SW3

SW4

Operation

Result stored on location

OFF

OFF

OFF

OFF

No operation

-

ON

OFF

OFF

OFF

Addition

0x1FFFF100 – 0x1FFFF103

OFF

ON

OFF

OFF

Subtraction

0x1FFFF104 – 0x1FFFF107

OFF

OFF

ON

OFF

Multiplication

0x1FFFF108 – 0x1FFFF10F

OFF

OFF

OFF

ON

Division

0x1FFFF110 – 0x1FFFF113

 **************************************************************************

Even and odd numbers
**************************************************************************

* Write embedded C code for FRDMKL25Z to bifurcate the even and odd numbers from given 16 elements list each having size of 8-bit. Store even numbers to the location starting from 0x1FFFF100 to 0x1FFFF10F and odd numbers to the location starting from 0x1FFFF110 to 0x1FFFF11F.

 **************************************************************************

Sunday, February 14, 2021

VHDL design main page

 VHDL design main page

******************************************************************************

# Step by step installation and path setting of GHDL and GTKWave. open VHDL simulator on windows platform.

_________________________________________________________________________________

# Design and implement all basic gates in VHDL on simuator GHDL and GTKWave.

_________________________________________________________________________________

Test VHDL code of half adder code on GHDL and GTKWave open simulator.

_________________________________________________________________________________

#Design and implement the full adder circuit by taking instance of the half adder circuit in structural style modeling in VHDL on GHDL and GTKWave simulator.

_________________________________________________________________________________

# Design 3X8 decoder using behavioral style modelling in VHDL and simulate using GHDL and GTKWave open simulator. 

_________________________________________________________________________________ 

# Design 8X3 encoder using structural style modeling in VHDL and simulate on GHDL and GTKWave open simulator.

_________________________________________________________________________________ 

# Design 1X8 demux using behavioural style modelling in VHDL and simulate on GHDL and GTKWave open simulator.

_________________________________________________________________________________ 

# Design 8X1 mux using structural style modelling in VHDL by taking the instance of mux 4X1 designed with the dataflow modeling. Simulate the design on GHDL and GTKWave open simulator.

_________________________________________________________________________________

 

Saturday, February 13, 2021

Arm Cortex M0+ simulation codes

**************************************************************************

 ARM Cortex M0 +

 **************************************************************************

########################################################
Codes

########################################################

Part 1 - Primitive set codes

**************************************************************************

Instruction set type-1: data transfer 

**************************************************************************

 Instruction set (register to register)

* Data transfer instructions with in the processor of ARM cortex M0+

Assembly language and embedded C code 

# Write KL25Z ARM cortex M0 code to transfer data with in the processor (register to register)  **************************************************************************

 Instruction set (Register to Memory vice versa)

* Data transfer instructions of ARM cortex M0/M0+ to memory access through registers.

Assembly language code

 # Write assembly language code to program KL25Z (ARM cortex M0+) transfer the data with memory. 

Embedded C code

# Write embedded C code for KL25Z to transfer data from memory to variable and variable to memory.

**************************************************************************

Instruction set type-2: Arithmetic and logical

# Write assembly code to perform Arithmetic operations

#Write assembly code to perform logical operations

Assembly language Problems

# Write Embedded C code to perform the arithmetic and logical operations for integer data type. 

************************************************************************** 

Instruction set type-3: Program flow control

# Write assembly language code for all type of the conditional and unconditional program flow control instructions.

1) Write assembly language code for all type of unconditional program flow control instructions.

2) Write assembly language code for all type of the conditional for value comparison operations 

3) Write assembly language code for all type of the conditional overgflow and signed program flow control instructions

# Write embedded C and assembly code for if_else to understand program flow instructions.

# Write embedded C and assembly code to understand program flow instructions for "for loop".

 **************************************************************************

 

**************************************************************************

 _________________________________________________________

Part 2 Algorithm Set codes

**************************************************************************

Memory to memory data trasnsfer

# write code to transfer block of data from 1FFFF104 to 1FFFF164 and block size is stores on 1FFFF100. 

**************************************************************************

Find the maximum and minimum number from given list

**************************************************************************

Steps to realize code

 *Write assembly and embedded C code to find the maximum and minimum from 32 bit data stored from memory location 0x1FFFF104, No. of data elements is stored on memory location 0x1FFFF100.  

Assembly language code

# solution of assembly code to find the maximum and minimum from block of 32 bit data stored from memory location 0x1FFFF104, No. of data elements is stored on memory location 0x1FFFF100.  

Solution-1                                                        Solution-2

Embedded C code

Solution


**************************************************************************

Arrange list of data in ascending and descending order

**************************************************************************

Steps to realize code

*Write assembly and embedded C code to arrange set of 32 bit data stored from memory location 0x1FFFF104 in ascending and descending order, No. of data elements is stored on memory location 0x1FFFF100. 

Assembly code of ascending order

Solution-1

Assembly code descending order

Solution-1  

 **************************************************************************

Generate Fibonacci series 

**************************************************************************

Write assembly and embedded C code to generate Fibonacci series of 32 bit data size and store the element starting from the memory location 0x1FFF104. Number of maximum elements is stored on memory location 0x1FFF100.

Elements  0, 1, 1, 2, 3, 5, 8, 13, 21, 34 .......

Image result for fibonacci series 

Assembly code                                             Embedded C code

______________________________________________________



 

VLSI and Embedded junction main page

########################################################

***************VLSI***************

#####################################################

 _____________________________________________________

VERILOG Main page

 _____________________________________________________

 Icarus verilog+GTKWave based simulations

Installation simulators                Execute code                      Designs 

_____________________________________________________

VHDL main page

_____________________________________________________

GHDL+GTKWave based simulations

Installation simulators                      Execute code                        Designs

 _____________________________________________________

 

#####################################################


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

***************EMBEDDED***************

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ARM cortex M0+

Basic Algorithm code                                        Interfacing    

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 8051

Basic Algorithm code                                        Interfacing      

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Basic C codes

Matrix multiplier code

 


 

 

 


PULP RISC-V important links

1) Understanding and working with PULP - all the details of the architectures https://pulp-platform.org/docs/riscv_workshop_zurich/schiavone...