imengyu / ONICPU

ONICPU is a CPU mod for OxygenNotIncluded that allows you to build programmable code execution control units to implement complex automation functions.
MIT License
9 stars 2 forks source link

代码中关于端口的部分 #2

Closed tastynoob closed 4 months ago

tastynoob commented 4 months ago

我发现这部分代码写得极其混乱,希望得到解答: Inputoutput.write(0)不起作用

tastynoob commented 4 months ago

第二个是期间有很多值拷贝,都可以优化性能

tastynoob commented 4 months ago

我的建议是输入与输出各自使用一个32位uint表示,这意味着最多可有32个输入与32个输出 而不是用一个数组,端口读写使用专门的指令,这里我在psam中定义了in 和 out指令 格式如下 in dst id shift : dst = dst | (input[id] << shift) 其中id必须为整数,当然id这里只能为0 out id src1 shift : output[id] = sarc1 >> shift sync : 将输入输出同步到模块上,这样做可以提高性能,避免频繁的同步数据