Logisim实验
1. Go back to the \
2. Change the \
rotated to accomodate wires as you need them. This will definately be useful when you do your project.
3. Place your Fib8 subcircuit into the main subcircuit. 4. Select the Fib8 subcircuit you just placed into main.
5. Connect output pins to the Fib8 subcircuit. Output pins are ordered top to bottom, left to right.
Thus, if you followed the schematic above, then the top pin on the right side outputs the value one of the top register, the middle pin is the output of adder, and the bottom pin is the output of the bottom register.
6. Right click on your Fib8 subcircuit, and select \ONLY method to preserving state. Double-clicking on the circuit at the circuit browser at left makes logisim think you want to edit the circuit instead of just checking what state the circuit has.
Note: You can use Simulate->Go In To State->*Circuit Name*, but that allows you go into the first circuit of that type. If you placed two Fib8 circuits down, it only takes you to the first Fib8 circuit to put down.
7. Initialize the register values to 1. You can do this by first, click on the register value with the poke
tool. Then, type the hex value in.
8. To return to the main circuit while preserving state, go to Simulate->Go Out To State->main.
Alternatively, you can hold Control key and press Up-Arrow.
9. Now start running your circuit by going to Simulate->Ticks Enabled. Your circuit should now be
outputting the fibonachi numbers in binary form.
10. If you want to run your circuit faster, you can change the tick frequency in Simulate->Tick
Frequency.
3 ALU
实现hw5对应的8位ALU,可以不实现溢出。注意参考附录B中相关章节。要求实现加、减、或,判等 四种操作。
说明:为了支持第四部分的内容,仅仅要求实现add、sub、or,要求能够支持equal信号输出
4 CPU(2次实验课,伯克利prj3)
为了考虑大家体力有限,我们不实现http://inst.eecs.berkeley.edu/~cs61c/sp11/projects/04/)
计算机组成与设计
模板版本:2.1
32位的CPU。(也可以参考
11 / 22
Logisim实验
实现prj3对应的8位CPU。这是体力活和脑力活的结合体,体会一下一个能够自动绘制电路软件的必要性吧:)
4.1 指令设计
一共支持7个指令:lw,sw,add,sub,ori,beq,jmp 留给寄存器的位数只有1位,所以只有2个通用寄存器 不支持移位操作。
I类型指令中立即数位数为3,J类型指令地址5位 具体指令编码如下
Opcode Rs Rt 指令 7 Add Sub 指令 Ori Lw Sw Beq 指令 Jmp
000 000 Opcode 001 010 011 100 Opcode 101 6 5 4 Rs 3 Rt Rd 2 Func 1 00 01 0 IMM/Addr Target Addr 4.2 设计2个8位寄存器的寄存器堆
因为是2个寄存器(如果是4个寄存器,就需要2个bit的寄存器位,这样指令位很难控制在8位以下,难度会大大增大,所以还是2个寄存器这么奇葩的好),所以这个寄存器堆的端口号都是1位,2个一位的读端口,1个1位的写端口,1位的写使能信号。另外,因为是状态单元,需要一个时钟。 输出是两个,2个8位的读数据情况。
计算机组成与设计
模板版本:2.1 12 / 22
Logisim实验
上图的dq触发器是直接使用的自带的子电路。 看一看,能理解这个电路吗。
这个电路,读端口1对应读数据1,读端口2对应读数据2;写端口和写数据共同决定改变哪个寄存器的值。下面做一个实验:
上面这个例子是使用刚才制作的寄存器堆得测试电路,可以按ctrl+T来模拟时钟,可以看到,数据可以写入对应的端口,并显示在读数据端口。
至此,一个包含2个8位寄存器的寄存器堆就完成了。
计算机组成与设计
模板版本:2.1
13 / 22
Logisim实验
4.3 支持add、sub、or的ALU(加法器可以先用现成的组件,
而不自己实现;当然自己实现是最好的)
上图用一种很直观也很粗暴的方法实现了ALU。
既然能实现3个功能:add、sub、or,那么就用加法器、减法器、或门电路直接运算,然后用一个选择器选择,因为是3选1,所以信号是2位。(选择器也是选择的系统自带的电路)
特殊一点的是equal信号,做减法的时候,equal信号为1表示两个操作数相等,0表示不相等。方法是吧输出的8位剥除来或,然后求非。(想想是不是这样,做减法的时候如果相等,equal就等于1?) 实验看看效果:
4.4 扩展器(3位的立即数扩展到8位),两种扩展方式
这里需要实现符号扩展和0扩展,看下图:
计算机组成与设计
模板版本:2.1 14 / 22
Logisim实验
看看上面两个图的实验,是不是0的时候0扩展,1的时候符号扩展?
4.5 PC的两种特殊扩展方式
这里先实现beq的扩展,jump暂时不考虑
分析一下beq扩展的需要,我们会发现能够得到一个非常奇葩的结论。
计算机组成与设计
模板版本:2.1 15 / 22