parameter int COIN_PRICE [4] = {1, 2, 3, 4};parameter int COIN_QUANTITY [4] = {8, 7, 6, 9};parameter int TIMEOUT = 30_000_000; // 30s在quartus里无法识别int怎么办
时间: 2024-03-22 19:36:58 浏览: 19
In Quartus, you can use `logic` instead of `int`. Here is an example:
```
parameter logic[31:0] COIN_PRICE [4] = '{32'h00000001, 32'h00000002, 32'h00000003, 32'h00000004};
parameter logic[31:0] COIN_QUANTITY [4] = '{32'h00000008, 32'h00000007, 32'h00000006, 32'h00000009};
parameter logic[31:0] TIMEOUT = 30000000; // 30s
```
In this example, I defined the `COIN_PRICE` and `COIN_QUANTITY` parameters as arrays of 32-bit `logic` values, and I used hexadecimal notation to represent the values. I also defined `TIMEOUT` as a 32-bit `logic` value.
Keep in mind that you may need to adjust the bit widths of the `logic` values depending on your specific needs.
相关问题
localparam int COIN_PRICE[4] = '{1, 2, 3, 4}; localparam int COIN_QUANTITY[4] = '{8, 7, 6, 9}; localparam int TIMEOUT = 30000000; // 30s能换种写法吗
Sure! Here is another way to write the same code:
```
parameter int COIN_PRICE [4] = {1, 2, 3, 4};
parameter int COIN_QUANTITY [4] = {8, 7, 6, 9};
parameter int TIMEOUT = 30_000_000; // 30s
```
Note that I replaced `localparam` with `parameter` since they are essentially the same thing in this context. Also, I used underscores to make the `TIMEOUT` value more readable.
public class GameAttribute : MonoBehaviour { public int coin; public int multiply = 1; public static GameAttribute instance; public int life = 1; public int initial_life = 1; public Text Text_Coin; public bool soundOn = true; // Use this for initialization void Start () { coin = 0; instance = this; } public void Reset() { life = initial_life; coin = 0; multiply = 1; } // Update is called once per frame void Update () { Text_Coin.text = coin.ToString(); } public void AddCoin() { GameAttribute.instance.coin += multiply; } }
这是一个用于游戏开发的 C# 脚本,它包含了一些游戏属性的定义和操作。其中,coin 表示金币数量,multiply 表示金币的倍数,life 表示生命值,initial_life 表示初始生命值,Text_Coin 是一个用于显示金币数量的 UI 元素,soundOn 表示游戏中是否开启声音。在 Start 函数中,将 coin 初始化为 0,并将 instance 设置为当前实例。Reset 函数用于重置游戏属性。在 Update 函数中,将 Text_Coin 的文本内容设置为当前金币数量。AddCoin 函数用于增加金币数量。