SHARE
TWEET

Untitled

a guest Aug 27th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  module barrel_shift
  2.      (
  3.          input logic [7:0] a,
  4.          input logic [2:0] amt,
  5.          input logic lr;
  6.          output logic [7:0] y
  7.      );
  8.  
  9.  logic [7:0] s0, s1;
  10.  
  11.  always_comb begin
  12.      // right rotate
  13.      if(lr) begin
  14.          assign s0 = amt[0] ? {a[0], a[7:1]} : a;
  15.          assign s1 = amt[1] ? {s0[1:0], s0[7:2]} : s0;
  16.          assign y = amt[2] ? {s1[3:0], s[7:4]} : s1;
  17.      end
  18.      // left rotate
  19.      else begin
  20.          assign s0 = amt[0] ? {a[6:0], a[7]} : a;
  21.          assign s1 = amt[1] ? {s0[5:0], s0[7:6]} : s0;
  22.          assign y = amt[2] ? {s1[3:0], s1[7:4]} : s1;
  23.      end
  24.  end
  25.  
  26.  endmodule
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top