]> cvs.zerfleddert.de Git - fpga-games/blame - galaxian/src/mc_stars.v
picture getting better again
[fpga-games] / galaxian / src / mc_stars.v
CommitLineData
782690d0
MG
1//===============================================================================\r
2// FPGA MOONCRESTA STARS\r
3//\r
4// Version : 2.00\r
5//\r
6// Copyright(c) 2004 Katsumi Degawa , All rights reserved\r
7//\r
8// Important !\r
9//\r
10// This program is freeware for non-commercial use. \r
11// An author does no guarantee about this program.\r
12// You can use this under your own risk.\r
13//\r
14// 2004- 9-22 \r
15//================================================================================\r
16\r
17\r
18module mc_stars(\r
19\r
20I_CLK_18M,\r
21I_CLK_6M,\r
22I_H_FLIP,\r
23I_V_SYNC,\r
24I_8HF,\r
25I_256HnX,\r
26I_1VF,\r
27I_2V,\r
28I_STARS_ON,\r
29I_STARS_OFFn,\r
30\r
31O_R,\r
32O_G,\r
33O_B,\r
34O_NOISE\r
35\r
36);\r
37\r
38input I_CLK_18M;\r
39input I_CLK_6M;\r
40input I_H_FLIP;\r
41input I_V_SYNC;\r
42input I_8HF;\r
43input I_256HnX;\r
44input I_1VF;\r
45input I_2V;\r
46input I_STARS_ON;\r
47input I_STARS_OFFn;\r
48\r
49output [2:0]O_R;\r
50output [2:0]O_G;\r
51output [1:0]O_B;\r
52output O_NOISE;\r
53\r
54wire W_V_SYNCn = ~I_V_SYNC;\r
55\r
56wire CLK_1C = ~(I_CLK_18M & I_CLK_6M & W_V_SYNCn & I_256HnX);\r
57\r
58reg W_1C_Q1,W_1C_Q2;\r
59always@(posedge CLK_1C or negedge W_V_SYNCn)\r
60begin\r
61 if(W_V_SYNCn==1'b0)begin\r
62 W_1C_Q1 <= 1'b0;\r
63 W_1C_Q2 <= 1'b0;\r
64 end\r
65 else begin\r
66 W_1C_Q1 <= 1'b1;\r
67 W_1C_Q2 <= W_1C_Q1;\r
68 end\r
69end\r
70\r
71wire CLK_1AB = ~(CLK_1C |(~(I_H_FLIP|W_1C_Q2))) ;\r
72\r
73reg [15:0]W_1AB_Q;\r
74reg W_2D_Qn;\r
75wire W_3B = W_2D_Qn^W_1AB_Q[4];\r
76\r
77always@(posedge CLK_1AB or negedge I_STARS_ON)\r
78begin\r
79 if(I_STARS_ON==1'b0)begin\r
80 W_1AB_Q <= 0;\r
81 W_2D_Qn <= 1'b1;\r
82 end\r
83 else begin\r
84 W_1AB_Q <= {W_1AB_Q[14:0],W_3B};\r
85 W_2D_Qn <= ~W_1AB_Q[15];\r
86 end\r
87end\r
88\r
89wire W_2A = ~(& W_1AB_Q[7:0]);\r
90wire W_4P = ~(( I_8HF ^ I_1VF ) & W_2D_Qn & I_STARS_OFFn);\r
91\r
92assign O_R[2] = 1'b0 ; \r
93assign O_R[1] = (W_2A|W_4P) ? 1'b0 : W_1AB_Q[8] ; \r
94assign O_R[0] = (W_2A|W_4P) ? 1'b0 : W_1AB_Q[9] ; \r
95\r
96assign O_G[2] = 1'b0 ; \r
97assign O_G[1] = (W_2A|W_4P) ? 1'b0 : W_1AB_Q[10] ; \r
98assign O_G[0] = (W_2A|W_4P) ? 1'b0 : W_1AB_Q[11] ; \r
99\r
100assign O_B[1] = (W_2A|W_4P) ? 1'b0 : W_1AB_Q[12] ; \r
101assign O_B[0] = (W_2A|W_4P) ? 1'b0 : W_1AB_Q[13] ; \r
102\r
103reg noise;\r
104always@(posedge I_2V) noise <= W_2D_Qn ;\r
105assign O_NOISE = noise ;\r
106\r
107\r
108endmodule
Impressum, Datenschutz