题解 | 游戏机计费程序

游戏机计费程序

https://www.nowcoder.com/practice/50188fb7e23b4eee86f8c463c8284f5e

`timescale 1ns/1ns

module game_count
    (
		input rst_n, //异位复位信号,低电平有效
        input clk, 	//时钟信号
        input [9:0]money,
        input set,
		input boost,
		output reg[9:0]remain,
		output reg yellow,
		output reg red
    );
//remain信号
always@(posedge clk or negedge rst_n)
if(!rst_n)
  remain <= 0;
else if(set)
  remain <= remain + money;
else if(boost && (remain > 10'd1))
  remain <= remain-10'd2;
else if(~boost && (remain > 10'd0))
  remain <= remain-1'b1;
else
  remain <= remain;

always@(posedge clk or negedge rst_n)
if(!rst_n) begin
  yellow <= 0;
  red <= 0;
end
else begin
  yellow <=((remain >0) && (remain < 10'd10))? 1 : 0;
  red <= (((boost && (remain < 10'd2))||(~boost && (remain <1))))?1:0;
end

  
endmodule

这道题我其实做的还有点迷茫。首先就是set、boost信号是按了按钮一直保持1还是只保持一个周期。

好像是一个周期(至少set应该是这样的)。

全部评论

相关推荐

昨天 18:44
已编辑
中山职业技术学院 Java
投递文远知行等公司8个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
06-15 02:05
已编辑
南昌航空大学 数据分析师
Eason三木:你如果想干技术岗,那几个发公众号合唱比赛的经历就去掉,优秀团员去掉,求职没用。然后CET4这种不是奖项,是技能,放到下面的专业技能里或者单独列一个英语能力。 另外好好改改你的排版,首行缩进完全没有必要,行间距好好调调,别让字和标题背景黏在一起,你下面说能做高质量PPT你得展现出来啊,你这简历排版我用PPT做的都能比你做的好。 然后自我评价,你如果要干数据工程师,抗压能力强最起码得有吧。
简历中的项目经历要怎么写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务