systemVerilog快速入门PPT.ppt_第1页
systemVerilog快速入门PPT.ppt_第2页
systemVerilog快速入门PPT.ppt_第3页
systemVerilog快速入门PPT.ppt_第4页
systemVerilog快速入门PPT.ppt_第5页
已阅读5页,还剩119页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

SystemVerilog 讲座,第一讲: SystemVerilog 基本知识,夏宇闻 神州龙芯集成电路设计公司 2008,Verilog HDL的发展历史,1984: Gateway Design Automation 推出 Verilog 初版 1989: Gateway 被Cadence Design Systems 公司收购 1990: Cadence 向业界公开 Verilog HDL 标准 1993: OVI 提升 the Verilog 标准,但没有被普遍接受 1995: IEEE 推出 Verilog HDL (IEEE 1364-1995)标准 2001: IEEE 推出 Verilog IEEE Std1364-2001 标准 2002: IEEE 推出 Verilog IEEE Std1364.1-2002 标准 2002: Accellera 对 SystemVerilog 3.0 进行标准化 Accellera 是OVI & VHDL International (VI)合并后的国际标准化组织 2003: Accellera 标准化后的SystemVerilog 3.1 2006: IEEE 推出带SystemVerilog 扩展的Verilog新标准,为什么称 SystemVerilog 3.x?,SystemVerilog 是 对Verilog 革命性的扩展 Verilog 1.0 - IEEE 1364-1995 “Verilog-1995” 标准 第一代 IEEE Verilog 标准 Verilog 2.0 - IEEE 1364-2001 “Verilog-2001” 标准 第二代 IEEE Verilog 标准 显著提升了 Verilog-1995 标准的性能 SystemVerilog 3.x - 国际标准化组织对Verilog-2001的扩展 第三代 Verilog 标准 DAC-2002 - SystemVerilog 3.0 DAC-2003 - SystemVerilog 3.1,SystemVerilog 是Verilog-2001扩展后的超集,assertions mailboxes test program blocks semaphores clocking domains constrained random values process control direct C function calls,- SystemVerilog -,- from C / C+ - classes dynamic arrays inheritance associative arrays strings references,SystemVerilog 是Verilog-2001扩展后的超集,interfaces dynamic processes nested hierarchy 2-state modeling byte unrestricted ports packed arrays implicit port connections array assignments enhanced literals enhanced event control time values & units unique/priority case/if logic-specific processes root name space alias const &= |= = %= -,- from C / C+- int globals break shortint enum continue longint typedef return Byte structures do-while Shortreal unions + - += -= *= /= void casting = = = alias const &= |= = %=,- SystemVerilog -,SystemVerilog 是Verilog-2001扩展后的超集,ANSI C style ports standard file I/O (* attributes *) generate $value$plusargs configurations localparam ifndef elsif line memory part selects constant functions * variable part select,- from C / C+- multi dimensional arrays signed types Automatic * (power operator),- Verilog -2001 -,SystemVerilog 是Verilog-2001扩展后的超集,modules $finish $fopen $fclose initial wire reg parameters $display $write disable integer real function/task $monitor events time always define ifdef else wait # packed arrays assign include timescale forkjoin 2D memory,- from C / C+- beginend + = * / % while for forever if-else repeat,- Verilog -1995 -,SystemVerilog 提高设计效率,提高了设计效率,描述同样的功能,其代码可缩短2到5倍 - 代码短发生意外错误的概率减小了,但仍然可以综合, 新的语句构造可以解决RTL仿真和综合后仿真的不匹配; - 小组成员间更容易理解和交流; 缩短了学习周期。,结构化的和用户定义的数据类型,与封装好的接口通信,.* 蕴涵的端口实例引用,极大地提高了仿真速度 仅一种语言就能解决设计和测试问题,设计和验证语言的统一提高了设计效率,学习周期 很短,设计和验证人员都乐意采用: - 可自动生成高级的受约束-随机测试信号语句,大大降低了设计和验证的复杂度; - 完整的统一的断言技术改善了设计小组和验证小组之间的交流。,使得我们有可能使用更高速度的仿真工具,加速了设计的完成,SyestemVerilog的全面验证和设计,统一的断言扩展了验证方法的效率 -基于断言的验证 -形式化特征的验证 -线路板上的加速验证,SystemVerilog 设计语言,Verilog-2001 的事件调度,当前的时隙,#0 阻塞赋值,计算非阻塞表达式 的RHS,连续赋值,$display命令,更新非阻塞表达式的LHS,阻塞赋值,更新原语的输入和的输出,,$monitor系统命令,$strobe 系统命令,语句激活,语句暂停活动,非阻塞赋值,监视,来自上一个时隙,Verilog-2001时隙被分成4等级区域,新的名称将”延迟”事件区域,去下一个时隙,编写代码的八项原则,一般情况下,编写代码时如能按照以下8条原则就可以避免 90%-100%由Verilog代码引起的冒险竞争现象: 1)时序逻辑-使用非阻塞赋值 2)锁存器-使用非阻塞赋值 3)用always块生成的组合逻辑-用阻塞赋值 4)在同一个always块中既有时序逻辑又有组合逻辑- 用非阻塞赋值 5)在同一个always块中不要既用阻塞赋值又用非阻塞赋值 6)不要在一个以上的always块中对同一个变量赋值 7)用$strobe显示用非阻塞赋值指定的变量值 8)不要用 0 过程性赋值 以上8条原则与Verilog-1995 完全一致,仍旧适用于SystemVerilog,SystemVerilog的基本数据类型,SystemVerilog 可以定义: 4 态数据类型: 0,1,X,Z 2 态数据类型: 0,1,未初始化的变量 = X 未初始化的线网 = Z 与Verilog-2001相同,未初始化的变量 = 0 未初始化的线网 *= 0 SystemVerilog新添加的,reg r; / 4态,Verilog-2001(位宽可变)数据类型 integer i; /4态,Verilog-2001(32位)有符号数据类型 logic w; /4态,(位宽可变) 0,1,x,或者 z bit b; /2态,(位宽可变) 1位 0 或 1 byte b8; /2态,(8位)有符号整型数 shortint s; /2态,(16位)有符号整型数 int i; /2态,(32位)有符号整型数 longint l; /2态,(64位)有符号整型数 注:* -bit 类型既可以用于变量也可以用于线网。另外还加入了其他一些数据类型,SystemVerilog 新添加的数据类型,reg 15:0 r16; logic 15:0 w16; bit 15:0 b16;,reg, logic和 bit数据类型位宽可以改变,几乎通用的数据类型logic (等价于原来的 reg类型),logic 类型类似于VHDL中的std_ulogic类型 - 对应的具体元件待定 - 只允许使用一个驱动源,或者来自于一个或者多个过程块的过程赋值,对同一变量既进行连续赋值又进行过程赋值是非法的,不允许的。,- 在SystemVerilog中:logic和reg类型是一致的(类似于Verilog中wire和tri类型是一致的),wire数据类型仍旧有用因为: - 多驱动源总线: 如多路总线交换器(bus crossbars & onehot muxes) - 双向总线(两个驱动源),logic 是4态数据类型的变量,bit 相当于2态数据类型的变量或线网,用户定义的类型-typedef,允许生成用户定义的或者容易改变的类型定义: 好的命名规则用“_t”做后缀 typedef existing_type mytype_t;,ifdef STATE2 typedef bit bit_t; /2 state else typedef logic bit_t; /4 state endif,defines.vh,设计策略:用各种typedefs,只要用typedef 就可以很容易地在4态和2态逻辑仿真之间切换以加快仿真速度,verilog_cmd define.vh tb.v dff.v,verilog_cmd define.vh tb.v dff.v +define+STATE2,确省,为4态逻辑值仿真,只用 2态逻辑值,仿真速度快,已确定的和待确定的类型,四态和两态设计策略用待确定类型是最容易的。,功能相当于VHDL中的std_ulogic 类型,很有效率,与VHDL中的std_logic类型没有功能可比较的类型,ifdef STATE2 typedef bit bit_t /2-态 else typedef logic bit_t;/4-态 endif,define.vh,ifdef STATE2 typedef bit bit_t /2-态 typedef ? tri_t /2-态 else typedef reg bit_t;/4-态 typedef wire tri_t;/4-态 endif,define.vh,无多驱动器的2态类型,- 也许下一个版本的SystemVerilog能得到修正,没有容易的std_ulogic 和std_logic 之间切换的等价语句,Verilog-2001 数据类型 (模块内部),模块的输入必须是线网类型的信号,module A(out,in); output out; input in; reg out; wire in; always (in) out = in; endmodule,module B(out,in); output out; input in; wire out; wire in; assign out = in; endmodule,用reg类型的输出 (过程赋值语句的LHS必须用变量类型),输出是线网类型的 (用连续赋值驱动的变量类型),Verilog-2001 数据类型 (模块外部),信号由源驱动的必须定义为线网类型,module A(out,in); 黑箱 输出 输入,module B(out,in); 黑箱 输出 输入,实例的输入往往由测试模块的变量驱动,a2b,输出信号必须定义为线网类型,module test; reg t_in; wire a2b; wire t_out; A u1(.out(a2b), .in(t_in); B u2(.out(t_out), .in(a2b); initial t_in =1;,t_out,Verilog-2001 数据类型 (模块内部、外部和测试放在一起),线网声明语句,过程赋值语句的LHS必须用变量类型,通常是reg类型,这些都声明为线网类型,module test; reg t_in; wire a2b; wire t_out; A u1(.out(a2b), .in(t_in); B u2(.out(t_out), .in(a2b); initial t_in =1; . endmodule,a2b,t_out,变量 声明语句,SystemVerilog对端口定义没有限制,SystemVerilog允许过程或者连续赋值给变量赋值,线网声明语句,logic 类型可以替代所有其他类型,包括reg类型,这些都声明为线网类型,module test; logic t_in; logic a2b; logic t_out; A u1(.out(a2b), .in(t_in); B u2(.out(t_out), .in(a2b); initial t_in =1; . endmodule,a2b,t_out,只有一个驱动源的变量都可以声明为logic类型,SystemVerilog表示数字的语法有改进,module fsm_sv1b_3; always * begin next = x; case (stat側 endmodule,类似VHDL的(Other=) 语句进行“填满”的操作,x 等于Verilog-2001的bx,z 等于Verilog-2001的bz,1 等于赋-1的值(即-1的2进制补码,也就是所有位赋为1),0 等于赋给0的值(也就是所有位赋为0),特定逻辑过程,SystemVerilog 有三个新的特定的逻辑过程来表达设计者的意图:,always_comb always_latch always_ff,always_comb begin tmp1= a end,always_latch if (en) q = d;,always_ff (posedge clk, negedge rst_n) if (!rst_n) q = 0 ; else q = d;,允许仿真工具进行某些 语法功能检查(linting functionality),always_comb 特定逻辑过程,always_comb -允许仿真工具检查正确的组合逻辑代码风格,正确的,module ao1( output bit_t y, input bit_t a, b, c, d ); bit_t tmp1, tmp2; always_comb begin tmp1 = a end endmodule,module ao1( output bit_t y, input bit_t en, d ); always_comb if (en) q = 0 ; endmodule,错误: 想生成组合逻辑 但产生了锁存器,可能发生的 错误信息:,always_latch 特定逻辑过程,always_latch -允许仿真工具检查正确的锁存器逻辑代码风格,正确的,module lat1( output bit_t q, input bit_t en, d ); always_latch if (en) q = d; endmodule,module lat1( output bit_t q, input bit_t en, d ); always_latch if (en) q = d; else q = q; endmodule,错误: 组合逻辑反馈环 路不能生成锁存器,可能发生的 错误信息:,always_ff 特定逻辑过程,always_ff -允许仿真工具检查正确的寄存器逻辑代码风格,正确的,module dff1( output bit_t q, input bit_t d, clk, rst_n ); always_ff (posedge clk, negedge rst_n) if (!rst_n) q = 0; else q = d ; endmodule,module dff1 ( output bit_t q, input bit_t d, clk, rst_n ); always_ff (clk, rst_n) if (!rst_n) q = 0; else q = q; endmodule,错误: 非法敏感列表 不能生成触发器,可能发生的 错误信息:,always * 与 always_comb 的差别,它们之间的真正有什么差别,IEEE VSG和Accellera SystemVerilog 委员会还在辩论中,尚未最后确认,module fsm_svlb_3 . always * begin next = x; case (state) end endmodule,always_comb 对于函数内容的变化是敏感的,存在一些差别,always_comb 可用来检查非法锁存器,always_comb 在0时刻结束时自动触发一次,* 可以写在always 块内,module fsm_svlb_3 . always_comb begin next = x; case (state) end endmodule,Void 函数,没有返回值的函数 不必从Verilog 表达式中被调用 -Void 函数可以象Verilog 任务一样,独立地调用 与Verilog 任务不同, Void 函数 - 不能等待 - 不能包括延迟 - 不能包括事件触发 - 被always_comb 搜寻到的信号自动加入敏感列表,always_comb 与 Void 函数,module comb1( output bit_t 2:1 y, input bit_t a, b, c) ; always_comb orf1(a); function void orf1; input a; y1 = a | b | C; endfunction always_comb ort1(a); task ort1; input a; y2 = a | b | C; endtask endmodule,always * orf1(a) ;,等价于: always (a),等价于: always (a,b,c),void 函数的行为 类似于0延迟的任务,等价于: always (a),Verilog 任务,b 和 c 是隐含的输入,always * ort1(a) ;,等价于: always (a),b 和 c 是隐含的输入,-或者-,-或者-,只有always_comb 对函数的内容的变化是敏感的,always_ff 用于双数据率(DDR)时序逻辑?,有可能提高未来综合工具的性能?,无正跳变沿触发时钟信号(clk) 无负跳变沿触发时钟信号(clk),目前对综合器来说 该语法是非法的,module ddrff ( output bit_t q, input bit_t d, clk, rst_n ); always_ff (clk, negedge rst_n) if (! rst_n) q = 0; else q = d; endmodule,去掉正跳变沿是否可以 允许用正负两个沿触发?,always_ff 显示 设计者的意图,这能综合成ASIC厂商库中的双数据率(DDR)时序逻辑吗?,设计意图unique/priority,有优先的还是没有优先的? 来回考虑 综合时常容易产生的错误!,full_case parallel_case,看似“完全一样”的语句 对应的实体是不同 的,这些指令告诉综合编译器,编 写的设计代码有些地方和仿真 器理解的有些不同,综合前与综合后 的仿真可能存在 一些差别,unique 和 priority 这两个新添的指令告诉仿真器和综合器同一个信息,unique case priority case unique if priority if,使得仿真器、综合器和 形式化验证工具的行为 变得一致,设计意图 priority,priority case: - full_case,full_case的 仿真和综合,所有的可能都已经定义了, 任何其他的可能都是错误的,priority case (1b1) irq0: irq= 4b1 0; irq1: irq= 4b1 1; irq2: irq= 4b1 2; irq3: irq= 4b1 3; endcase,priority if: - 所有的分支被指定后不需要最后结束的else,priority if (irq0) irq = 4b1; else if (irq1) irq = 4b2; else if (irq2) irq = 4b4; else if (irq3) irq = 4b8;,priority case (1b1) irq0: irq= 4b1 0; irq1: irq= 4b1 1; irq2: irq= 4b1 2; irq3: irq= 4b1 3; default: irq = 0; endcase,priority if (irq0) irq = 4b1; else if (irq1) irq = 4b2; else if (irq2) irq = 4b4; else if (irq3) irq = 4b8; else irq = 4b0;,irq0到irq3中至少有一个必定为高否则仿真就出现运行错误,default 或 最后的else语句 使得 priority关键字无效,设计意图 Unique,unique case: - full_case / parallel_case,full_case 和parallel_case 的仿真和综合,所有的可能都已经定义了, 任何其他的可能都是错误的,unique case (1b1) sel0: muxo = a; sel1: muxo = b; sel2: muxo = c; endcase,unique if: - full_case/ parallel_case,unique if (sel0) muxo = a; else if (sel1) muxo = b; else if (sel2) muxo = c;,if sel = = 3 b011 仿真出现运行错误,任何没有预料到的sel值 将使仿真出现运行错误,unique case (1b1) sel0: muxo = a; sel1: muxo = b; sel2: muxo = c; default: muxo = x; endcase,unique if (sel0) muxo = a; else if (sel1) muxo = b; else if (sel2) muxo = c; else muxo = x;,对没有预料到的sel值不会出现仿真运行错误,unique仍旧测试 覆盖的条件,Moore FSM举例 - - 状态图,FSM状态图,两个always块的编码风格 (符号、参数赋值时序always块),module sm2a (rd,ds,go,ws,clk,rstN); output rd, ds; input go, ws, clk, rstN; parameter IDLE = 2b00, READ = 2b01, DLY = 2b10, DONE = 2b11; reg 1:0 state, next; always (posedge clk or negedge rstN) if (!rstN) state =IDLE; else state = next;,Verilog 没有 枚举类型变量,参数被用于 有限状态机的设计,两个always块的编码风格 (组合逻辑always块-连续赋值输出),always (state or go or ws) begin next = 2bx; case(state) IDLE: if (go) next = READ; else next = IDLE; READ: next = DLY; DLY : if (!ws) next = DONE; else next = READ; DONE: next = IDLE; endcase end assign rd = (state = read)|(state=DLY); assign ds = (state = DONE); endmodule,仿真差错诀窍,综合优化诀窍,输出方法1 (连续赋值),两个always块的编码风格 (组合逻辑always块-always阻塞赋值输出), always (state or go or ws) begin next = 2bx; rd = 1b0; ds = 1 b0; case(state) IDLE: if (go) next = READ; else next = IDLE; READ: begin rd = 1b1; next = DLY; end DLY : begin rd = 1b1; if (!ws) next = DONE; else next = READ; end DONE: begin ds = 1b1; next = IDLE; end endcase end endmodule,初始化确省值的赋值 初始化输出值到确省态,输出方法2 (always 块赋值),枚举(enumerated)数据类型 (更高抽象层面的功能强大的数据类型),typedef enumred, yellow,green,blue,white,black clolors_t; clolors_t light1, light2; initial begin light1 = red; if (light1 = red) light1 = green; end,匿名的2态 整 型(int)变量,enum red, yellow,green light1,light2;,enum bronze=3, silver,gold medal;,enum a=0, b=7, c, d = 8 alphabet;,enum bronze=4h3, silver,gold medal;,silver = 4, gold = 5;,silver = 4h4, gold = 4h5;,语法错误 (隐含)c= 8, (明确)d = 8;,traffic_light = 0 (“red”),traffic_light = 2 (“green”),枚举类型的抽象,module fsm_svla_3; . enum IDLE, READ, DLY, DONE, XX state, next; . endmodule,无指定值的抽象 枚举名(值可以在 以后指定),枚举变量 state 和 next,逗号把括在内的 枚举名分隔开来,枚举关键字,枚举-赋整型值,module fsm_svla_3; . enum IDLE = 3b000, READ = 3b001, DLY = 3b010, DONE = 3b011, XX = 3b111 state, next; . endmodule,未指定数据类型, 即假定数据为整型,确省类型,用户对枚举名 赋值,在 FSM 设计用3个always块 应用枚举,module fsm_svla_3; (output reg rd,ds, input go, ws, clk,rst_n ); enum IDLE , READ , DLY , DONE , XX state, next; always (posedge clk, negedge rst_n) if (!rst_n) state = IDLE; else state = next; always * begin next = xx; case (state) IDLE: if (go) next = READ; else next = IDLE; READ: next = DLY; DLY: if (!ws) next = DONE; else next = READ; DONE: next = IDLE; end .,枚举的测试 和赋值, always (posedge clk, negedge rst_n) if (!rst_n) begin rd = 1b0; ds = 1b0; end else begin rd = 1b0; ds = 1b0; case (next) READ: rd = 1b1; DLY: rd = 1b1; DONE: ds = 1b1; endcase end endmodule,逗号分开的敏感列表,*表示组合逻辑的敏感列表 (简化的语法,减少RTL错误),抽象的枚举名,枚举 指定四状态值,module fsm_svlb_3; . enum reg 1:0 IDLE = 2b00, READ = 2b01, DLY = 2b10, DONE = 2b11, XX = x state, next; . endmodule,x 赋值在仿真无关项 优化综合和调试时非 常有用,指定4态数据类 型 允许数据值 为x 或者z,在 FSM 设计用3个always块 应用赋值枚举,module fsm_svla_3; (output reg rd,ds, input go, ws, clk,rst_n ); enum reg 1:0 IDLE=2b00 , READ=2b01 , DLY=2b10 , DONE =2b11 , XX =x state, next; always (posedge clk, negedge rst_n) if (!rst_n) state = IDLE; else state = next; always * begin next = xx; case (state) IDLE: if (go) next = READ; else next = IDLE; READ: next = DLY; DLY: if (!ws) next = DONE; else next = READ; DONE: next = IDLE; end ., always (posedge clk, negedge rst_n) if (!rst_n) begin rd = 1b0; ds = 1b0; end else begin rd = 1b0; ds = 1b0; case (next) READ: rd = 1b1; DLY: rd = 1b1; DONE: ds = 1b1; endcase end endmodule,从抽象到具体需要做的唯一 修改就是在枚举定义处赋值,赋值的枚举值,在 FSM 设计用3个always块 SystemVerilog 3.0 - 应用赋值枚举,module fsm_svla_3; (output reg rd,ds, input go, ws, clk,rst_n ); enum reg 1:0 IDLE=2b00 , READ=2b01 , DLY=2b10 , DONE =2b11 , XX =x state, next; always_ff (posedge clk, negedge rst_n) if (!rst_n) state = IDLE; else state = next; always_comb begin next = xx; unique case (state) IDLE: if (go) next = READ; else next = IDLE; READ: next = DLY; DLY: if (!ws) next = DONE; else next = READ; DONE: next = IDLE; end ., always (posedge clk, negedge rst_n) if (!rst_n) begin rd = 1b0; ds = 1b0; end else begin rd = 1b0; ds = 1b0; case (next) READ: rd = 1b1; DLY: rd = 1b1; DONE: ds = 1b1; endcase end endmodule,无论对仿真器和综合器以及 形式化验证工具 都相当于 full_case parallel_case,允许更多的类似lint 的代码检查,在 FSM 设计用3个always块 SystemVerilog 3.0 - 应用赋值枚举,enum reg 1:0 IDLE=2b00, READ=2b01, DLY=2b10, DONE =2b11 , XX =x state, next;,加入四状态变量的枚举类 型,允许合法状态赋值和 x状态赋值,以未定义的抽象 状态开始,enum IDLE, READ, DLY, DONE, XX state, next;,有利于抽象,有利于观察波形,有利于调试和 综合,枚举类型 波形显示,enum reg 1:0 IDLE=2b00, READ=2b01, DLY=2b10, DONE =2b11 , XX =x state, next;,确切标准的波形显示 能力正在定义中,循环语句的性能得到增强,module for4a( output reg 31:0 y, input 31:0 a, input s); integer i; always (a or s) for ( i=0; i32; i=i+1) if (!s) yi = ai; else yi = a 31-i; endmodule,module for4b( output logic 31:0 y, input 31:0 a, input s); always (a or s) for ( int i=0; i32; i+) if (!s) yi = ai; else yi = a 31-i; endmodule,独立的迭代 变量声明,本地迭代 变量声明,自动递加,本地迭代变量是 自动变量退出循 环后就不再存在,Verilog-2001,SystemVerilog,显式的递加,a31:0,a0:31,a31:0,i1,i0,s,y,y31:0,s,SystemVerilog 还增加了一个 do-while循环(底测试循环),隐含的端口连接,Verilog 和VHDL都能用按端口名连接或按顺序连接的方式引用实例模块 SystemVerilog用了两个新的隐含端口连接解决了顶层代码编写时表示端口连接代码的冗长 - .name 端口连接 - .* 隐含的端口连接,大型ASIC顶层模块的端口连接非常麻烦而且冗长,下面是一个中等大小模块的例子,中央算术逻辑单元(CALU)方块图,注意:所有寄存 器的时钟端都由 “clk”驱动,异步 复位都由“rst_n” 驱动,MultOp1 reg,shifter(0,1,4),MultOut reg,Accumulator,Barrel shifter (0-16),MUX,ALU (32bit),Multiplier,16 data,16,32,16,16,16,16,16,32,32,32,32,32,32,alu_out,acc,multout,bs,acc,alu_in,en_acc,alu_op2:0,muxsel,ld_multop1,ld_multout,ld_acc,ld_shft,en_shft,shft_lshft,bs_lshft4:0,ld_bs,mop1,mult,32,中央算术逻辑单元(CALU)模块之一,module calu3( inout 15:0 data; input 4:0 bs_lshft; input 2:0 alu_op; input 1:0 shft_lshft; input calu_muxsel, en_shft, ld_acc, ld_bs; input clk,rst_n); wire 31:0 acc, alu_in, alu_out, bs, mult, multout; wire 15:0 mop1; multop1 multop1 (.mop1, .data, .ld_multop1, .clk, . rst_n); multiplier multiplier(.mult, .mop1, .data); multoutreg multoutreg (.multout, .mult, .ld_multout, .clk, .rst_n);,MultOp1 reg,MultOut reg,Multiplier,multop1 multop1 (.mop1, .data, .ld_multop1, .clk, . rst_n);,端口名的匹配只 需要列出一次,中央算术逻辑单元(CALU)模块之二, barrel_shifter barrel_shifter( .bs, .data, .bs_lshft, .ld_bs, .clk, . rst_n); mult2 mux ( .y(alu_in), .i1(acc), .sel1(calu_muxsel); alu alu (.aluout, .zero( ), .neg( ), .alu_in, .acc, .alu_op); accumulator accumulator (.acc, .alu_out, .ld_acc, .clk, .rst_n); shifter shifter(.data, .acc, .shft_lshft,. ld_shft, .en_shft, .clk, . rst_n); tribuf tribuf (.data, .acc(acc15:0), en_acc); endmodule,具备所有按端口 名连接的优点,Barrel shifter (0-16),MUX,ALU (32bit),Accumulator,shifter(0,1,4),代码更简练!,中央算术逻辑单元(CALU)顶层模块 用 * 表示隐含的端口,module calu4( inout 15:0 data, input 4:0 bs_lshft, input 2:0 alu_op, input 1:0 shft_lshft, input ca

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论