Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module shift_reg_r(
  2.     input in,
  3.     input [3:0] data,
  4.     input clk,sclr,sload,
  5.     output [3:0] y,
  6.     output CR);
  7.    
  8.     wire c1,c2,c3;
  9.    
  10.     FFD_sclr_sload d0(in,clk,sclr,sload,data[0],c1);
  11.     FFD_sclr_sload d1(c1,clk,sclr,sload,data[1],c2);
  12.     FFD_sclr_sload d2(c2,clk,sclr,sload,data[2],c3);
  13.     FFD_sclr_sload d3(c3,clk,sclr,sload,data[3],CR);
  14.    
  15.     assign y={CR,c3,c2,c1};
  16. endmodule
  17.  
  18.  
  19. module FFD_sclr_sload(
  20.     input D,clk,sclr,sload,data,
  21.     output reg Q);
  22.    
  23.     always @(posedge clk)
  24.         if(sclr) Q <= 0;
  25.         else if(sload) Q <= data;
  26.         else Q <= D;
  27. endmodule
  28.  
  29. module FSM_with_shift_reg(
  30.     input w,clk,
  31.     output [3:0] Y1,Y0,
  32.     output z);
  33.    
  34.     wire c0,c1;
  35.    
  36.     shift_reg_r ex1( w,4'b0,clk,~w,1'b0,Y1,c1);
  37.     shift_reg_r ex0(~w,4'b0,clk, w,1'b0,Y0,c0);
  38.    
  39.     assign z = c0 | c1;
  40. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement