⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sent_buf.v

📁 基于ATEREAL EPM1270T144C5N CPLD 压力传感器数据采集源码 开发软件 Quartus II
💻 V
字号:
module sent_buf(clk,rst,plt_out,stop_ini);
input         clk,rst;
output[7:0]   plt_out;
output        stop_ini;
reg           over_sel;
reg      tp;
reg      stop_ini;
reg[5:0] now_data;
reg[5:0] next_data;
reg[7:0] plt_out;
reg[7:0] data_buf;
reg[3:0] now_state;

parameter  Q0=6'b000000;
parameter  Q1=6'b000001;
parameter  Q2=6'b000010;
parameter  Q3=6'b000011;
parameter  Q4=6'b000100;
parameter  Q5=6'b000101;
parameter  Q6=6'b000110;
parameter  Q7=6'b000111;
parameter  Q8=6'b001000;
parameter  Q9=6'b001001;
parameter  Q10=6'b001010;
parameter  Q11=6'b001011;
parameter  Q12=6'b001100;
parameter  Q13=6'b001101;
parameter  Q14=6'b001110;
parameter  Q15=6'b001111;
parameter  Q16=6'b010000;
parameter  Q17=6'b010001;
parameter  Q18=6'b010010;
parameter  Q19=6'b010011;
parameter  Q20=6'b010100;
parameter  Q21=6'b010101;
parameter  Q22=6'b010110;
parameter  Q23=6'b010111;
parameter  Q24=6'b011000;
parameter  Q25=6'b011001;
parameter  Q26=6'b011010;
parameter  Q27=6'b011011;
parameter  Q28=6'b011100;
parameter  Q29=6'b011101;
parameter  Q30=6'b011110;
parameter  Q31=6'b011111;
parameter  Q32=6'b100000;
parameter  Q33=6'b100001;
parameter  Q34=6'b100010;
parameter  Q35=6'b100011;
parameter  Q36=6'b100100;
parameter  Q37=6'b100101;
parameter  Q38=6'b100110;

always @(posedge clk or negedge rst)
begin
if(!rst)
  begin
  stop_ini<=1'b0;
  now_data<=6'b000000;
  now_state<=4'b0001;
  end
else if(now_state==4'b1000)
  begin
  tp<=~tp;
  stop_ini<=stop_ini;
  now_state<=now_state+4'b0001;
  end
else if(now_state==4'b1101)
  begin
  now_data<=next_data;
  now_state<=4'b0001;
  stop_ini<=stop_ini;
  tp<=tp;
  end
else if(now_state==4'b0010)
  begin
  now_state<=now_state+4'b0001;
  now_data<=now_data;
  tp<=tp;
  if(now_data==Q38)
  stop_ini<=1'b1;
  else 
  stop_ini<=stop_ini;
  end
else
  begin
  now_state<=now_state+4'b0001;
  now_data<=now_data;
  stop_ini<=stop_ini;
  tp<=tp;
  end
end 

always @(posedge clk or negedge rst)
begin
if(!rst)
   plt_out<=8'b11111111;
else if(now_state==4'b1101)
   plt_out<=data_buf;
else
   plt_out<=plt_out;
end

always @(tp or now_data)
begin
    case(now_data)
        Q0:next_data<=Q1;
        Q1:next_data<=Q2;
        Q2:next_data<=Q3;
        Q3:next_data<=Q4;
        Q4:next_data<=Q5;
        Q5:next_data<=Q6;
        Q6:next_data<=Q7;
        Q7:next_data<=Q8;
        Q8:next_data<=Q9;
        Q9:next_data<=Q10;
        Q10:next_data<=Q11;
        Q11:next_data<=Q12;
        Q12:next_data<=Q13;
        Q13:next_data<=Q14;
        Q14:next_data<=Q15;
        Q15:next_data<=Q16;
        Q16:next_data<=Q17;
        Q17:next_data<=Q18;
        Q18:next_data<=Q19;
        Q19:next_data<=Q20;
        Q20:next_data<=Q21;
        Q21:next_data<=Q22;
        Q22:next_data<=Q23;
        Q23:next_data<=Q24;
        Q24:next_data<=Q25;
        Q25:next_data<=Q26;
        Q26:next_data<=Q27;
        Q27:next_data<=Q28;
        Q28:next_data<=Q29;
        Q29:next_data<=Q30;
        Q30:next_data<=Q31;
        Q31:next_data<=Q32;
        Q32:next_data<=Q33;
        Q33:next_data<=Q34;
        Q34:next_data<=Q35;
        Q35:next_data<=Q36;
        Q36:next_data<=Q37;
        Q37:next_data<=Q38;
        Q38:next_data<=Q38;
   default:next_data<=Q0;
   endcase
end

always @(posedge clk or negedge rst)
begin
if(!rst)
data_buf<=8'b11111111;
else
case(now_data)
      Q0:data_buf<=8'b11111111;
      Q1:data_buf<=8'b11111111;
      Q2:data_buf<=8'b11111111;
      Q3:data_buf<=8'b11111111;
      Q4:data_buf<=8'b11111111;
      Q5:data_buf<=8'b11111111;
      Q6:data_buf<=8'b11111111;
      Q7:data_buf<=8'b11111111;
      Q8:data_buf<=8'b11111111;
      Q9:data_buf<=8'b11111111;
      Q10:data_buf<=8'b11111111;
      Q11:data_buf<=8'b11111111;
      Q12:data_buf<=8'b11111111;
      Q13:data_buf<=8'b11111111;
      Q14:data_buf<=8'b11111111;
      Q15:data_buf<=8'b11111110;
      Q16:data_buf<=8'b00000011;
      Q17:data_buf<=8'b00100000;
      Q18:data_buf<=8'b00000000;
      Q19:data_buf<=8'b00000000;
      Q20:data_buf<=8'b00000000;
      Q21:data_buf<=8'b00001011;
      Q22:data_buf<=8'b00000000;
      Q23:data_buf<=8'b00000000;
      Q24:data_buf<=8'b00000000;
      Q25:data_buf<=8'b00000000;
      Q26:data_buf<=8'b00000011;
      Q27:data_buf<=8'b00000000;
      Q28:data_buf<=8'b01000000;
      Q29:data_buf<=8'b00000000;
      Q30:data_buf<=8'b00000000;
      Q31:data_buf<=8'b00000101;
      Q32:data_buf<=8'b00110001;
      Q33:data_buf<=8'b10000000;
      Q34:data_buf<=8'b00110001;
      Q35:data_buf<=8'b10000000;
      Q36:data_buf<=8'b11000000;
      Q37:data_buf<=8'b00000000;
      Q38:data_buf<=8'b00000000;
  default:data_buf<=8'b00000000;
  endcase
end

endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -