[答疑互动] NV笔试2011 asic最后一题7 [. x6 N& S$ e- N 发个笔试题 攒rp asic的笔试题个人觉得有难度啊 最后一题是 将 C code 翻译成成 RTL code ———————————————————— o$ B0 c" n7 i: y4 s7 ? mem[256] = {8 J; X$ \& M/ g. E A" k+ p 0 7 6 6 5 5 5 5 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3. `$ c! i/ L# j0 ]/ o2 b3 Q: C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 B& |- P( e7 p7 D+ C, m% U 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 18 `1 R% F' R% K- ~- x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 U! o+ r1 e/ R1 l: I. B7 ? 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0& A. y3 J% G, |9 y1 K( a9 y 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } int arith_c::bin(int bit, int prob) { int left = 1 + (((high-1)*prob)>>8);& _ K+ r& c) E% V7 I if (bit) {. @8 q' d; D- v; [( x, | low +=left;* L( y. o( Y# I: h( |! f9 s high -=left;0 h7 i9 f& U6 i4 _4 c* g } else { high =left; } int shift = norm[high];$ M0 h( k+ z! b$ F. b high <<=shift; count += shift; return count; } : k8 F9 C" s7 p4 |/ Q" j RTL code$ {. Z3 H, D5 j2 [* r Module arith(); input clk; input reset;//negative async reset input bit; input [7:0] prob; input [31:0] count; Output [31:0] count_new; //this one is the 'return count' in C code % r! N% X: P! c# G5 c7 C# Q reg [31:0] low;//reset to 0;) Q" V& O2 R5 Q- i) p% ~- G+ I reg [7:0] high; //reset to 255; . V$ G. j/ m% Y2 p( T) { //fill your RTL here; //…0 _ l& B% w7 I/ b g) Z ———————————————————— |
|
来自: CharlseLib > 《技术文章》