澜起科技2022数字验证笔试
时间2021.8.11
简答题(共11题)
1.[简答题]Please provide Linux shell command(s)to find all files which contains string "Montage" or "montage" in the/home/user.(5 points)
find /home/user -regex ".*[mM]ontage.*"
2.[简答题]What's the Non_Blocking assignment(b <= a)and Blocking assignment(b = a)?(5points)
阻塞赋值与非阻塞赋值区别: b = a : a的值立即赋值给b,b的值是立即更新的,通常用于组合逻辑赋值。 b <= a : 等号右端a的值不会立即赋值给b,在块结束后才完成赋值操作,通常用于时序逻辑赋值。
3.[简答题]Please use verilog write an 8bits asynchronous reset D flip-flop(8bits低有效异步复位的D触发器).(5points)
module f8 ( input clk, input rst_n, input [7:0] data, output reg [7:0] data_r ); always @(posedge clk or negedge rst_n)begin if(!rst_n) data_r <= 1'b0; else data_r <= data; end endmodule
(Ps:知识点 同步复位的触发器面积更小,因为rst可以直接接到D上,异步复位需要触发器具有clr引脚,面积更大,想起这个事了)
4.[简答题]What's the difference between "task" and "function" in Verilog?(5points)
task 可以调用task 和function,function不行。 task 可以延时,执行过程可以消耗时间,function是立即返回的。 function至少要有一个输入变量,task可以没有或者多个输入变量。 task function在sv里面是可以返回的,verilog不行。
// Code your testbench here // or browse Examples module tb; task delay(); #1; return; #5; endtask initial begin delay(); $display("tb now end at %t", $time); $finish; end endmodule // ------------------------- // output: tb now end at 1
5.[简答题]Please use two methods to generate a 100MHz Clk signal in testbench,you can use verilog or system verilog;(5 points)
// -------------- method1--------------- module tb; reg clk; inital begin clk <= 1'b0; #5 clk <= 1'b1; forever clk <= ~clk; end endmodule // -------------- method 2------------- module tb; reg clk; initial clk <= 0; always #(10/2) clk <= ~clk; endmodule // --------------- method 3 ------------ module tb; reg clk; always begin clk <= 1'b0; #5 clk <= 1'b1; #5 end endmodule
6.[简答题]What's the setup time and hold time in Synchronous circuit,and how to resolve if setup time was not met?(10 points)
建立时间:时钟上升/下降沿来临之前,信号需要保持稳定的时间 保持时间:时钟上升/下降沿来临之后,信号需要保持稳定的时间 如何解决setup违例: 插入寄存器 增大时钟周期 降低Tcq 降低Tsetup
7.[简答题]请用下面CMOS组成反相器,与非门,或非门。(10 points)
左边N沟道增强型MOS管,右边P沟道增强型MOS管
与非门:AB = 00 时, NMOS导通,输出0;其他时候两个PMOS至少有一个导通。
对应的或非门就是结构反过来,AB=00的时候,PMOS导通,输出1;其他时刻NMOS至少有一个导通,输出0.
8.[简答题]What's the result of these function print A and print B?(10 points)
class BasePacket; int A=1; int B=2; function void printA; $display ("BasePocket::A is %0d", A); endfunction virtual function void printB; $display ("BasePacket::B is %0d",B); endfunction endclass class My_Pocket extends BasePucket; int A=3; int B=4; function void printA; $display("My_Pocket::A is %0d", A); endfunction virtual function void printB; $display("My_Pocket::B is %0d",B); endfunction endclass BasePacket P1; My_Packet P2; initial begin P1=new(); P2=new(); P1.printB; P1=P2; P1.printA; P1.printB; P2.printA; P2.printB; end /* ------------------- output ------------- 1. BasePacket::B is 2 2. BasePocket::A is 1 3. BasePocket::A is 4 子类对象赋值给父类句柄,父类下的printB是virtual,于是向子类查找函数。父类句柄可以访问子类方法,但是不能访问子类成员变量。 4. BasePacket::B is 3 5. BasePacket::B is 4 ----------------------------------------*/
9.[简答题]Please use any a programming language to locate the largest element in the matrix(矩阵)and print largest value,row and column of this largest value.(10 Points)
Matrix: matrix 3={{0,1,2,3},
{8,7,6,5}
{-5,9,-3,4}
#!/usr/bin/python3 matrix = [[0,1,2,3], [8,7,6,5], [-5,9,-3,4]] max_value = 0 max_row = 0 max_col = 0 for i in range(len(matrix)): for j in range(len(matrix[0])): if(max_value < matrix[i][j]): max_value = matrix[i][j] max_row = i max_col = j print(max_value, max_row, max_col) #输出是9,2,1 行列要不要加1没细说 可以加上
10.[简答题]Please translate below c code to Assembly language(can use pseudo code)(15 Points)
C code: for(int i=0;i<3;i++) {a+=i*3;}
Assembly code:
Line1: mv S0 0 // i Line2: mv S1 1 // 1 Line3: mv S2 3 // 3 Line3: mul S0 S1 S3 // cal i*3 Line4: add S5 S3 S5 // cal a+=i*3 Line5: add S0 S1 S0 // cal i++ Line6: sub S2 S0 S4 // cal 3 - i Line7: bneqz S4 #3 // jump to line3 Initial values in register $0-$5: Reg $1 $2 $3 $4 $5 Value empty empty empty empty a Assembly command example to use; bneqz $1,#5 (branch to line s if $1 !=0) sub $1,$2, $3 ($3=$1-$2) mv $0,0 (store value 0 to $0) add $1, $2, $3 ($3=$1+$2) mul $1, $2, $3 ($3=$1*$2)
11.[简答题]请用verilog或VHDL设计一个模块,完成有符号数除法,被除数为16-bit整数,除数为16-bi整数,输出16-bit商和16-bit余数,所有输入输出都是有符号数(最高位1代表负数,0代表正数).(20 points
没写... 有空补上