一、选择
1、To achieve better leakage( )cells are placed
A.HVT
B.LVT
C.RVT
解:
LVT(Low V threshold):低阈值 这种库的漏电流较大,但是延迟较小
SVT( Standard V threshold):标准阈值 居于两者中间
HVT(HVT = High V threshold):高阈值 这种库的漏电流小,但是延迟大
HVT的cell其阈值电压最大其掺杂浓度越高,因而泄露功耗最小;选A
2、To achieve better delay( )cells are placed in critical path
A.HVT
B.LVT
C.RVT
解:
LVT的cell其阈值电压最小,整体电路中传播速度最快,延迟最小;选B
3、关于“线与”逻辑描述错误的是:()
A.“线与”逻辑是两个输出信号相连可以实现“与”的功能
B.可以用OD门来实现“线与”
C.可以用OC门来实现“线与”
D.“线与”逻辑必须在输出端加一个下拉电阻
解:线与逻辑在硬件上,要用oc门来实现(漏极或者集电极开路),由于不用oc门可能使电流过大,而烧坏逻辑门,同时在输出端口应加一个上拉电阻。(线或则是下拉电阻),选D
二、问答
4、请画出setup/hold关系图,以及removal/recovery 关系图
5、
某主频为400MHz的CPU执行标准测试程序,程序中指令类型、执行数量和平均时钟周期数如下:
指令类型 | 指令执行数量 | 平均时钟周期数 |
整数 | 45000 | 1 |
数据传送 | 75000 | 2 |
浮点 | 8000 | 10 |
分支 | 1500 | 2 |
1).求该计算机的有效CPI(Cycle Per Instruction). MIPS(Million Instruction Per Second)和程序执行时间。
2.)若将CPU中浮点单元加速10倍,CPU整体性能提升比例是多少?
解:做这道题前先搞清楚CPU几个指标的基本概念
CPI :平均每条指令执行的平均时钟周期个数
MIPS(MillionInstructions Per Second) :每秒执行百万条指令数
程序执行时间:执行程序所需的时钟周期数×时钟周期时间
对于问题1有
CPI=(45000*1+75000*2+8000*10+1500*2)/(45000+75000+8000+1500)=2.147
MIPS=1/(T(period)*CPI*1000000) =f/CPI=400/2.147=186.31
程序执行时间=(45000+75000*2+8000*10+1500*2)/400=695
对于问题2有
CPI=(45000*1+75000*2+8000*1+1500*2)/(45000+75000+8000+1500)=1.591
CPI提升约(2.147-1.591)/2.147=25.9%
6、
Python or Perl写出数组的交集
"""以a、b、c为实验对象,求a、b、c都同时拥有的元素"""
a = [0,1,2,3,4]
b = [0,2,6]
c = [-1,2,5,8]
r = list(set(a).intersection(b,c)) # 求多个list的交集:a、b、c同时拥有的元素
print('r -->', r) # 输出r --> [2]
8.在后端中,反相器、PMOS和NMOS谁的面积更大?
nmos的导电沟道中载流子是电子,而pmos导电是空穴,电子的迁移率是空穴迁移率的2.5倍左右,P沟道MOS晶体管的空穴迁移率低,因而在MOS晶体管的几何尺寸和工作电压绝对值相等的情况下,PMOS晶体管的跨导小于N沟道MOS晶体管。相同大小下,PMOS的驱动能力要比NMOS弱,为了驱动力平衡,同等工艺下一般PMOS的面积是NMOS的2~3倍,因此PMOS大于NMOS;而一个反相器由一个PMOS和一个NMOS拼接而成,因而反相器>PMOS>NMOS
三、手撕代码
1、实现四请求的轮询仲裁器
解:轮询仲裁器逻辑特点:
a. 基于次序的优先级:小号输入口的优先级高于大号输入口;
b. 最高优先级是循环的,RR逻辑中,最高优先级并不总是0,而是根据上一次选择的输入口而变化的。上一次选择的输入口的下一个输入口具有最高的优先级。同时最高优先级并不是逐个向后轮换的,而是根据上一次选择的输入口可能产生跳变
module rr_arbiter
(
input clk,
input rst_n,
input [3:0]req,
input req_en,
output[3:0]grant_arb
);
reg [3:0] state_c_arb;
reg [3:0] state_n_arb;
always @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
state_c_arb<=0;
end
else if(req_en)begin
state_c_arb=state_n_arb;
end
else begin
state_c_arb<=0;
end
end
always @(*) begin
if (!rst_n) begin
state_n_arb<=0;
end
else begin
case(state_c_arb)
4'b0001:begin
case(1'b1)
req[1]:state_n_arb<=4'b0010;
req[2]:state_n_arb<=4'b0100;
req[3]:state_n_arb<=4'b1000;
req[0]:state_n_arb<=4'b0001;
default:state_n_arb<=4'b0001;
endcase
end
4'b0010:begin
case(1'b1)
req[2]:state_n_arb<=4'b0100;
req[3]:state_n_arb<=4'b1000;
req[0]:state_n_arb<=4'b0001;
req[1]:state_n_arb<=4'b0010;
default:state_n_arb<=4'b0010;
endcase
end
4'b0100:begin
case(1'b1)
req[3]:state_n_arb<=4'b1000;
req[0]:state_n_arb<=4'b0001;
req[1]:state_n_arb<=4'b0010;
req[2]:state_n_arb<=4'b0100;
default:state_n_arb<=4'b0100;
endcase
end
4'b1000:begin
case(1'b1)
req[0]:state_n_arb<=4'b0001;
req[1]:state_n_arb<=4'b0010;
req[2]:state_n_arb<=4'b0100;
req[3]:state_n_arb<=4'b1000;
default:state_n_arb<=4'b1000;
endcase
end
default:state_n_arb<=4'b0001;
endcase
end
end
assign grant_arb=state_n_arb;
endmodule
2、实现异步握手信号的发送传输
1)top层
module asynchronous_data(
input tclk,
input rclk,
input rstn,
input rrstn,
input [4:0] data_in,
output[4:0]data_out
);
wire req;
wire ack;
reg [4:0]tx_data;
tx tx_module(
.tclk(tclk),
.rstn(rstn),
.ack(rrstn),
.data_in(data_in),
.req(req),
.tx_data(tx_data)
);
rx rx_1(
.rclk(rclk),
.rrstn(rrstn),
.req(req),
.data_in(tx_data),
.ack(ack),
.rx_data(data_out)
);
endmodule
2)发送端
module tx(
input tclk,
input rstn,
input ack,
input [4:0] data_in,
output req,
output reg[4:0]tx_data
);
wire ack_sync;
reg ack_sync1;
reg req_reg;
wire ack_syn_negedge;
always@(posedge tclk or negedge rstn)begin
if(!rstn)begin
tx_data<=0;
end
else if(ack_syn_negedge)begin
tx_data<=data_in;
end
end
reg_module reg_module1(
.clk(tclk),
.sig(ack),
.rstn(rstn),
.sig_reg(ack_sync)
);
always@(posedge tclk or negedge rstn)begin
if(!rstn)begin
ack_sync1<=0;
end
else if(ack_syn_negedge)begin
ack_sync1<=ack_sync;
end
end
assign ack_syn_negedge=!ack_sync&ack_sync1;
always@(posedge tclk or negedge rstn)begin
if(!rstn)begin
req_reg<=0;
end
else if(ack_sync)begin
req_reg<=0;
end
else begin
req_reg<=1;
end
end
assign req= req_reg;
endmodule
3)接收端
module rx(
input rclk,
input rrstn,
input req,
input [4:0] data_in,
output ack,
output reg [4:0]rx_data
);
wire req_sync;
always@(posedge rclk or negedge rrstn)begin
if(!rrstn)begin
rx_data<=0;
end
else if(req_sync)begin
rx_data<=data_in;
end
end
reg_module reg_module1(
.clk(rclk),
.sig(req),
.rstn(rrstn),
.sig_reg(req_sync)
);
assign ack =req_sync;
endmodule
4)、reg_module信号寄存模块
module reg_module(
input clk,
input rstn,
input sig,
output reg sig_reg
);
reg sig_reg0;
always@(posedge clk or negedge rstn)begin
if(!rstn)begin
sig_reg0<=0;
sig_reg<=0;
end
else begin
sig_reg0<=sig;
sig_reg<=sig_reg0;
end
end
endmodule
3、格雷码转换
1)、二进制到格雷码的转换,法则是保留二进制码的最高位作为格雷码的最高位,而次高位格雷码为二进制码的高位与次高位相异或
module gray_trans
#(parameter SIZE=8)
(
input [SIZE-1] bin,
output[SIZE-1] gray,
);
assign gray=bin^{1'b0,bin[SIZE-1:1]};
endmodule
2)、格雷码到二进制的转换,法则是保留格雷码的最高位作为自然二进制码的最高位,而次高位自然二进制码为高位自然二进制码与次高位格雷码相异或
module gray_trans
#(parameter SIZE=8)
(
input [SIZE-1:0] gray,
output[SIZE-1]:0 bin
);
assign bin[SIZE-1]=gray[SIZE-1];
genvar i;
generate
for (i=SIZE-2;i>0;i=i-1)
begin:trans
assign bin[i]=gray[i]^bin[i+1];
end
endgenerate
endmodule