分享

NV笔试2011 asic最后一题

 CharlseLib 2011-10-12

[答疑互动] NV笔试2011 asic最后一题

本帖最后由 aaron_09 于 2011-9-25 21:00 编辑 ( J6 ~" ?5 G& V
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
————————————————————

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约