You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nand2Tetris项目5报错:未找到内置芯片RAM16K求解决

硬件模拟器提示“No such built-in chip used: RAM16K”的排查方案

我用computerAdd.tst脚本测试Computer.hdl时,硬件模拟器报错:No such built-in chip used: RAM16K,但已经把RAM16K.hdl放到对应目录里了,请问可能是什么原因?


可能的原因及解决办法

  • 测试脚本直接引用RAM16K,但你的Computer实现用的是封装后的Memory芯片
    你的computerAdd.tst里,output-list和set命令直接写了RAM16K[0]这类语句,但Computer.hdl里用的是封装好的Memory芯片,硬件模拟器无法直接访问Memory内部的RAM16K。要么修改测试脚本,改成访问Memory对应的端口;要么调整Computer的实现,让RAM16K能被外部直接访问。
  • RAM16K.hdl的路径或文件名有误
    确认文件名是RAM16K.hdl(大小写必须完全匹配,不能写成ram16k.hdl),并且放在硬件模拟器能识别的目录里——要么和Computer.hdl同目录,要么在模拟器设置的芯片库路径下。
  • Memory芯片的实现没正确引用RAM16K
    检查你的Memory.hdl,看里面是否正确实例化了RAM16K。如果Memory内部没用到RAM16K,或者引用路径错误,也会导致模拟器找不到这个芯片。
  • 硬件模拟器缓存干扰
    有时候模拟器会缓存旧的芯片信息,关闭模拟器重新打开,或者清空模拟器的缓存目录,再重新加载测试脚本试试。

相关文件内容

Computer.hdl

CHIP Computer {

    IN reset;

    PARTS:
    // Put your code here:
    ROM32K(address=pc, out=instruction);
    CPU(inM=inM, instruction=instruction, reset=reset, outM=outM, writeM=writeM, addressM=addressM, pc=pc);
    Memory(in=outM, load=writeM, address=addressM, out=inM);
}

computerAdd.tst

load Computer.hdl,
output-file ComputerAdd.out,
compare-to ComputerAdd.cmp,
output-list time%S1.4.1 reset%B2.1.2 ARegister[0]%D1.7.1 DRegister[0]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1;

// Load a program written in the Hack machine language.
// The program adds the two constants 2 and 3 and writes the result in RAM[0]. 
ROM32K load Add.hack,
output;

// First run (at the beginning PC=0)
repeat 6 {
    tick, tock, output;
}

// Reset the PC
set reset 1,
set RAM16K[0] 0,
tick, tock, output;


// Second run, to check that the PC was reset correctly.
set reset 0,

repeat 6 {
    tick, tock, output;
}

computerAdd.cmp

| time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]|
| 0    |  0  |       0 |       0 |   0|       0 |       0 |       0 |
| 1    |  0  |       2 |       0 |   1|       0 |       0 |       0 |
| 2    |  0  |       2 |       2 |   2|       0 |       0 |       0 |
| 3    |  0  |       3 |       2 |   3|       0 |       0 |       0 |
| 4    |  0  |       3 |       5 |   4|       0 |       0 |       0 |
| 5    |  0  |       0 |       5 |   5|       0 |       0 |       0 |
| 6    |  0  |       0 |       5 |   6|       5 |       0 |       0 |
| 7    |  1  |       0 |       5 |   0|       0 |       0 |       0 |
| 8    |  0  |       2 |       5 |   1|       0 |       0 |       0 |
| 9    |  0  |       2 |       2 |   2|       0 |       0 |       0 |
| 10   |  0  |       3 |       2 |   3|       0 |       0 |       0 |
| 11   |  0  |       3 |       5 |   4|       0 |       0 |       0 |
| 12   |  0  |       0 |       5 |   5|       0 |       0 |       0 |
| 13   |  0  |       0 |       5 |   6|       5 |       0 |       0 |

内容的提问来源于stack exchange,提问作者ccy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 09:22:54