1、VerilogHDL数字设计与综合夏宇闻译第二版课后题答案Verilog-HDL数字设计与综合-夏宇闻译(第二版)课后题答案LT c: -2(1010)-取反(1101)-再加一(1110) d: h1234/*2-*/ a:正确 b:正确 c:正确 d:正确/*3-*/ a : 合法 b : 合法 c : 不合法,含有$ 为延时含义 d : 标识符组成:字母数字下划线。/*4-*/ a: wire 7:0 a_in; b: reg 31:0 c: integer count; d: time snap_shot; e: integer delays20; f: reg 63:0 mem256
2、; g: parameter cach_size=256;/*5-*/ a : 1010 b: 10 c : 400第四章/*1-*/模块的基本组成部分有哪些?哪几个部分必须出现? 模块定义已关键字module开始,模块名,端口列表,端口声明和可选的参数声明出现在其他部分的前面 ,endmodule必须为最后一条语句 1)wire。reg和其他类型的变量的声明 2)数据流语句 (assign,连续赋值语句) 3)低层模块实例 4)always和initial块,所有的行为语句都在这些块中 5) 任务和函数。 其中module和模块名和endmodule是必不可少的。 /*2-*/ /一个不与外
3、界环境交互的模块是否有端口?模块定义中是否有端口列表? 不与外界交互即没有端口列表,在没有端口的情况下端口列表也是不存在的。/*3-*/ module shift_reg(reg_in3:0 , clock , reg_out3:0 ); input 3:0 reg_in; input clock; output 3:0 reg_out; /. endmodule;/*4-*/ /connect in order module stimulus(); reg 3:0 REG_IN; wire 3:0 REG_OUT; reg CLK; shift_reg sr1(REG_IN,CLK,REG_
4、OUT); endmodule/*5-*/ /connect by name module stimulus(); reg 3:0 REG_IN; wire 3:0 REG_OUT; reg CLK; shift_reg sr1(.clock(CLK) ,.reg_in(REG_IN) , .reg_out(REG_OUT) ); endmodule/*6-*/ stimulus.REG_IN stimulus.CLK; stimulus.REG_OUT;/*7-*/ stimulus.sr1; stimulus.sr1.clock; stimulus.sr1.reg_in; stimulus
5、.sr1.reg_out;第五章/*1-*/ /利用双输入的nand门设计自己的与或非门。 /my_and module my_and(out , in1,in2); input in1,in2; output out; endmodule /my_not module my_not(out , in1); input in1; output out; nand(out , in1 ,in1 ); endmodule /my_and module my_or(out ,in1 ,in2); wire t; nand(t,in1,in2); nand(out,t,t); / endmodule/
6、*2-*/ /使用上题中完成的my_or,my_and,my_not构造一个双 /输入的xor门,其功能是计算z=xy+xy /*3-*/ /全加器 module sum(a,b,c_in,sum,c_out); input a,b,c_in; output sum,c_out; wire y1,y2,y3,y4; wire x1,x2,x3; or(sum,y1,y2,y3,y4); and(y1,a,b,c_in); and(y2,x1,b,x3); and(y3,x1,x2,c_in); and(y4,a,x2,x3); not(x1,a); not(x2,b); not(x3,c);
7、wire j1,j2,j3; or(c_out,j1,j2,j3); and(j1,a,b); and(j2,b,c_in); and(j3,a,c_in); endmodule /*4-*/带有延时的SR锁存器 module SR(reset , q ,set , qbar); input reset,set; output q,qbar; wire line1,line2; nor( line2 , reset ,line1 ); nor( line1, set ,line2 ); endmodule/*-ISE中一个端口如何接多根线?*/*5-*/ module select(out,i
8、n1,in2,s); input in1,in2,s; output out; /3为上升延迟,4为下降延时,5为关断延迟。 bufif1 #(1:2:3,3:4:5,5:6:7) b2(out,in1,s); bufif0 #(1:2:3,3:4:5,5:6:7) b1(out,in2,s); endmodule/*-*/第六章/*1-*/全减器/输入 :x,y,z(前面的借位)/输出: 差和借位module sub(x,y,z,D,B); input x,y,z; output D,B; wire y0,y1,y2,y3; wire j1,j2,j0; /非门 not(j0,x); not
9、(j1,y); not(j2,z); and(y0,j0,j1,j2); and(y1,j0,y,j2); and(y2,x,j1,j2); and(y3,x,y,z); or(D,y0,y1,y2,y3); /B wire a1,a0,a2; and(a0 , j0 ,y); and( a1, j0, z); and( a2, y , z); or(B,a1,a0,a2); endmodule/激励模块:module stimulus;/initial 从仿真0时刻开始,而且只执行一次,若程序中有若干个initial块,则并发执行。 reg a,b,c; wire d,e; reg i; s
10、ub sub(a,b,c,d,e); initial for(i=1 ;i0;) begin #5 ; a=1; b=1; c=0; #5; a=1; b=0; c=0; endendmodule/*2-*/大小比较器module cmp(A ,B ,A_gt_B , A_lt_B,A_eq_B); input 3:0 A,3:0 B; output A_gt_B , A_lt_B , A_eq_B ; endmodule/*3 -*/ module syn_counter(clear,clock,count_enable,Q); input clear,clock,count_enable;
11、 output 3:0 Q; wire 3:0 Q; wire b1,b2,b3; nand(b1,count_enable,Q1); nand(b2,b1,Q2); nand(b3,b2,Q3); jk jk1(count_enable,count_enable,clear,clock,Q0,); jk jk2(b1,b1,clear,clock,Q1,); jk jk3(b2,b2,clear,clock,Q2,); jk jk4(b3,b3,clear,clock,Q3,);endmodulemodule jk(J,K,clear,clock,q,qbar); input J,K,cle
12、ar,clock; output q,qbar; wire a,y,c,b,ybar,cbar,d; not (cbar,clock); nand a1(a,qbar,J,clock,clear); nand a2(b,clock,K,q); nand a3(y,a,ybar); nand a4(ybar,y,clear,b); nand a5(c,y,cbar); nand a6(d,cbar,ybar); nand a7(q,c,qbar); nand a8(qbar,q,clear,d);endmodule第七章/*1-*/ reg oscillate=0; initial begin forever #30 oscillate=oscillate; end/*2-*/ initial clock=0; always begin #30 clock=1; #10 clock=0; end/*3 -*/ 执行时刻:0,10,15,35. 最终结果:a=0,b=1,c=0;d=3b010;/*4-*/ 执行时刻:0,10,5,20. 最终结果:a=0,b=1,c=0;d=3b010;/*5 -*/ a,b,c,d: 0 ,1,1,0 /每个initial中的语句是串行执行的。/*6 -*/ d=0;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1