老怪甲 发表于 2010-5-28 10:47:00

移位寄存器Verilog代码

移位寄存器

//
//
//-----------------------------------------------------------------------------------
// DESCRIPTION: Shift register
//         Type : univ
//         Width : 4
//         Shift direction: right/left (right active high)
//
//         CLK active : high
//         CLR active : high
//         CLR type : synchronous
//         SET active : high
//         SET type : synchronous
//         LOAD active : high
//         CE active : high
//         SERIAL input : SI
//
//-----------------------------------------------------------------------------------


module shft_reg (CLR , SET , DIR , CE , LOAD , DATA , SI , data_out , CLK );
input CLR , SET , CE , LOAD , DIR , SI , CLK ;
input DATA ;
output data_out ;



reg TEMP;

always @(posedge CLK )
begin
    if (CE == 1'b1)
      if (CLR == 1'b1)
      TEMP = {4{1'b0}};
      else if (SET == 1'b1)
      TEMP = {4{1'b1}};
      else if (LOAD == 1'b1)
      TEMP = DATA ;
      else if (DIR == 1'b1)
      TEMP = {SI , TEMP };
      else
      TEMP = {TEMP , SI };
end

assign data_out = TEMP;
endmodule

weibode01 发表于 2010-11-9 11:11:53

这些都是我最近实验的内容

伍金霄 发表于 2016-5-10 11:51:37

有人做过红外测距没?
页: [1]
查看完整版本: 移位寄存器Verilog代码