input clk
input urgency
output [7:0]east_west,south_north
output [5:0]led
reg [7:0]east_west,south_north
reg [5:0]led
initial begin
east_west<=8'b0
south_north<=8'b0
led<=6'b100001end
always @(posedge clk)
begin if(urgency==1) led<=6'b100100
else if(east_west==8'b0 &&south_north==8'b0) begin
east_west<=8'b00101101
south_north<=8'b00101000
led<=6'b100001end
else if(east_west==8'b00000110 &&south_north==8'b1) begin
east_west<=8'b00000101
south_north<=8'b00000101
led<=6'b100010end
else if(east_west==8'b1 &&south_north==8'b1 &&led[5]==1'b1) begin
east_west<=8'b00101000
south_north<=8'b00101101
led<好洞=6'b001100end
else if(east_west==8'b1 &&south_north==8'b00000110) begin
east_west<=8'b00000101
south_north<=8'b00000101
led<=6'b010100end
else if(east_west==8'b1 &&south_north==8'b1 &&led[2]==1'b1) begin
east_west<=8'b00101101
south_north<=8'b00101000
led<=6'b100001end
else if(east_west[3:0]==4'b0000) begin
east_west<=east_west-8'b111
south_north<=south_north-1'b1end
else if(south_north[3:0]==4'b0000) begin
east_west<=east_west-1'友锋枯b1
south_north<=south_north-8'b111end
else begin
east_west<=east_west-1'b1
south_north<=south_north-1'b1
end
end
endmodule
上面是我前一段时间写基州的交通灯控制器设计代码,相应的英文字母对应相应的信号
这就是自己实现一个ID自增的东西。比如的你有个公用类专门用来生成后面的数字,所有迹蔽需要用到的方法都调用这个类的一个方法我们就叫它nextId吧,只要这个方法是线程安全的就可以了。
IdUtils.nextId()
int nextId() {
lock(this){
return this.id++
}
}
应用启动的时候从数据库查询一下id的最大值并设置给工具类的id,让它接简州毁着增长就行了。拦备
具体实现看你用什么语言。
请仔细阅读别人回答的是什么意思。想想oracle的sequence的实现,是不是类似?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)