Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.57 KB | None | 0 0
  1. `define s0 4'b0000
  2. `define s1 4'b0001
  3. `define s2 4'b0010
  4. `define s3 4'b0011
  5. `define s4 4'b0100
  6. `define s5 4'b0101
  7.  
  8. `default_nettype none
  9. module top(data_in,clk,clr,data_out);
  10.  
  11. input clr;
  12. input clk;
  13. input [129:0]data_in;
  14.  
  15. reg [3:0]state;
  16. output [129:0]data_out;
  17. reg [129:0]data_out;
  18.  
  19. reg EIEOS,error,SKP,valid,SKP_98,SKP_66,SKP_130,SKP_162,SKP_194;
  20. reg [8:0]count;
  21. integer i;
  22. reg [259:0]temp;
  23. reg [129:0]temp2;
  24.  
  25. always @( posedge clr or posedge clk )
  26. begin
  27. if (clr)
  28. begin
  29. state <= `s0;
  30. temp<=259'h00;
  31. temp2<=130'h00;
  32. EIEOS = 0;
  33. SKP<=0;
  34. SKP_98=0;
  35. SKP_66=0;
  36. SKP_130=0;
  37. SKP_162=0;
  38. SKP_194=0;
  39.  
  40. error <= 0;
  41. count = 9'b00000000;
  42.  
  43. end
  44.  
  45.  
  46. else
  47. begin
  48. case(state)
  49.  
  50. `s0:
  51. begin
  52. if(data_in)
  53. begin
  54. temp<= data_in;
  55. state<=`s1;
  56. end
  57. else
  58. state<=`s0;
  59. end
  60.  
  61. `s1:
  62. begin
  63. temp <= {data_in,temp[129:0]};
  64. state<=`s2;
  65. end
  66.  
  67. `s2:
  68. begin
  69. for(i=0;i<=129;i=i+1)
  70. begin
  71.  
  72. if(temp[129:0]==130'b1111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000001)
  73. begin
  74. data_out<=temp[129:0];
  75. count=i+1;
  76. if(count>=130)
  77. count= count-130;
  78. temp<={data_in,temp[259:130]};
  79. EIEOS=1;
  80. state<=`s3;
  81. end
  82.  
  83. else
  84. begin
  85. if((i==129) && (EIEOS==0))
  86. begin
  87. //i<=i-130;
  88. temp<={data_in,temp[259:130]};
  89. state<=`s2;
  90. end
  91. else
  92. begin
  93. temp<=temp>>1;
  94. end
  95.  
  96. end
  97. end
  98. end
  99.  
  100. `s3:
  101. begin
  102. temp<={data_in,temp[129:0]};
  103. valid<=0;
  104. SKP_66=0;
  105. SKP_98=0;
  106. SKP_130=0;
  107. SKP_162=0;
  108. SKP_194=0;
  109.  
  110.  
  111. //$display("%b" ,temp[count+:2]);
  112.  
  113. if(temp[count+:2]==2'b01)
  114. begin
  115.  
  116.  
  117. if((temp[(count+2)+:40]==40'hE1AAAAAAAA)&&(count>=64))
  118. begin
  119. count=count+66;
  120. SKP_66=1;
  121.  
  122. temp[129:0]<=temp[259:130];
  123. state<=`s3;
  124.  
  125. end
  126. else
  127. if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) &&(count>=32))
  128. begin
  129. count=count+98;
  130. SKP_98=1;
  131.  
  132. temp[129:0]<=temp[259:130];
  133. state<=`s3;
  134.  
  135. end
  136. else
  137. //begin
  138. if(temp[(count+2)+:104]==104'hE1AAAAAAAAAAAAAAAAAAAAAAAA)
  139. begin
  140. count=count;
  141. temp[129:0]<=temp[259:130];
  142. SKP_130=1;
  143. state<=`s3;
  144. end
  145. else
  146. //begin
  147. if(temp[(count+2)+:128]==128'hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
  148. begin
  149. temp2<=temp[count+:130];
  150. SKP<=1;
  151. if((temp[(count+130)+:8]==8'hE1)&&(count<122))
  152. begin
  153. count=count+32;
  154. SKP<=0;
  155. SKP_162=1;
  156. temp[129:0]<=temp[259:130];
  157. state<=`s3;
  158. end
  159. else
  160. //begin
  161. if((temp[(count+130)+:40]==40'hE1AAAAAAAA)&&(count<90))
  162. begin
  163. count=count+64;
  164. SKP<=0;
  165. SKP_194=1;
  166. temp[129:0]<=temp[259:130];
  167. state<=`s3;
  168. end
  169. else
  170.  
  171. if(count>=90)
  172. begin
  173. temp[129:0]<=temp[259:130];
  174.  
  175. state<=`s4;
  176. end
  177. else
  178. begin
  179. valid<=1;
  180.  
  181. data_out<=temp[count+:130];
  182. temp[129:0]<=temp[259:130];
  183. state<=`s3;
  184. end
  185. end
  186. else
  187. if((temp[(count+2)+:40]==40'hE1AAAAAAAA) && (temp[(count+68)+:40]==40'hE1AAAAAAAA) && (count<64))
  188. begin
  189. count=count+2;
  190. SKP_66=1;
  191.  
  192. temp[129:0]<=temp[259:130];
  193. state<=`s3;
  194.  
  195. end
  196. else
  197. if((temp[(count+2)+:40]==40'hE1AAAAAAAA) && (temp[(count+68)+:72]==72'hE1AAAAAAAAAAAAAAAA)&& (count<64))
  198. begin
  199. count=count+34;
  200. SKP_66=1;
  201. SKP_98=1;
  202. temp[129:0]<=temp[259:130];
  203. state<=`s3;
  204. end
  205. else
  206. if((temp[(count+2)+:40]==40'hE1AAAAAAAA) && (temp[(count+68)+:104]==104'hE1AAAAAAAAAAAAAAAAAAAAAAAA)&& (count<64))
  207. begin
  208. count=count+66;
  209. SKP_66=1;
  210. SKP_130=1;
  211. temp[129:0]<=temp[259:130];
  212. state<=`s3;
  213. end
  214. else
  215. if((temp[(count+2)+:40]==40'hE1AAAAAAAA) && (temp[(count+68)+:128]==128'hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)&& (count<64))
  216. begin
  217.  
  218. SKP_66=1;
  219. count=count+66;
  220. temp2<=temp[count+:130];
  221. SKP<=1;
  222. if((temp[(count+130)+:8]==8'hE1)&&(count<56))
  223. begin
  224. count=count+32;
  225. SKP<=0;
  226. SKP_162=1;
  227. temp[129:0]<=temp[259:130];
  228. state<=`s3;
  229. end
  230. else
  231. //begin
  232. if((temp[(count+130)+:40]==40'hE1AAAAAAAA)&&(count<24))
  233. begin
  234. count=count+64;
  235. SKP<=0;
  236. SKP_194=1;
  237. temp[129:0]<=temp[259:130];
  238. state<=`s3;
  239. end
  240. else
  241. if(count>=56)
  242. begin
  243. temp[129:0]<=temp[259:130];
  244.  
  245. state<=`s4;
  246. end
  247. else
  248. begin
  249. valid<=1;
  250.  
  251. data_out<=temp[count+:130];
  252. temp[129:0]<=temp[259:130];
  253. state<=`s3;
  254. end
  255.  
  256. end
  257. else
  258. 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)))
  259. begin
  260. valid<=1;
  261.  
  262. data_out<=temp[count+:130];
  263. temp[129:0]<=temp[259:130];
  264. state<=`s3;
  265. end
  266. else
  267. if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) && (temp[(count+100)+:40]==40'hE1AAAAAAAA) && (count<32))
  268. begin
  269. count=count+2;
  270. SKP_66=1;
  271. SKP_98=1;
  272. temp[129:0]<=temp[259:130];
  273. state<=`s3;
  274.  
  275. end
  276. else
  277. if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) && (temp[(count+100)+:72]==72'hE1AAAAAAAAAAAAAAAA)&& (count<32))
  278. begin
  279. count=count+34;
  280.  
  281. SKP_98=1;
  282. temp[129:0]<=temp[259:130];
  283. state<=`s3;
  284. end
  285. else
  286. if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) && (temp[(count+100)+:104]==104'hE1AAAAAAAAAAAAAAAAAAAAAAAA)&& (count<32))
  287. begin
  288. count=count+34;
  289. SKP_98=1;
  290. SKP_130=1;
  291. temp[129:0]<=temp[259:130];
  292. state<=`s3;
  293. end
  294. else
  295. if((temp[(count+2)+:72]==72'hE1AAAAAAAAAAAAAAAA) && (temp[(count+100)+:128]==128'hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)&& (count<32))
  296. begin
  297. SKP_98=1;
  298. count=count+98;
  299. temp2<=temp[count+:130];
  300. SKP<=1;
  301.  
  302. if((temp[(count+130)+:8]==8'hE1)&&(count<24))
  303. begin
  304. count=count+32;
  305. SKP<=0;
  306. SKP_162=1;
  307. temp[129:0]<=temp[259:130];
  308. state<=`s3;
  309. end
  310. else
  311. if(count>=24)
  312. begin
  313.  
  314. temp[129:0]<=temp[259:130];
  315.  
  316. state<=`s4;
  317. end
  318. else
  319. begin
  320. valid<=1;
  321.  
  322. data_out<=temp[count+:130];
  323. temp[129:0]<=temp[259:130];
  324. state<=`s3;
  325. end
  326.  
  327. end
  328.  
  329.  
  330.  
  331. else
  332. begin
  333. valid<=1;
  334. data_out<=temp[count+:130];
  335. temp[129:0]<=temp[259:130];
  336. state<=`s3;
  337. end
  338. end
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345. else
  346. //begin
  347.  
  348. if(temp[count+:2]==2'b10)
  349. begin
  350. valid<=1;
  351. data_out<=temp[count+:130];
  352.  
  353. //$display ("%b,%b",temp ,data_out);
  354. temp[129:0]<=temp[259:130];
  355. state <= `s3;
  356. //state <= `s6;
  357.  
  358. end
  359.  
  360. else
  361. begin
  362. error <= 1;
  363. state <= `s1;
  364.  
  365. end
  366.  
  367.  
  368.  
  369. if(count>=130)
  370. begin
  371. count=count-130;
  372. temp[129:0]<=temp[259:130];
  373.  
  374. end
  375.  
  376.  
  377. end
  378.  
  379.  
  380. `s4:
  381. begin
  382. temp<={data_in,temp[129:0]};
  383. if(temp[count+:8]==8'hE1)
  384. begin
  385. SKP<=0;
  386. count=count+32;
  387. SKP_162=1;
  388. state<=`s3;
  389. end
  390. else
  391.  
  392. if(temp[count+:40]==40'hE1AAAAAAAA)
  393. begin
  394. SKP<=0;
  395. count=count+64;
  396. SKP_194=1;
  397. state<=`s3;
  398. end
  399. else
  400. begin
  401. valid<=1;
  402. SKP<=0;
  403. data_out<=temp2;
  404. state<=`s3;
  405. end
  406. if(count>=130)
  407. begin
  408. count=count-130;
  409. temp[129:0]<=temp[259:130];
  410. end
  411. end
  412.  
  413. default:
  414. begin
  415. state<=`s0;
  416. end
  417. endcase
  418. end
  419. end
  420. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement