Introduction to Information Science and Technology

Tutorial 0: Introduction to Logisim

Speaker

沈博宇 Boyu Shen

Slides thanks to Quanyu Chen, Shihan Wang

shenby2024@shanghaitech.edu.cn

Fall 2026 · Nov. 20, 2026

Contents

Contents

  1. Before Start
  2. 安装 Logisim
  3. 上手练习
  4. 设计一个组合逻辑电路
SI100B · EETutorial 0: Introduction to Logisim1 / 38
Before Start

Before Start

  • Logisim 是带图形界面(GUI)的程序,要装在自己电脑上运行。Windows、macOS、Linux 都能用。
  • 我们使用 Logisim 5.0 课程版,请使用助教派发的指定版本
  • Logisim 不会自动保存。开始时先存一次,之后经常保存。
  • 保存的快捷键:Ctrl + S(macOS 上是 Command + S)。
SI100B · EETutorial 0: Introduction to Logisim2 / 38
Before Start

Main Window

Logisim 的窗口分四块

  • Toolbar(工具栏):Poke、Select 和常用元件。
  • Explorer(元件库):电路列表和各类元件。
  • Canvas(画布):搭建电路。
  • Properties(属性面板):查看和修改所选元件的属性。
SI100B · EETutorial 0: Introduction to Logisim3 / 38
Installation

Course Edition Only

请务必安装课程版 Logisim-evolution 5.0.0,下载链接由助教发布。

  • Windows 的 MSI 和 macOS 的 PKG 会把 logisim-evolution 加进 PATH,这会有助于你们使用本地测试脚本。不使用这个版本会对作业体验产生严重影响。
  • 课程版使用的界面菜单名和课件、作业文档均保持一致。
  • 自行安装官方版等非课程版本导致的问题由本人承担,助教不会因此恢复分数。
SI100B · EETutorial 0: Introduction to Logisim4 / 38
Installation

Download and Install

请访问课程网站获得课程定制版安装包:

https://vsplab.cn/courses/si100b/

系统文件名结尾安装
Windowsamd64.msi双击,一路 Next;装完新开终端,命令才生效
Mac(M 芯片)aarch64.pkg双击安装;被拦截时到「隐私与安全性」点仍要打开
Mac(Intel 芯片)x86_64.pkg同上
Debian / Ubuntuamd64.debsudo apt install ./logisim*.deb
Arch Linux.pkg.tar.zstsudo pacman -U logisim*.zst
SI100B · EETutorial 0: Introduction to Logisim5 / 38
Installation

Common Pitfalls

  • 安装包可能被安全软件拦截:360 等电脑管家可能拦截 Logisim 安装,请在安装之前关闭所有的电脑管家类软件。
  • 鸿蒙电脑(HarmonyOS PC)很可能无法运行 Logisim。请用 Windows、macOS 或 Linux 电脑。
  • 提问的方法和礼貌:在提问时,请清晰地描述你的问题,提供足够的信息,包括你的系统和版本,以及足以描述问题的截图。不擅长描述的,可以先让 AI 帮你把问题整理清楚再发。如果你的问题信息过少、难以理解,助教也无法为你提供足够的帮助。
SI100B · EETutorial 0: Introduction to Logisim6 / 38
Getting Started

Task 1: AND Gate

放置 AND 门和引脚

  1. 从工具栏选中 AND,再单击画布。
  2. 用 Input Pin 在左侧放两个输入引脚。
  3. 用 Output Pin 在右侧放一个输出引脚。

左下角可以缩放画布和切换网格。

SI100B · EETutorial 0: Introduction to Logisim7 / 38
Getting Started

Task 1: Wiring

SI100B · EETutorial 0: Introduction to Logisim8 / 38
Getting Started

Task 1: Poke

  1. 选 Poke 工具(手指图标),单击输入引脚,它会在 0 和 1 之间切换。看输出怎么变;在导线上按住,可以看到导线当前的值。
SI100B · EETutorial 0: Introduction to Logisim9 / 38
Getting Started

Exercise 1: Pin

引脚(pin)是电路的输入和输出:输入引脚给电路送信号,输出引脚显示结果。

  • 放置:点工具栏上的 Input Pin 或 Output Pin,在画布上单击。
  • 改类型:选中引脚,在左下角 Properties 里把 Type 改成 Input 或 Output(旧版叫 Output?)。
  • 看形状:方形是输入,圆形是输出;当前的值显示在引脚上。

Data Bits 是位宽,Label 是名字,其余属性保持默认。

SI100B · EETutorial 0: Introduction to Logisim10 / 38
Getting Started

Exercise 1: Keep Appearance Default

不要改元件的 Appearance 属性。 Pin 保持默认的 Classic Logisim。
自动评测按默认外观读取电路。改成 Arrow shapes 之类的外观,电路逻辑正确也可能判错。
SI100B · EETutorial 0: Introduction to Logisim11 / 38
Getting Started

Exercise 1: Appearance Settings

门电路也有外观属性:Facing、Gate Size、Number Of Inputs、Label Font,都保持默认。
AND 门默认朝东(East)、Medium、2 个输入。Negate 1/2 会给输入取反,改变的是电路逻辑,作业里不要动。Pin 的 Appearance 保持 Classic Logisim。改了怎么恢复:选中元件,在 Properties 里改回默认;记不清默认值,就删掉它,从元件库重新放一个。
SI100B · EETutorial 0: Introduction to Logisim12 / 38
Getting Started

Exercise 2: Tunnel

隧道(tunnel)像导线一样把点连起来,但不用画出连线。
关键属性是标签(Label):标签相同的隧道彼此连通。图中三个隧道的标签都是 a,输入 A 的 1 传到了输出 X、Y;如果其中一个改成 b,它就属于另一组。电路中两个点隔得很远时,用隧道代替长导线。
SI100B · EETutorial 0: Introduction to Logisim13 / 38
Getting Started

Exercise 3: Constant

常量(constant)输出 Value 属性指定的值。它只有一个引脚,位宽由 Data Bits 决定。
Data Bits(数据位宽):输出有几位, 位的常量取值范围是 到 。Value(值):以 0x 开头表示十六进制,例如 0xf 是 15。图中是 4 位常量 0xf,接到输出引脚上。
SI100B · EETutorial 0: Introduction to Logisim14 / 38
Getting Started

Exercise 4: Splitter

分线器(splitter)把一个多位信号拆成几组,也能反过来把几组合成一个多位信号。

SI100B · EETutorial 0: Introduction to Logisim15 / 38
Getting Started

Exercise 5: Subcircuits

电路可以像程序调用函数一样使用子电路。
子电路和 main 一起列在 Explorer 里,双击打开。图中的 MyGate 由一个 AND 门和一个 NOT 门组成。 子电路名称不能用 NAND 等关键字,也不能以数字开头。
SI100B · EETutorial 0: Introduction to Logisim16 / 38
Getting Started

Exercise 5: Steps

  1. 打开练习文件:File → Open → ex1.circ。
  2. 在左侧的电路列表里双击 NAND1,打开这个空的子电路。名字末尾有 1,是因为已经有一个叫 NAND 的元件。
  3. 在 NAND1 里搭一个 NAND 电路:左侧 2 个输入引脚,右侧 1 个输出引脚。不要用 Gates 文件夹里内置的 NAND 门,只用选择工具旁边的 AND、OR、NOT。引脚的名字在左下角属性 Label 里改。
  4. 用同样的方法完成其余子电路:NOR、XOR、2-to-1 MUX、4-to-1 MUX。
SI100B · EETutorial 0: Introduction to Logisim17 / 38
Getting Started

Exercise 5: MUX Select Rule

多路选择器(multiplexer,MUX)由选择信号决定哪一路输入接到输出。HW0 的选择规则如下,以 HW0 文档为准:

2-to-1 MUX

Sel输出
0A
1B

4-to-1 MUX

Sel1Sel2输出
00A
10B
01C
11D
SI100B · EETutorial 0: Introduction to Logisim18 / 38
Getting Started

Exercise 5: Rules

做好的子电路可以(也鼓励)拿来搭别的电路:在 Explorer 里单击它,再在画布上单击放置。
不要改子电路的名字,也不要新建子电路。每个电路都在对应名字的子电路里完成,否则自动评分(autograder)找不到你的电路。内置门只能用 AND、OR、NOT。图中把 MyGate 放进了 main。
SI100B · EETutorial 0: Introduction to Logisim19 / 38
Getting Started

Exercise 5: Don’t Touch

作业模板里 Fixed I/O / Don’t touch 框里是固定位置的输入输出,评分时要用;电路搭在下面的 PUT CIRCUITRY HERE 区域。
可以复制它们,但不要以任何方式移动它们。因为移动 IO 导致测试不通过的,助教可以不安排补测。发现自己动过了,重新下载模板文件即可。
SI100B · EETutorial 0: Introduction to Logisim20 / 38
Getting Started

Appendix: Common Gates

ABNAND NOR XOR XNOR
001101
011010
101010
110001

异或(XOR)、同或(XNOR)、与非(NAND)、或非(NOR)。

SI100B · EETutorial 0: Introduction to Logisim21 / 38
Designing a Circuit

Truth Table

组合逻辑(combinational logic)电路的输出只取决于当前的输入。设计这类电路,从真值表(truth table)开始:它列出所有可能的输入组合,以及每种组合对应的输出。

同一个 NAND 门的三种写法:(a) 电路符号 circuit symbol,(b) 真值表 truth table,(c) 布尔表达式 Boolean expression。
SI100B · EETutorial 0: Introduction to Logisim22 / 38
Designing a Circuit

Example: Full Adder

全加器(full adder)把两个 1 位二进制数相加,同时加上低位送来的进位。

  • 输入:加数 、,低位进位
  • 输出:和 (sum),向高位的进位 (carry out)

个输入有 种组合,真值表就有 行。全加器有 3 个输入,真值表有 8 行。

SI100B · EETutorial 0: Introduction to Logisim23 / 38
Designing a Circuit

Full Adder: Truth Table

00000
00101
01001
01110
10001
10110
11010
11111
SI100B · EETutorial 0: Introduction to Logisim24 / 38
Designing a Circuit

Sum of Products

积之和(sum of products,SOP)把逻辑函数写成若干个「与项」(product term)的「或」。每个与项对应一种让输出为 1 的情况。

标准 SOP 里,每个与项都包含全部变量,原变量或取反都可以。这样的与项叫最小项(minterm)。例如三输入函数 的一项 ,表示 、、 时输出为 1。

SI100B · EETutorial 0: Introduction to Logisim25 / 38
Designing a Circuit

SOP from the Truth Table

在全加器的真值表里找输出为 1 的行,每一行写成一个最小项,再把它们或起来:

的行是 001、010、100、111:

\[ S = \overline{A}\,\overline{B}\,C_{in} + \overline{A}\,B\,\overline{C_{in}} + A\,\overline{B}\,\overline{C_{in}} + A\,B\,C_{in} \]

的行是 011、101、110、111:

\[ C_{out} = \overline{A}\,B\,C_{in} + A\,\overline{B}\,C_{in} + A\,B\,\overline{C_{in}} + A\,B\,C_{in} \]

SI100B · EETutorial 0: Introduction to Logisim26 / 38
Designing a Circuit

Boolean Algebra

布尔代数(Boolean algebra)的规则可以化简逻辑函数,用更少的门实现同样的功能。

、、 可以是单个变量,也可以是变量的组合。用代数手工化简不一定能找到最简形式,变量一多既麻烦又容易出错。

SI100B · EETutorial 0: Introduction to Logisim27 / 38
Designing a Circuit

Karnaugh Map

卡诺图(Karnaugh map,K-map)是真值表的图形化表示:把函数的每个最小项填进一个特定的方格里。下图是四变量卡诺图里每一格对应的最小项编号。

Diagram
SI100B · EETutorial 0: Introduction to Logisim28 / 38
Designing a Circuit

Why Gray Code

行列标号按 00、01、11、10 排,而不是二进制从小到大。这种排法叫格雷码(Gray code)。
这样排,几何上相邻的两格在逻辑上也相邻:两个最小项只差一个变量。最左列和最右列、最上行和最下行也相邻(图中箭头)。卡诺图适合四个及以下变量,五个变量也能画,但一般不用。
SI100B · EETutorial 0: Introduction to Logisim29 / 38
Designing a Circuit

Grouping Rules

  • 卡诺图的边缘是相连的:最左列与最右列相邻,最上行与最下行相邻。
  • 把所有输出为 1 的格子圈起来,每个圈包含 个格子(1、2、4、8 …)。
  • 圈尽量大:圈越大,这一项的变量越少。
  • 每个 1 至少被一个圈覆盖,圈可以重叠。
  • 圈的个数尽量少,最后的表达式就尽量简单。
SI100B · EETutorial 0: Introduction to Logisim30 / 38
Designing a Circuit

Grouping Examples

相邻的 1 尽量合并,跨过边缘的 1 也相邻。(a) 两个:、 合成 。(b) 四个角 、、、 跨边相邻,合成 。(c) 八个:、 两行合成 。
SI100B · EETutorial 0: Introduction to Logisim31 / 38
Designing a Circuit

Drawing the Circuit

用化简后的表达式选门:

  • 与门(AND gate)实现与(AND)运算
  • 或门(OR gate)实现或(OR)运算
  • 非门(NOT gate)实现取反(NOT)

以全加器的 为例:

  1. 用三个非门,得到 、、。
  2. 每个与项用一个三输入与门。
  3. 用一个四输入或门把四个与项合起来,输出 。
SI100B · EETutorial 0: Introduction to Logisim32 / 38
Example: Traffic Light Monitor

The Problem

用逻辑门设计一个监视交通信号灯工作状态的电路。每组信号灯由红(R)、黄(A)、绿(G)三盏灯组成。正常工作时,任何时刻有且只有一盏灯亮;出现其他五种点亮状态时,电路发出故障信号,提醒维护人员修理。

SI100B · EETutorial 0: Introduction to Logisim33 / 38
Example: Traffic Light Monitor

Step 0: Abstraction

先做逻辑抽象:

  • 输入:红、黄、绿三盏灯的状态,记为 、、。灯亮为 1,灯灭为 0。
  • 输出:故障信号,记为 。正常工作时 ,发生故障时 。
SI100B · EETutorial 0: Introduction to Logisim34 / 38
Example: Traffic Light Monitor

Steps 1–2: Truth Table and Minterms

Step 1:列出真值表。只有一盏灯亮(001、010、100)时 ,其余五种情况下输出

000001010011100101110111
10010111

Step 2:找 的列,每列写成一个最小项,再或起来:

\[ Z = \overline{R}\,\overline{A}\,\overline{G} + \overline{R}AG + R\overline{A}G + RA\overline{G} + RAG \]

SI100B · EETutorial 0: Introduction to Logisim35 / 38
Example: Traffic Light Monitor

Step 3: Simplify with a K-Map

Diagram

\[ Z = \overline{R}\,\overline{A}\,\overline{G} + RA + RG + AG \]

SI100B · EETutorial 0: Introduction to Logisim36 / 38
Example: Traffic Light Monitor

Step 4: Draw the Circuit

上方三个与门得到 、、;三个非门得到 、、,下方两个与门串接得到 。两个或门分别合并 、,最后一个或门输出 。图中 、、(只亮黄灯),。
SI100B · EETutorial 0: Introduction to Logisim37 / 38
Example: Traffic Light Monitor

Q&A

Questions?

Tutorial 0: Introduction to Logisim