fpga出租车计费器

所需积分/C币:49 2012-06-26 15:20:28 59KB PDF
2
收藏 收藏
举报

所有的编程代码里面都有 关于使用fpga编程出租车计费器的详细代码
enc lse if (Istart&speedup==b11&&!pause&&! stop) //4档 distance reg=distance reg+2 S S if (dis>-'d100 begin d<=di, dis<=d0; end 已⊥se begin d= do end if(distance reg)=d300 //超过3KM,则按照1.2元每MM计算 egin if(money reg<=d2000&&d=='d1) pegin money reg=money+ d120; end else if( >d2000&&d--2d1) begin money reg= money+dl80;end//当车费达到20元以上时 每千米加收50%的车费 money =money reg distance=distance reg end endmodul 显示模块稈序 module deceder (scan, seg7, dp, clk20mhz, money in, distance in output[7:0]scan;//数码管地址选择信号 output[6: 0] seg7 //7段显示控制信号 output dp //小数点 input clk20mhz //系统时钟20MHZ input [12: 0 money in //车费 input [12: 0 distance in //路程 reg scan reg 16: 0_seg eg dp reg clklkhz //1KZ分频时钟,用于扫描数码管地址 reg[3: 0. data reg[3: 0 m one, m ten, m hun, m tho //车费钱数的4位十进制表小 reg [3: 0 d one, d ten, d hun, d tho /路稈的4位十进制表示 reg[15: 0]count reg| 15: 0 comb1 mb1 d: reg[15: 0 comb reg[3: 0_comb2 a, comb2 b, comb2 C, comb d reg cnt //1khz分频,用于扫描数码管地址 al ways@(posedge c1 k20mhz) g if(count==1 d10000) begin clklkhz<=clklkhz: count<=d0; end begin count<- count+1: end //将车费转化为4位十进制数 if (comb1<money in) be f (comb1 a== 9&&comb1 b== d9&&comb c==d9) begin comb1 as= b000 comb b= b0000 comb1 c- b0000 combi d<=comb1 d-1 combI<=com end else if(comb1 a='d9&&comb1 b==d9) begin comb b<= b0000 comb1 c-comb1 c-1 comb1<-comb1+1 else if( comb1 a-’d9) comb a= b0000 comb1 b<=comb1 b-1 comb<=comb1+1 d else begin comb1 a=comb1 a+ comb1<-comb1+1 else if (comb1=money in m one=comb1 a: m ten=comb1 b m hun=comb1 c m tho=comb1 d en else if (comb1>money in) comb a=b0000 comb1 b= b0000 comb1 c= b0000 comb d= b0000 comb1<- dO end //将路程转化为4位十进制数 Ifcomb<distance in begin if (comb2 a==d 9&comb b== d9&&comb2 c== d9) begin comb2 a-b0000 comb b<= b0000 comb2 c=b0000 comb2 d<=comb d-1 combo<=combo+1 end else if(comb2 a==' d9&&comb2 b== d 9) comb2 a<-b0000 comb 2 b<-b0000 comb2 c=comb c-1 comb<-comb2+1 end else if(comb2 a=dy) comb a<= b0000 comb2 b<=comb2 b-1 comb2<-comb2+1 comb2 a=comb2 a+l 2 end else if (comb2==distance in d one=comb2 ten=combo b d hun =comb2 d the end else if(comb>distance in) begin comb a= b0000 comb2 b<-=b0000 comb2 c<-b0000 comb2 d= b0000 coIl do end end //数码管动态扫描 always@(posedge clklkhz) cnt-=cnt+1 en always@(cnt) begin case(cnt) b000: begin data=m one; dp=do; scan(=b00000001: end b001: begin data(=m ten; dp(= dO; scan(=b00000010: end b010: begin data<-m hun; dp- dl; scan<-b00000100; end b011: begin data<-m tho; dp<d0; scan<-b00001000: end begin data=d one; dp=do; scan<=b00010000; end b101: begin data-d ten; dp- do; scan<-b00100000: end b110: begin data=d hun; dp=dl; scan<=b01000000; end blll: begin data=d tho; dp= do; scan=b10000000; end default: begin data=bx; dp<= bx; scan<=bx; end endcase //7段译码 lways@(data) egli case(data[3: 0]) 4b000:seg7[6:0]=7b111110 4b0001:seg7[6:0]-7b0110000 4'b0010:seg7[6:0]=7b101101 4b0011:seg7[6:0]=7b1111001 4b0100:seg7|6:0|=7b0110011 4b0101:seg7[6:0]=7b1011011 4b0110:seg7[6:0]=7b101111 4b0111:seg7[6:0]=7b11100 4b1000:seg7[6:0]=7b111l 4b1001:seg7[6:0]-7bl11101 default: seg7[6: 0]=7 b0000000 endcase end enam FPGA犀利。

...展开详情
试读 7P fpga出租车计费器
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
hehanrong1234 总的来说不错,能实现简单功能,程序看得懂
2013-05-30
回复
上传资源赚积分or赚钱
    最新推荐
    fpga出租车计费器 49积分/C币 立即下载
    1/7
    fpga出租车计费器第1页
    fpga出租车计费器第2页

    试读结束, 可继续读1页

    49积分/C币 立即下载 >