Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `define s0 4'b0000
- `define s1 4'b0001
- `define s2 4'b0010
- `define s3 4'b0011
- `define s4 4'b0100
- `define s5 4'b0101
- `default_nettype none
- module top(data_in,clk,clr,data_out);
- input clr;
- input clk;
- input [129:0]data_in;
- reg [3:0]state;
- output [129:0]data_out;
- reg [129:0]data_out;
- reg EIEOS,error,SKP,valid,SKP_98,SKP_66,SKP_130,SKP_162,SKP_194;
- reg [8:0]count;
- integer i;
- reg [259:0]temp;
- reg [129:0]temp2;
- always @( posedge clr or posedge clk )
- begin
- if (clr)
- begin
- state <= `s0;
- temp<=259'h00;
- temp2<=130'h00;
- EIEOS = 0;
- SKP<=0;
- SKP_98=0;
- SKP_66=0;
- SKP_130=0;
- SKP_162=0;
- SKP_194=0;
- error <= 0;
- count = 9'b00000000;
- end
- else
- begin
- case(state)
- `s0:
- begin
- if(data_in)
- begin
- temp<= data_in;
- state<=`s1;
- end
- else
- state<=`s0;
- end
- `s1:
- begin
- temp <= {data_in,temp[129:0]};
- state<=`s2;
- end
- `s2:
- begin
- for(i=0;i<=129;i=i+1)
- begin
- if(temp[129:0]==130'b1111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000001)
- begin
- data_out<=temp[129:0];
- count=i+1;
- if(count>=130)
- count= count-130;
- temp<={data_in,temp[259:130]};
- EIEOS=1;
- state<=`s3;
- end
- else
- begin
- if((i==129) && (EIEOS==0))
- begin
- //i<=i-130;
- temp<={data_in,temp[259:130]};
- state<=`s2;
- end
- else
- begin
- temp<=temp>>1;
- end
- end
- end
- end
- `s3:
- begin
- temp<={data_in,temp[129:0]};
- valid<=0;
- SKP_66=0;
- SKP_98=0;
- SKP_130=0;
- SKP_162=0;
- SKP_194=0;
- //$display("%b" ,temp[count+:2]);
- if(temp[count+:2]==2'b01)
- begin
- if((temp[(count+2)+:40]==40'hE1AAAAAAAA)&&(count>=64))
- begin
- count=count+66;
- SKP_66=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) &&(count>=32))
- begin
- count=count+98;
- SKP_98=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- //begin
- if(temp[(count+2)+:104]==104'hE1AAAAAAAAAAAAAAAAAAAAAAAA)
- begin
- count=count;
- temp[129:0]<=temp[259:130];
- SKP_130=1;
- state<=`s3;
- end
- else
- //begin
- if(temp[(count+2)+:128]==128'hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
- begin
- temp2<=temp[count+:130];
- SKP<=1;
- if((temp[(count+130)+:8]==8'hE1)&&(count<122))
- begin
- count=count+32;
- SKP<=0;
- SKP_162=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- //begin
- if((temp[(count+130)+:40]==40'hE1AAAAAAAA)&&(count<90))
- begin
- count=count+64;
- SKP<=0;
- SKP_194=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if(count>=90)
- begin
- temp[129:0]<=temp[259:130];
- state<=`s4;
- end
- else
- begin
- valid<=1;
- data_out<=temp[count+:130];
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- end
- else
- if((temp[(count+2)+:40]==40'hE1AAAAAAAA) && (temp[(count+68)+:40]==40'hE1AAAAAAAA) && (count<64))
- begin
- count=count+2;
- SKP_66=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if((temp[(count+2)+:40]==40'hE1AAAAAAAA) && (temp[(count+68)+:72]==72'hE1AAAAAAAAAAAAAAAA)&& (count<64))
- begin
- count=count+34;
- SKP_66=1;
- SKP_98=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if((temp[(count+2)+:40]==40'hE1AAAAAAAA) && (temp[(count+68)+:104]==104'hE1AAAAAAAAAAAAAAAAAAAAAAAA)&& (count<64))
- begin
- count=count+66;
- SKP_66=1;
- SKP_130=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if((temp[(count+2)+:40]==40'hE1AAAAAAAA) && (temp[(count+68)+:128]==128'hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)&& (count<64))
- begin
- SKP_66=1;
- count=count+66;
- temp2<=temp[count+:130];
- SKP<=1;
- if((temp[(count+130)+:8]==8'hE1)&&(count<56))
- begin
- count=count+32;
- SKP<=0;
- SKP_162=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- //begin
- if((temp[(count+130)+:40]==40'hE1AAAAAAAA)&&(count<24))
- begin
- count=count+64;
- SKP<=0;
- SKP_194=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if(count>=56)
- begin
- temp[129:0]<=temp[259:130];
- state<=`s4;
- end
- else
- begin
- valid<=1;
- data_out<=temp[count+:130];
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- end
- else
- if(((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA)&& (temp[(count+98)+:2]==2'b10)) ||((temp[(count+2)+:40]==40'hE1AAAAAAAA)&& (temp[(count+66)+:2]==2'b10)))
- begin
- valid<=1;
- data_out<=temp[count+:130];
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) && (temp[(count+100)+:40]==40'hE1AAAAAAAA) && (count<32))
- begin
- count=count+2;
- SKP_66=1;
- SKP_98=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) && (temp[(count+100)+:72]==72'hE1AAAAAAAAAAAAAAAA)&& (count<32))
- begin
- count=count+34;
- SKP_98=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) && (temp[(count+100)+:104]==104'hE1AAAAAAAAAAAAAAAAAAAAAAAA)&& (count<32))
- begin
- count=count+34;
- SKP_98=1;
- SKP_130=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) && (temp[(count+100)+:128]==128'hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)&& (count<32))
- begin
- SKP_98=1;
- count=count+98;
- temp2<=temp[count+:130];
- SKP<=1;
- if((temp[(count+130)+:8]==8'hE1)&&(count<24))
- begin
- count=count+32;
- SKP<=0;
- SKP_162=1;
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- else
- if(count>=24)
- begin
- temp[129:0]<=temp[259:130];
- state<=`s4;
- end
- else
- begin
- valid<=1;
- data_out<=temp[count+:130];
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- end
- else
- begin
- valid<=1;
- data_out<=temp[count+:130];
- temp[129:0]<=temp[259:130];
- state<=`s3;
- end
- end
- else
- //begin
- if(temp[count+:2]==2'b10)
- begin
- valid<=1;
- data_out<=temp[count+:130];
- //$display ("%b,%b",temp ,data_out);
- temp[129:0]<=temp[259:130];
- state <= `s3;
- //state <= `s6;
- end
- else
- begin
- error <= 1;
- state <= `s1;
- end
- if(count>=130)
- begin
- count=count-130;
- temp[129:0]<=temp[259:130];
- end
- end
- `s4:
- begin
- temp<={data_in,temp[129:0]};
- if(temp[count+:8]==8'hE1)
- begin
- SKP<=0;
- count=count+32;
- SKP_162=1;
- state<=`s3;
- end
- else
- if(temp[count+:40]==40'hE1AAAAAAAA)
- begin
- SKP<=0;
- count=count+64;
- SKP_194=1;
- state<=`s3;
- end
- else
- begin
- valid<=1;
- SKP<=0;
- data_out<=temp2;
- state<=`s3;
- end
- if(count>=130)
- begin
- count=count-130;
- temp[129:0]<=temp[259:130];
- end
- end
- default:
- begin
- state<=`s0;
- end
- endcase
- end
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement