电子线路测试实验
汽车尾灯控制电路 FPGA 代码及仿真答案
华中科技大学电信系
作者:华中科技大学 释梵
声明:
本答案出于学习交流之用,不可用于商业用途。
Windows 7 Sins: The case against Microsoft and proprietary software
The new version of Microsoft's Windows operating system, Windows 7, has the same problem that 
Vista, XP, and all previous versions have had -- it's proprietary software. Users are not permitted to 
share or modify the Windows software, or examine how it works inside.
The fact that Windows 7 is proprietary means that Microsoft asserts legal control over its users 
through a combination of copyrights, contracts, and patents. Microsoft uses this power to abuse 
computer users. At windows7sins.org, the Free Software Foundation lists seven examples of abuse 
committed by Microsoft.
We've mailed a letter to 499 of the 
Fortune 500 companies (we didn't 
think Microsoft would listen), but 
that's just the start...
1. Poisoning education: Today, most children whose 
education involves computers are being taught to use one 
company's product: Microsoft's. Microsoft spends large 
sums on lobbyists and marketing to corrupt educational 
departments. An education using the power of computers 
should be a means to freedom and empowerment, not an 
avenue for one corporation to instill its monopoly.
2. Invading privacy: Microsoft uses software with 
backward names like Windows Genuine Advantage to 
inspect the contents of users' hard drives. The licensing 
agreement users are required to accept before using 
Windows warns that Microsoft claims the right to do this 
without warning.
3. Monopoly behavior: Nearly every computer 
purchased has Windows pre-installed -- but not by 
choice. Microsoft dictates requirements to hardware 
vendors, who will not offer PCs without Windows 
installed on them, despite many people asking for them. 
Even computers available with other operating systems 
like GNU/Linux pre-installed often had Windows on 
them first.
We've also mailed another letter to 
500 non-profit groups around the 
world.
We'd love to send more letters to the 
Windows 7 decision makers that 
people have identified within their own 
organization or community, and with 
your help we can.
If you donate $25 dollars, we'll send 50 
more letters, donate $100 we'll send 
200 letters and so on.
Send us your suggestions for 
organizations who would benefit from 
our letter. 
4. Lock-in: Microsoft regularly attempts to force updates on its users, by removing support for 
older versions of Windows and Office, and by inflating hardware requirements. For many people, 
this means having to throw away working computers just because they don't meet the unnecessary 
requirements for the new Windows versions.
5. Abusing standards: Microsoft has attempted to block free standardization of document formats, 
because standards like OpenDocument Format would threaten the control they have now over users 
via proprietary Word formats. They have engaged in underhanded behavior, including bribing 
officials, in an attempt to stop such efforts.
6. Enforcing Digital Restrictions Management (DRM): With Windows Media Player, Microsoft 
works in collusion with the big media companies to build restrictions on copying and playing media 
into their operating system. For example, at the request of NBC, Microsoft was able to prevent 
Windows users from recording television shows that they have the legal right to record.
7. Threatening user security: Windows has a long history of security vulnerabilities, enabling the 
spread of viruses and allowing remote users to take over people's computers for use in spam-
sending botnets. Because the software is secret, all users are dependent on Microsoft to fix these 
problems -- but Microsoft has its own security interests at heart, not those of its users.
http://en.windows7sins.org/
汽车驾驶室一般有刹车开关、左转弯开关和右转弯开关,司机通过操作这三个开关控制着汽
车尾灯的显示状态,以表明汽车当前的行驶状态。假设汽车尾部左、右两侧各有 3 个指示灯
(用发光二极管模拟),要求设计一个电路能实现如下功能。
1、汽车正常行驶时,尾部两侧的 6 个指示灯全灭灯。
操作方式:stop=0,left=0,right=0,reverse=0
2、刹车时,尾部两侧的灯全亮
操作方式:reverse=0,stop=1,left=0,right=0
3、右转弯时,右侧 3 个指示灯为右顺序循环点亮,频率为 1Hz,左侧灯全灭。
操作方式:reverse=0,stop=0,right=1,left=0
4、左转弯时,左侧 3 个指示灯为左顺序循环点亮,频率为 1Hz,右侧灯全灭。
操作方式:reverse=0,stop=0,right=0,left=1
5、右转弯刹车时,右侧的三个尾灯顺序循环点亮,左侧的灯全亮;左转弯刹车时,左侧的
三个尾部灯顺序循环点亮,右侧的灯全亮。
操作方式:reverse=0,stop=1,right=1,left=0;reverse=0,stop=1,right=0,left=1
6、倒车时,尾部两侧的 6 个指示灯随 CP 时钟脉冲同步闪烁。
操作方式:reverse=1
代码:
/////////reverseLight.v
module reverseLight(leftThree,rightThree,CP); 
output [2:0] leftThree,rightThree; 
input CP; 
reg[2:0] leftThree,rightThree; 
always@(posedge CP) 
begin 
end 
{leftThree,rightThree}<=~{leftThree,rightThree}; 
endmodule 
////////////shutDown.v
module shutDown(leftThree,rightThree,CP); 
output [2:0] leftThree,rightThree; 
input CP; 
reg[2:0] leftThree,rightThree; 
always@(posedge CP) 
begin 
{leftThree,rightThree}<=6'b000000; 
end 
endmodule 
///////////shutLeft.v
module shutLeft(leftThree,rightThree,CP); 
output [2:0] leftThree,rightThree; 
input CP; 
reg[2:0] leftThree,rightThree; 
integer i; 
always@(posedge CP) 
begin 
rightThree[0]<=1'b1; 
rightThree[1]<=1'b1; 
rightThree[2]<=1'b1; 
i=i+1; 
if(i==3) 
i=0; 
if(i==0) 
leftThree<=3'b001; 
else if(i==1) 
else if(i==2) 
leftThree<=3'b010; 
leftThree<=3'b100; 
end 
endmodule 
///////////////shutRight.v
module shutRight(leftThree,rightThree,CP); 
output [2:0] leftThree,rightThree; 
input CP; 
reg[2:0] leftThree,rightThree; 
integer i; 
always@(posedge CP) 
begin 
leftThree[0]<=1'b1; 
leftThree[1]<=1'b1; 
leftThree[2]<=1'b1; 
i=i+1; 
if(i==3) 
i=0; 
if(i==0) 
rightThree<=3'b001; 
else if(i==1) 
else if(i==2) 
rightThree<=3'b010; 
rightThree<=3'b100; 
end 
endmodule
//////////////////tailLight.v
module tailLight(leftThree,rightThree,CP,stop,left,right,reverse,test); 
output [2:0] leftThree,rightThree,test; 
input CP,stop,left,right,reverse; 
wire [2:0] leftThree,rightThree,test; 
wire
reverseLightCP,shutDownCP,shutLeftCP,shutRightCP,subTemplateCP,tailLightCP,turnLeftCP,tur
nOnCP,turnRightCP; 
wire [2:0] leftThree0,rightThree0, 
leftThree6,rightThree6,leftThree5,rightThree5,leftThree2,rightThree2,leftThree4,rightThree4,leftTh
ree1,rightThree1,leftThreex,rightThreex; 
assign test=rightThree5[1]; 
assign leftThree[0]=(reverse&&leftThreex[0])||((~stop)&&(~left)&&(~right)&&leftThree0[0])||
(stop&&left&&(~right)&&leftThree6[0])||(stop&&(~left)&&right&&leftThree5[0])||
((~stop)&&left&&(~right)&&leftThree2[0])||(stop&&(~left)&&(~right)&&leftThree4[0])||
((~stop)&&(~left)&&right&&leftThree1[0]); 
assign leftThree[1]=(reverse&&leftThreex[1])||((~stop)&&(~left)&&(~right)&&leftThree1[1])||
(stop&&left&&(~right)&&leftThree6[1])||(stop&&(~left)&&right&&leftThree5[1])||
((~stop)&&left&&(~right)&&leftThree2[1])||(stop&&(~left)&&(~right)&&leftThree4[1])||
((~stop)&&(~left)&&right&&leftThree1[1]); 
assign leftThree[2]=(reverse&&leftThreex[2])||((~stop)&&(~left)&&(~right)&&leftThree2[2])||
(stop&&left&&(~right)&&leftThree6[2])||(stop&&(~left)&&right&&leftThree5[2])||
((~stop)&&left&&(~right)&&leftThree2[2])||(stop&&(~left)&&(~right)&&leftThree4[2])||
((~stop)&&(~left)&&right&&leftThree1[2]); 
assign rightThree[0]=(reverse&&rightThreex[0])||
((~stop)&&(~left)&&(~right)&&rightThree0[0])||(stop&&left&&(~right)&&rightThree6[0])||
(stop&&(~left)&&right&&rightThree5[0])||((~stop)&&left&&(~right)&&rightThree2[0])||
(stop&&(~left)&&(~right)&&rightThree4[0])||((~stop)&&(~left)&&right&&rightThree1[0]); 
assign rightThree[1]=(reverse&&rightThreex[1])||
((~stop)&&(~left)&&(~right)&&rightThree1[1])||(stop&&left&&(~right)&&rightThree6[1])||
(stop&&(~left)&&right&&rightThree5[1])||((~stop)&&left&&(~right)&&rightThree2[1])||
(stop&&(~left)&&(~right)&&rightThree4[1])||((~stop)&&(~left)&&right&&rightThree1[1]); 
assign rightThree[2]=(reverse&&rightThreex[2])||
((~stop)&&(~left)&&(~right)&&rightThree2[2])||(stop&&left&&(~right)&&rightThree6[2])||
(stop&&(~left)&&right&&rightThree5[2])||((~stop)&&left&&(~right)&&rightThree2[2])||
(stop&&(~left)&&(~right)&&rightThree4[2])||((~stop)&&(~left)&&right&&rightThree1[2]); 
assign reverseLightCP=reverse&&CP; 
reverseLight Ux(leftThreex,rightThreex,reverseLightCP); 
assign shutDownCP=(~stop)&&(~left)&&(~right)&&CP; 
shutDown U0(leftThree0,rightThree0,shutDownCP); 
assign shutLeftCP=stop&&left&&(~right)&&CP; 
shutLeft U6(leftThree6,rightThree6,shutLeftCP); 
assign shutRightCP=stop&&(~left)&&right&&CP; 
shutRight U5(leftThree5,rightThree5,shutRightCP); 
assign turnLeftCP=(~stop)&&left&&(~right)&&CP; 
turnLeft U2(leftThree2,rightThree2,turnLeftCP); 
assign turnOnCP=stop&&(~left)&&(~right)&&CP; 
turnOn U4(leftThree4,rightThree4,turnOnCP); 
assign turnRightCP=(~stop)&&(~left)&&right&&CP; 
turnRight U1(leftThree1,rightThree1,turnRightCP); 
 
endmodule 
////////////turnLeft.v
module turnLeft(leftThree,rightThree,CP); 
output [2:0] leftThree,rightThree; 
input CP; 
reg[2:0] leftThree,rightThree; 
integer i; 
always@(posedge CP) 
begin 
rightThree[0]<=1'b0; 
rightThree[1]<=1'b0; 
rightThree[2]<=1'b0; 
i=i+1; 
if(i==3) 
i=0; 
if(i==0) 
leftThree<=3'b001; 
else if(i==1) 
else if(i==2) 
leftThree<=3'b010; 
leftThree<=3'b100; 
end 
endmodule 
///////////turnRight.v
module turnRight(leftThree,rightThree,CP); 
output [2:0] leftThree,rightThree; 
input CP; 
reg[2:0] leftThree,rightThree; 
integer i; 
always@(posedge CP) 
begin 
leftThree[0]<=1'b0; 
leftThree[1]<=1'b0; 
leftThree[2]<=1'b0; 
i=i+1; 
if(i==3) 
i=0; 
if(i==0) 
rightThree<=3'b001; 
else if(i==1) 
rightThree<=3'b010; 
else if(i==2) 
rightThree<=3'b100; 
end 
 
endmodule
////////////turnOn.v
module turnOn(leftThree,rightThree,CP); 
output [2:0] leftThree,rightThree; 
input CP; 
reg[2:0] leftThree,rightThree; 
always@(posedge CP) 
begin 
{leftThree,rightThree}<=6'b111111; 
end 
endmodule