CPU.hdl - 需要解释理解代码

问题描述 投票:-4回答:2

我有这样的CPU.hdl代码。

CHIP CPU {

IN  inM[16],         // M value input  (M = contents of RAM[A])
    instruction[16], // Instruction for execution
    reset;           // Signals whether to re-start the current
                     // program (reset=1) or continue executing
                     // the current program (reset=0).

OUT outM[16],        // M value output
    writeM,          // Write into M? 
    addressM[15],    // Address in data memory (of M)
    pc[15];          // address of next instruction

PARTS:
Not(in=instruction[15], out=isAcmd);
Not(in=isAcmd, out=isCcmd);

// Create the ALU chip.
// First input to ALU is always D; 2nd is A or M based on inst[12]
Mux16(a=outA, b=inM, out=outAM, sel=instruction[12]);
ALU(x=outD, y=outAM, zx=instruction[11], nx=instruction[10], zy=instruction[9], ny=instruction[8], f=instruction[7], no=instruction[6], out=outM, out=outALU, out=inD, zr=zr, ng=ng);
//also need logic as to whether to write to M ... it's part of the instruction
And(a=isCcmd, b=instruction[3], out=writeM);
 .
 .
 .
}

我想了解CPU.hdl。我不明白的部件后,2号线。他们是怎么做到?

hdl
2个回答
0
投票

PARTS实例你CPU内部新组件。

例如。有一个NOT组件,其命名in端口连接到信号instruction[15]


0
投票

从书:

为了弄清楚这16位字的意思是,如果可以分为田野“我XX一个CCCCCC DDD JJJ”。 i比特码的指令类型,这是0的A-指令,和1为C-指令。

这两条线在问题被分割指令[15]到2个引脚。也许分裂他们与一个分路器可能会更有意义给你:

DMux(in=true, sel=instruction[15], a=aInstruction, b=cInstruction);

画出真值表两种方式,它应该是有意义的你。

© www.soinside.com 2019 - 2024. All rights reserved.