Skip to content

Commit

Permalink
大二下/大三上 (PKUanonym#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
Co1lin authored Aug 4, 2021
1 parent 38adec0 commit 63e16ae
Show file tree
Hide file tree
Showing 30 changed files with 735 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions 大三上/计算机网络原理/exam/2021 spring/2021.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 2021 Tips

Overall: 拟合往年题能会大部分。但是毕竟崔勇换 PPT 了,所以风格还是变了一些。比如 TCP 拥塞控制大题变了。还有一些题是对老题的前提条件做一些微小改动。

如果 PPT 都背下来了大概是不难吧。o(╥﹏╥)o

考试大概记得这些:

一、不定项选择题(15×2')

太多了,仅举几例:

- 16 + 5 位的海明码计算。
- 报文交换需要建立连接,因此有……劣势?
- QUIC 协议,重传时序号是新的,因此无二义性。(同一道题还有 QUIC 的其它特性,比如队头阻塞。)

二、填空题

1. 给一张图(两个 Host 、一个 Router;除了 Host A 的 IP 没给,其余的 IP 、 MAC 都给了。)问:

(1)A 的 IP 。

(2)A 给 B 传, A → Router 路径上帧的目的 MAC 地址? 目的 IP 地址?

(3)B 给 A 传,类似(2)。

2. P1 乌托邦协议中有四条假设,写出其中的三条。

P2 引入了 ? 机制。

P3 引入了 ? 机制和 ? 机制。

P6 n 位 bit 的序号,接收窗口大小最大为?

3. 给出 TCP 自动机。按时间顺序写出三次握手🤝、四次挥手过程中,每一步的状态转移(用边的序号填空),以及”条件/动作“对。

三、简答题

1. OSI 七层模型,从底向上的前 4 层是哪些层?简要描述各自的功能。
2. 举出两个端到端设计原则的例子。说明协议分层的目的。
3. RIP 、 OSPF 、 BGP 各自由什么协议承载?承载它们的协议不同导致它们在设计时有很大区别,请简要说明区别。
4. 流媒体传输。从 HTTP 服务器获取到的源数据是什么内容?说两种应对网络抖动的方式。

四、综合题

1. CDMA。问哪个站在发,发的是 0 还是 1。

2. 生成树协议。一张图, R1 、 R2 、 R3 ,一个 Router 两个端口,给出各自的优先级。请生成树,并简要说明过程。

3. 类似老题,比较电路交换和(负载较轻)的分组交换网络的快慢。但是,分组交换中,交换方式改成了直通交换,给出从帧头到目的地址结束的长度为 h 。

4. ![image-20210616171839466](2021.assets/image-20210616171839466.png)

无水平分割和毒性反转的 RIP 协议。(图中边上的权忘了。)

(1)一开始 R1 \~ R4 各路由器到 R5 的信息都是 (metric, nexthop) = (inf, -) 。给一张表,表示 6 轮迭代中各路由器到 R5 的信息的变化。填这张表。

(2)R3 到 R5 的链路断开。从上问中最终稳定的值开始,填后续 10 轮迭代中的信息表。

5. TCP 拥塞控制。

(1)R1 、 R2 共享一个带宽为 1 的瓶颈网络。

![image-20210616172615893](2021.assets/image-20210616172615893.png)

在下图中画出在 MIMD 控制下,从 init 开始,三次增减过程中 R1 、 R2 所占带宽的变化。

![image-20210616172601505](2021.assets/image-20210616172601505.png)

(2)在下图所示的瓶颈带宽变化下, AIAD 、 AIMD 、 MIMD 、 MIAD 四种方式哪个的 goodput 表现最佳?请简要定性分析。

![image-20210623161216485](2021.assets/image-20210623161216485.png)

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions 大三上/软件工程/hw/2021/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2021

[PRJ 1 - NSAOP](https://github.com/Co1lin/NSAOP) (快来学 Go!)

22 changes: 22 additions & 0 deletions 大二下/人工智能导论/exam/2021.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 人工智障导论 2021

1. alpha-beta 剪枝。要求:1)标出每个节点的值;2)表明在何处剪枝;3)画出最终选择的走步。(P.S. 给的树是“不齐”的。)

2. 修正的 A\* 算法。给出求解过程、依次拓展的节点、最终选择的路径。

3. 非线性可分的 SVM 。

样本:正例: $\boldsymbol{x_1}=(0, 0)^T$ ;负例: $\boldsymbol{x_2}=(1, 1)^T$ , $\boldsymbol{x_3}=(-1, -1)^T$ 。

核函数: $K(\boldsymbol{x}, \boldsymbol{y}) = (1 + \boldsymbol{x}^T \boldsymbol{y})^2$ 。

请求解 SVM 参数,并给出 $(0, 1)^T$ 的分类。

4. (1)模拟退火。(温度固定,类似往年题。)

(2)遗传算法。(类似 PPT 例题。)

5. 决策树。用 ID3 算法建立决策树,只需给出根节点及其子节点,表明叶节点的类别。

6. 设计智障神经网络:输入单个数字的图片,输出对应的英文单词(one, two, ...)。要求使用 MLP、CNN、RNN 。画示意图,简要说明。

Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Created by Colin on 2021/06/11.
// Copyright © 2021 Colin. All rights reserved.

module Main (
input wire Clk,
input wire E_Button, Ctrl, Rst,
output reg[6:0] Seg,
output reg Div_out
);
logic[3:0] number = 1;
FourBitsDecoder decoder(.number(number), .digits(Seg));

shortint counter = 0;
int cc = 0;

initial begin
Div_out = 1;
end

always @(posedge Clk) begin
if (Rst) begin
number = 1;
cc = 0;
end
else if (cc == 1_000_000) begin
cc = 0;
if (E_Button == 0) begin
if (Ctrl == 1) begin
// 1 -> 6
if (number < 6) begin
number++;
end
end
else begin
// 6 -> 1
if (number > 1) begin
number--;
end
end
end
end
if (E_Button == 0)
cc++;

if (counter % 2 == 0) begin
Div_out = ~Div_out;
counter = 0;
end
counter++;
end

endmodule

module FourBitsDecoder (
input wire[3:0] number,
output reg[6:0] digits
);

always @(number) begin
case(number)
4'h0: digits = 7'b1111110;
4'h1: digits = 7'b0110000;
4'h2: digits = 7'b1101101;
4'h3: digits = 7'b1111001;
4'h4: digits = 7'b0110011;
4'h5: digits = 7'b1011011;
4'h6: digits = 7'b1011111;
4'h7: digits = 7'b1110000;
4'h8: digits = 7'b1111111;
4'h9: digits = 7'b1110011;
4'ha: digits = 7'b1110111;
4'hb: digits = 7'b0011111;
4'hc: digits = 7'b1001110;
4'hd: digits = 7'b0111101;
4'he: digits = 7'b1001111;
4'hf: digits = 7'b1000111;
default:
digits = 7'b0;
endcase
end

endmodule
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 116 additions & 0 deletions 大二下/数字逻辑实验/hw/verilog/四位加法器.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Created by Colin on 2021/05/06.
// Copyright © 2021 Colin. All rights reserved.

module OneBitHalfAdder (
input x, y,
output s, c
); // 教科书上的半加器基本逻辑
assign s = x ^ y;
assign c = x & y;
endmodule

module OneBitFullAdder(
input c_last, x, y,
output s, c_this,
output p, g
); // 利用两个半加器实现一个全加器;为了超前进位加法器的方便,输出了中间量p,g
logic c1; // 中间量
// Verilog 模块例化:
OneBitHalfAdder ha0(
.x(x), .y(y), .s(p), .c(g)
);
OneBitHalfAdder ha1(
.x(p), .y(c_last), .s(s), .c(c1)
);
assign c_this = g | c1;
endmodule

module SeqFourBitsAdder(
input c_last,
input[3:0] a, b,
output[3:0] s,
output c_this
); // 逐次进位加法器;依照教材上的结构,利用四个全加器实现
logic c[0:2]; // 中间量
// Verilog 模块例化:
OneBitFullAdder fa0(
.c_last(c_last), .x(a[0]), .y(b[0]), .s(s[0]), .c_this(c[0])
);
OneBitFullAdder fa1(
.c_last(c[0]), .x(a[1]), .y(b[1]), .s(s[1]), .c_this(c[1])
);
OneBitFullAdder fa2(
.c_last(c[1]), .x(a[2]), .y(b[2]), .s(s[2]), .c_this(c[2])
);
OneBitFullAdder fa3(
.c_last(c[2]), .x(a[3]), .y(b[3]), .s(s[3]), .c_this(c_this)
);
endmodule

module AdvancedFourBitsAdder(
input c_last,
input[3:0] a, b,
output[3:0] s,
output c_this
); // 逐次进位加法器;依照教材上的结构,利用四个全加器实现
// 中间量
logic p[0:3], g[0:3];
logic c[0:2];
// Verilog 模块例化:
OneBitFullAdder fa0(
.c_last(c_last), .x(a[0]), .y(b[0]), .s(s[0]), .p(p[0]), .g(g[0])
);
OneBitFullAdder fa1(
.c_last(c[0]), .x(a[1]), .y(b[1]), .s(s[1]), .p(p[1]), .g(g[1])
);
OneBitFullAdder fa2(
.c_last(c[1]), .x(a[2]), .y(b[2]), .s(s[2]), .p(p[2]), .g(g[2])
);
OneBitFullAdder fa3(
.c_last(c[2]), .x(a[3]), .y(b[3]), .s(s[3]), .p(p[3]), .g(g[3])
);
// look and carry 结构,用于计算第2、3、4位需要的上一位的进位信息
assign c[0] = g[0] | p[0] & c_last;
assign c[1] = g[1] | p[1] & g[0] | p[1] & p[0] & c_last;
assign c[2] = g[2] | p[2] & g[1] | p[2] & p[1] & g[0] | p[2] & p[1] & p[0] & c_last;
assign c_this = g[3] | p[3] & g[2] | p[3] & p[2] & g[1] | p[3] & p[2] & p[1] & g[0] |
p[3] & p[2] & p[1] & p[0] & c_last;
endmodule

module FourBitsAdder(
input clk,
input switch_mode,
input c_last,
input[3:0] a, b,
output reg[3:0] s,
output reg c_this
); // 顶级模块;统一两种加法器,监听一个微动开关用于切换输出哪个加法器的结果

logic flag = 0; // 标识当前用哪个加法器
logic[3:0] sum[0:1]; // 两个加法器的结果(数组)
logic c_out[0:1]; // 两个加法器输出的进位的结果(数组)

SeqFourBitsAdder adder0(
.c_last(c_last), .a(a), .b(b), .s(sum[0]), .c_this(c_out[0])
); // 逐次进位加法器的模块例化

AdvancedFourBitsAdder adder1(
.c_last(c_last), .a(a), .b(b), .s(sum[1]), .c_this(c_out[1])
); // 超前进位加法器的模块例化

always @(posedge switch_mode) begin
flag <= ~flag; // 当按下微动开关时,标识反转
end

// 当标识、输入量改变时,更新输出值
always @(flag or c_last or a or b) begin
if (flag) begin // 用超前进位加法器时,将4位结果反向输出,用于区分
s <= { sum[flag][0], sum[flag][1], sum[flag][2], sum[flag][3] };
end
else begin // 用逐次进位加法器时,直接输出4位结果
s <= sum[flag];
end
c_this <= c_out[flag]; // 两种加法器进位输出是一样的
end

endmodule
70 changes: 70 additions & 0 deletions 大二下/数字逻辑实验/hw/verilog/日期循环显示.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Created by Colin on 2021/04/30.
// Copyright © 2021 Colin. All rights reserved.

module seqdisplay (
input logic rst,
input logic clk,
output logic [6:0] natural,
output logic [3:0] even,
output logic [3:0] odd
);

int counter;
logic[3:0] date [0:9] = '{ 4'h2, 4'h0, 4'h2, 4'h1, 4'h0, 4'h4, 4'h0, 4'h9, 4'h0, 4'h7 };
logic[3:0] index = 0;

initial begin
even = 0;
odd = 0;
//date = '{ 4'h2, 4'h0, 4'h2, 4'h1, 4'h0, 4'h4, 4'h0, 4'h9, 4'h0, 4'h7 };
natural = digital_number(0);
end

always @ (posedge clk) begin
if (rst) begin
counter <= 32'd4_000_000;
index = 0;
natural <= digital_number(date[0]); // display 0
end
else begin
if (counter == 32'd4_000_000) begin // need update
// display the next number
natural <= digital_number(date[index]);
index = index + 4'b1;
if (index == 10) begin
index = 0;
end
counter <= 0;
end
else begin
counter <= counter + 32'd1;
end
end
end

function logic[6:0] digital_number(
logic[3:0] number
);
case(number)
4'h0: digital_number = 7'b1111110;
4'h1: digital_number = 7'b0110000;
4'h2: digital_number = 7'b1101101;
4'h3: digital_number = 7'b1111001;
4'h4: digital_number = 7'b0110011;
4'h5: digital_number = 7'b1011011;
4'h6: digital_number = 7'b1011111;
4'h7: digital_number = 7'b1110000;
4'h8: digital_number = 7'b1111111;
4'h9: digital_number = 7'b1110011;
4'ha: digital_number = 7'b1110111;
4'hb: digital_number = 7'b0011111;
4'hc: digital_number = 7'b1001110;
4'hd: digital_number = 7'b0111101;
4'he: digital_number = 7'b1001111;
4'hf: digital_number = 7'b1000111;
default:
digital_number = 7'bx;
endcase
endfunction

endmodule
Loading

0 comments on commit 63e16ae

Please sign in to comment.