verilog出租车计价器

出租车计价器由以下几个模块组成:

1、速度产生模块

module velocity(clk,rst,en_1,en_2,F_1HZ,frequency );

2、速度判断模块

module judge_v(rst,frequency,F_1HZ,en_1,en_2,v_h,v_l);

3、路程模块

module kilometer(rst,frequency,start,stop,distance_q,distance_b,distance_s,distance_g);

4、时间模块

module clock(F_1HZ,rst,start,stop,en1,en2,time_h,time_t,time_o,flag_1min,T_goes);

5、价格模块

Module price(clk,rst,start,stop,v_h,v_l,flag_1min,distance_b,distance_s,flag,money_q,money_b,

money_s,money_g);

6、VGA模块

module VGA_disp (clk,rst,time_h,time_t,time_o,money_q,money_b,money_s,money_g,distance_q,

distance_b,distance_s,distance_g,hs, vs,vga_r,vga_g,vga_b);

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
根据提供的引用内容,出租车计价器需要实现以下功能: 1. 显示里程,精确到1公里; 2. 显示金额,精确到1元; 3. 根据行程计算价格,起步价设为5元,基本里程设为3公里,每多行一公里,在起步价上加2元; 4. 等待时计费,每等待一分钟加1元,不足一分钟的按一分钟计算; 5. 用脉冲信号模拟轮胎的转数,设每计一个脉冲汽车前进100米。 以下是一个Verilog出租车计价器的实现,其中包括计价器的各个模块以及顶层模块的代码: ```verilog // 计价器顶层模块 module taxi_meter( input clk, // 时钟信号 input rst, // 复位信号 input start, // 启动信号 input stop, // 停止信号 input wait, // 等待信号 input [15:0] pulse, // 脉冲信号 output reg [15:0] distance, // 里程 output reg [15:0] price // 价格 ); // 计价器状态定义 parameter IDLE = 2'b00; // 空闲状态 parameter RUNNING = 2'b01; // 行驶状态 parameter WAITING = 2'b10; // 等待状态 // 计价器参数定义 parameter START_PRICE = 16'd500; // 起步价,5元 parameter BASE_DISTANCE = 16'd3000; // 基本里程,3公里 parameter PRICE_PER_KM = 16'd200; // 每公里价格,2元 parameter WAITING_PRICE = 16'd100; // 等待价格,1元/分钟 // 计价器状态寄存器 reg [1:0] state = IDLE; // 计价器计数器 reg [15:0] count = 16'd0; // 计价器里程计数器 reg [15:0] distance_count = 16'd0; // 计价器价格计数器 reg [15:0] price_count = START_PRICE; // 计价器等待计数器 reg [15:0] wait_count = 16'd0; // 计价器等待标志 reg waiting = 1'b0; // 计价器启动信号处理 always @(posedge clk) begin if (rst) begin state <= IDLE; count <= 16'd0; distance_count <= 16'd0; price_count <= START_PRICE; wait_count <= 16'd0; waiting <= 1'b0; end else begin case (state) IDLE: begin if (start) begin state <= RUNNING; count <= 16'd0; distance_count <= 16'd0; price_count <= START_PRICE; wait_count <= 16'd0; waiting <= 1'b0; end end RUNNING: begin if (stop) begin state <= IDLE; distance <= distance_count / 1000; price <= price_count; end else if (wait) begin state <= WAITING; waiting <= 1'b1; end else begin count <= count + 1; if (count == 16'd5) begin count <= 16'd0; distance_count <= distance_count + pulse; price_count <= price_count + PRICE_PER_KM; end end end WAITING: begin if (!wait) begin state <= RUNNING; waiting <= 1'b0; end else begin wait_count <= wait_count + 1; if (wait_count == 16'd60) begin wait_count <= 16'd0; price_count <= price_count + WAITING_PRICE; end end end endcase end end endmodule // 脉冲计数器模块 module pulse_counter( input clk, // 时钟信号 input rst, // 复位信号 input pulse, // 脉冲信号 output reg [15:0] count // 脉冲计数器 ); always @(posedge clk) begin if (rst) begin count <= 16'd0; end else begin count <= count + pulse; end end endmodule // 顶层模块 module top( input clk, // 时钟信号 input rst, // 复位信号 input start, // 启动信号 input stop, // 停止信号 input wait, // 等待信号 input [15:0] pulse, // 脉冲信号 output reg [15:0] distance, // 里程 output reg [15:0] price // 价格 ); wire [15:0] pulse_count; pulse_counter pulse_counter_inst( .clk(clk), .rst(rst), .pulse(pulse), .count(pulse_count) ); taxi_meter taxi_meter_inst( .clk(clk), .rst(rst), .start(start), .stop(stop), .wait(wait), .pulse(pulse_count), .distance(distance), .price(price) ); endmodule ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

芯作者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值