跳到主要内容

東京大学 情報理工学系研究科 コンピュータ科学専攻 2017年2月実施 専門科目 問題4

Author​

Codex

Description​

Let us consider implementing a linear recurrence sequence generator as a sequential circuit. Assume that the clock is an ideal rectangular wave without skew, and that the gate delays are negligible. The clock signal must be used for the Clock inputs of all the flip-flops, and must not be used otherwise.

Let mm and 0<j1<j2<⋯<jm≤2560<j_1<j_2<\cdots<j_m\le256 be positive integers. Given initial values x0,x1,…,x255x_0,x_1,\ldots,x_{255}, the value of xnx_n for n≥256n\ge256 is defined by the recurrence equation:

xn=xn−j1⊕xn−j2⊕⋯⊕xn−jm,x_n=x_{n-j_1}\oplus x_{n-j_2}\oplus\cdots\oplus x_{n-j_m},

where xi∈{0,1}x_i\in\{0,1\}, and ⊕\oplus represents the exclusive-or (XOR) operator.

You can use AND, OR and NOT gates and positive-edge-triggered D flip-flops in your circuit design. Recall that a positive-edge-triggered D flip-flop has two inputs DD and Clock, and one output QQ. At the positive-edge of the Clock signal, the DD input is sampled and stored as the current value of QQ. The value of QQ is kept unchanged until the next positive-edge of the Clock signal. A flip-flop is depicted as the following figure in this problem.

D flip-flop

Answer the following questions.

(1) Design a 2-input XOR circuit with AND, OR and NOT gates.

(2) Consider the following circuit and the Input and Clock signals depicted by the timing diagram below. Assume that the initial values of Q1,Q2Q_1,Q_2 and Q3Q_3 are zeros. Depict the timing diagram for Q1,Q2Q_1,Q_2 and Q3Q_3 along with the Input and Clock signals.

Circuit and timing diagram

(3) Suppose that we have 512 positive-edge-triggered D flip-flops X1,X2,…,X256X_1,X_2,\ldots,X_{256} and C1,C2,…,C256C_1,C_2,\ldots,C_{256}. Assume that initially XiX_i stores the value of x256−ix_{256-i} and CiC_i stores 1 if i∈{j1,j2,…,jm}i\in\{j_1,j_2,\ldots,j_m\} and 0 otherwise, for i=1,2,…,256i=1,2,\ldots,256. Design a circuit so that XiX_i stores the value of x256−i+kx_{256-i+k} at the kkth clock cycle.

(4) Modify the circuit you have answered in question (3) as follows, in order to enable the initialization of the flip-flops. It is enough to show only the difference. Add three inputs WW, X0X_0 and C0C_0. At the positive edge of Clock, the circuit should execute the following. If input signal WW is 0, the value of Xi−1X_{i-1} is moved to XiX_i, and the value of Ci−1C_{i-1} is moved to CiC_i, for i=1,2,…,256i=1,2,\ldots,256. If input signal WW is 1, the circuit works as described in question (3).

题目描述​

考虑用时序电路实现一个线性递推序列生成器。假设时钟为无偏斜的理想矩形波,门延迟可忽略。时钟信号必须用于全部触发器的 Clock 输入,且不得用于其他用途。

设 mm 及 0<j1<j2<⋯<jm≤2560<j_1<j_2<\cdots<j_m\le256 为正整数。给定初值 x0,x1,…,x255x_0,x_1,\ldots,x_{255},对 n≥256n\ge256,由递推式

xn=xn−j1⊕xn−j2⊕⋯⊕xn−jmx_n=x_{n-j_1}\oplus x_{n-j_2}\oplus\cdots\oplus x_{n-j_m}

定义 xnx_n,其中 xi∈{0,1}x_i\in\{0,1\},⊕\oplus 表示异或运算。

设计电路时可使用 AND、OR、NOT 门和上升沿触发的 D 触发器。上升沿触发的 D 触发器有两个输入 DD、Clock,以及一个输出 QQ。在 Clock 信号的上升沿,对 DD 输入采样并存储为 QQ 的当前值。QQ 的值保持不变,直到 Clock 信号的下一个上升沿。本题以如下图形表示触发器。

D flip-flop

回答下列问题。

(1) 用 AND、OR、NOT 门设计一个双输入异或电路。

(2) 考虑下图电路以及时序图所示的 Input 和 Clock 信号。假设 Q1,Q2,Q3Q_1,Q_2,Q_3 初值均为0。画出 Q1,Q2,Q3Q_1,Q_2,Q_3 的时序图,并同时画出 Input 和 Clock 信号。

Circuit and timing diagram

(3) 假设有512个上升沿触发的 D 触发器 X1,X2,…,X256X_1,X_2,\ldots,X_{256} 和 C1,C2,…,C256C_1,C_2,\ldots,C_{256}。对于 i=1,2,…,256i=1,2,\ldots,256,初始时 XiX_i 存储 x256−ix_{256-i};若 i∈{j1,j2,…,jm}i\in\{j_1,j_2,\ldots,j_m\},CiC_i 存储1,否则存储0。设计电路,使 XiX_i 在第 kk 个时钟周期存储 x256−i+kx_{256-i+k}。

(4) 为了能够初始化触发器,按下述要求修改你在 (3) 中设计的电路。只须表示改变的部分。增加三个输入 W,X0,C0W,X_0,C_0。在 Clock 上升沿,电路应执行:若输入信号 W=0W=0,则对 i=1,2,…,256i=1,2,\ldots,256,将 Xi−1X_{i-1} 的值移入 XiX_i,将 Ci−1C_{i-1} 的值移入 CiC_i;若 W=1W=1,电路按 (3) 中所述方式工作。

Kai​

(1)​

For two input bits a,ba,b,

a⊕b=(a∧¬b)∨(¬a∧b).a\oplus b=(a\land\neg b)\lor(\neg a\land b).

Use two NOT gates, two AND gates and one OR gate. The two AND outputs are disjoint: the result is one precisely for (a,b)=(1,0)(a,b)=(1,0) or (0,1)(0,1).

AND, OR and NOT implementation of XOR

(2)​

At every rising edge, all flip-flops sample their inputs simultaneously. If uku_k is the external input at the kk-th edge, then

Q1(k)=uk,Q2(k)=Q1(k−1),Q3(k)=Q2(k−1).\begin{gathered} Q_1(k)=u_k,\\ Q_2(k)=Q_1(k-1),\\ Q_3(k)=Q_2(k-1). \end{gathered}

All three outputs retain their values between rising edges. With the given initial zeros:

Rising edge kk123456
Input uku_k110100
Q1(k)Q_1(k)110100
Q2(k)Q_2(k)011010
Q3(k)Q_3(k)001101

Three-stage shift-register output timing

(3)​

Let XiX_i and CiC_i also denote the current output bits of their flip-flops. Form the combinational feedback

Ti=Ci∧Xi,F=⨁i=1256Ti.T_i=C_i\land X_i,\qquad F=\bigoplus_{i=1}^{256}T_i.

A cascade or tree of 255 two-input XOR circuits from (1) implements this expression; each tap term requires an AND gate. Connect the D inputs as follows:

D(X1)=F,D(Xi)=Xi−1(2≤i≤256),D(Ci)=Ci(1≤i≤256).\begin{aligned} D(X_1)&=F,\\ D(X_i)&=X_{i-1} &&(2\le i\le256),\\ D(C_i)&=C_i &&(1\le i\le256). \end{aligned}

All 512 flip-flops share the unchanged clock. Each CiC_i retains its initialized tap bit.

To prove correctness, suppose that after kk edges, Xi=x256−i+kX_i=x_{256-i+k}. Immediately before edge k+1k+1,

F=⨁r=1mx256−jr+k=x256+k.F=\bigoplus_{r=1}^{m}x_{256-j_r+k}=x_{256+k}.

Thus the next value of X1X_1 is x256+kx_{256+k}, and for i≥2i\ge2 the next value is

Xi−1=x256−(i−1)+k=x256−i+(k+1).X_{i-1}=x_{256-(i-1)+k}=x_{256-i+(k+1)}.

The initialization supplies the induction base k=0k=0.

Recurrence generator and load/run input equations

(4)​

A multiplexer selecting bb when W=0W=0 and aa when W=1W=1 can be implemented as

mux⁡W(a,b)=(W∧a)∨(¬W∧b).\operatorname{mux}_W(a,b)=(W\land a)\lor(\neg W\land b).

Use it at the D inputs:

D(X1)=mux⁡W(F,X0),D(Xi)=Xi−1(2≤i≤256),D(Ci)=mux⁡W(Ci,Ci−1)(1≤i≤256).\begin{aligned} D(X_1)&=\operatorname{mux}_W(F,X_0),\\ D(X_i)&=X_{i-1} &&(2\le i\le256),\\ D(C_i)&=\operatorname{mux}_W(C_i,C_{i-1}) &&(1\le i\le256). \end{aligned}

Here X0,C0X_0,C_0 are external inputs. For i≥2i\ge2, both modes require the same shift of XiX_i, so no selection gate is needed there. The tap registers shift in load mode and retain their values in recurrence mode. The clock continues to connect only to the flip-flop clock pins.

To load prescribed values Xi∗,Ci∗X_i^*,C_i^*, keep W=0W=0 for 256 rising edges and supply X257−k∗,C257−k∗X_{257-k}^*,C_{257-k}^* at edge kk. After the final load edge, all registers contain their prescribed values; set W=1W=1 to begin generation.

Reference​