设计一台嵌入式CISC模型计算机。
釆用定长CPU周期、联合控制方式,并运行能完成一定功能的机器语言源程序进行验证,机器语言源程序功能如下:
输入包含10个整数(无符号数)的数组M,输出众数及其出现次数
说明:嵌入式模型计算机内必须设计和使用RAM存储器读写数据,相应地需要设。
计对RAM存储器数据的读写指令,以及对RAM中数组操作必须的寄存器间接寻址方式等。
Rs Rd | 选定的寄存器 |
---|---|
0 0 | R0 |
0 1 | R1 |
1 0 | R2 |
1 1 | R3 |
CLR | LOAD | LDPC | 功能 |
---|---|---|---|
0 | x | x | PC清零 |
1 | 0 | ↑ | DBUS→PC |
1 | 1 | 0 | PC+1 |
1 | 1 | ↑ | 不装入、不计数 |
输入 | 输出 | |
---|---|---|
LED_B | FENOUT[7..0] | OUTBUS[7..0] |
0 | INBUS[7..0] | |
1 | DBUS[7..0] |
CS_I | 功能 |
---|---|
0 | 读 |
1 | 不选择 |
CS_D | RD_D | 功能 |
---|---|---|
↓ | 0 | 写 |
↓ | 1 | 读 |
X | 不选择 |
S2 | S1 | S0 | 功能 |
---|---|---|---|
0 | 0 | 0 | X + Y,修改ZF、CF |
0 | 0 | 1 | X – Y,修改ZF、CF |
0 | 1 | 0 | Y + 1,修改ZF、CF |
0 | 1 | 1 | Y – 1,修改ZF、CF |
1 | 0 | 0 | X*Y |
1 | 0 | 1 | X / Y,修改ZF、CF |
1 | 1 | 1 | Y |
时序产生电路
指令助记符 | 指 | 令 | 格 | 式 | 功能 |
---|---|---|---|---|---|
15-12 | 11-10 | 9-8 | 7-0 | ||
MOV Rd,im | 0001 | XX | Rd | Im | 输入设备 → Rd |
IN Rd | 0010 | XX | Rd | XXXXXX | 输入设备 → Rd |
DEC Rd | 0011 | XX | Rd | XXXXXX | (Rd) - 1 → Rd,锁存ZF、CF |
SUB Rs Rd | 0100 | Rs | Rd | XXXXXX | (Rs) - (Rd) → Rd,锁存ZF、CF |
JB | 0101 | XX | XX | addr | CF=0 则addr → PC |
JZ | 0110 | XX | XX | addr | ZF=0 则addr → PC |
JMP | 0111 | XX | XX | addr | addr → PC |
CMP | 1000 | Rs | Rd | XXXXXX | (Rs) – (Rd),锁存ZF、CF |
ADD | 1001 | Rs | Rd | XXXXXX | (Rs) + (Rd) → Rd,锁存ZF、CF |
OUT | 1010 | Rs | XX | XXXXXX | (Rs) → 输出设备 |
LAD | 1011 | Rs | (Rd) | XXXXXX | ((Rs)) → Rd |
STO | 1100 | Rs | (Rd) | XXXXXX | (Rs) → (Rd) |
INC | 1101 | XX | Rd | XXXXXX | (Rd) + 1 → Rd,锁存ZF、CF |
地址转移逻辑电路是根据微程序流程图中的棱形框部分及多个分支微地址,利用微地址寄存器的异步置“1”端,实现微地址的多路转移。地址转移逻辑电路中异步置“1”信号SE5~SE0表达式的确定与P字段测试时转移微地址的确定密切相关。
为了满足JB和JZ两个跳转指令的设计要求,使用SE4和SE5用作P2,P3测试。
SE5<=NOT(CF AND NOT(ZF) AND P2 AND T4);
SE4<=NOT(ZF AND NOT(CF) AND P3 AND T4);
SE3<=NOT(I15 AND P1 AND T4);
SE2<=NOT(I14 AND P1 AND T4);
SE1<=NOT(I13 AND P1 AND T4);
SE0<=NOT(I12 AND P1 AND T4);
微地址 | LOAD | LDPC | LDAR | LDIR | LDRI | LDPSW | Rs_B | S2 | S1 | S0 | ALU_B | SW_B | LED_B | RD_D | CS_D | RAM_B | CS_I | ADDR_B | P1 | P2 | P3 | 后续微地址 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
取址 | 000000 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 000000 |
MOV | 000001 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 000000 |
IN | 000010 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 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