shift and add multiplication verilog code
#1

i need verilog code for shift rows in rijndael algorithm
Reply
#2
The multiplication of shifts and aggregates is similar to multiplication done by paper and pencil. This method adds the multiplying X to itself Y times, where Y denotes the multiplier. To multiply two numbers per paper and pencil, the algorithm must take the digits of the multiplier one at a time from right to left, multiply the multiplying by a single digit of the multiplier and place the intermediate product in the appropriate positions to the left of the results  .

Code:
module MULTIPLY_revision (
 input              clk, reset, start,
 input       [7:0]  A_in, B_in,
 output reg         done_tick,
 output wire [15:0] product
);

localparam [1:0]
   idle  = 2'b00,
   op    = 2'b01,
   shift = 2'b10;

// signal declaration
reg       carry, next_carry;
reg [1:0] state, next_state;
reg [7:0] reg_PL, PL, reg_PH, PH, reg_a_multiplicand, a_multiplicand;  
reg [4:0] counter, next_counter;

assign product = {reg_PH, reg_PL};

always @(posedge clk, posedge reset)
 if (reset) begin
   state              <= idle;
   counter            <= 0;
   carry              <= 0;
   reg_PL             <= 0;
   reg_PH             <= 0;
   reg_a_multiplicand <= 0;
 end
 else begin
   state              <= next_state;
   carry              <= next_carry;
   counter            <= next_counter;
   reg_PL             <= PL;
   reg_PH             <= PH;
   reg_a_multiplicand <= a_multiplicand;
 end

// next state logic
always @ * begin
 done_tick      = 1'b0;
 PL             = reg_PL;
 PH             = reg_PH;
 a_multiplicand = reg_a_multiplicand;
 next_carry     = carry;
 next_counter   = counter;
 next_state     = state;

 case(state)
   idle: begin
     if(start) begin
       next_counter   = 7; // load 7 for 8 bits down counter
       PL             = B_in; // load multiplier into lower half
       PH             = 8'b0; // clear upper half.
       a_multiplicand = A_in; // load A multiplicand into register.
       next_state     = op;
     end
   end

   op: begin
     if(reg_PL[0] == 1) begin
       {next_carry,PH} = reg_PH + reg_a_multiplicand;      // add A multiplicand to upper half with carry bit.
     end
     next_counter = counter - 1;
     next_state   = shift;            
   end

   shift: begin
     {next_carry,PH,PL} = {carry,reg_PH,reg_PL} >> 1;  // putting everything back together and shifting everything to the right once.
     if(next_counter == 0) begin
       next_state = idle;
     end
     else begin
       next_state = op;
     end
   end

   default: begin
     next_state = idle;
   end
 endcase
end


endmodule


  `timescale 1ns / 1ps
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: how to shift partial product in verilog, matrix multiplication in verilog code, verilog and, add shift multipler verilog coglde, research paper on multiplication techniques in verilog, code of multiplication of bcd in verilog, did surnames begin,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  source code in php for online training and placement cell management 1 6,665 23-03-2018, 09:06 AM
Last Post: ritzi
  ppt on design and implementation of intelligent campus security tracking system based on rfid and zigbee 7 15,913 09-02-2018, 02:20 PM
Last Post: udaya
  matlab code shadow detection and removal in colour images using matlab 2 2,237 12-01-2018, 01:24 PM
Last Post: dhanabhagya
Smile physics investigatory projects for class 12 cbse to set up a common base transistor circuit and to study its input and o 3 25,007 20-12-2017, 09:44 AM
Last Post: jaseela123d
  code for fingerprint based atm and locker system 3 8,900 01-12-2017, 11:22 AM
Last Post: jaseela123d
  multiplication using the nikhilam sutra vedic maths 1 972 23-10-2017, 11:09 PM
Last Post: Diya_nila
  verilog radix 8 booth multiplier 7 3,233 18-10-2017, 11:05 AM
Last Post: jaseela123d
  location alarm android tutorial and source code 1 1,437 14-10-2017, 02:53 PM
Last Post: shakil19944
  matlab code for digital watermarking using dct and dwt 5 4,409 19-05-2017, 02:59 PM
Last Post: jaseela123d
  booths algorithm multiplication 8085 4 2,449 11-05-2017, 11:25 AM
Last Post: jaseela123d

Forum Jump: