Docsity

Verilog Code - Digital Design and Synthesis - Solved Assignment, Exercises of Computer Science

Toggle sidebar
bg1
ECE551 Homework 4 solutions 1
Problem 2:
a) b,y
b) a,b,n,f,t,j
c) b,k
d) posedge clk
e) posedge clk
f) posedge clk, posedge set
g) The description in (f) behaves incorrectly when set becomes high and rst_n happens to be 1’b0. In this
case, y will be reset to zero asynchronously.
h) The simulator will have to do extra work as it will fire the always block redundantly when this extra signal
changes, even though nothing will change in the always block. Synthesis will work normally.
Problem 3:
a)
1
1’b0
g
f
y
z
h
0
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Verilog Code - Digital Design and Synthesis - Solved Assignment and more Exercises Computer Science in PDF only on Docsity!

Problem 2: a) b,y b) a,b,n,f,t,j c) b,k d) posedge clk e) posedge clk f) posedge clk, posedge set g) The description in (f) behaves incorrectly when set becomes high and rst_n happens to be 1’b0. In this case, y will be reset to zero asynchronously. h) The simulator will have to do extra work as it will fire the always block redundantly when this extra signal changes, even though nothing will change in the always block. Synthesis will work normally. Problem 3: a) 1 1’b

g

f y

z

h

b) Problem 4: `default_nettype none module decoder3_to_8 (input wire E3, E2_n, E1_n, A2, A1, A0,output reg Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n); always@(*) begin casex ({E3, E2_n, E1_n, A2, A1, A0}) 6'b100_000: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b1111_1110; 6'b100_001: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b1111_1101; 6'b100_010: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b1111_1011; 6'b100_011: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b1111_0111; 6'b100_100: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b1110_1111; 6'b100_101: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b1101_1111; 6'b100_110: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b1011_1111; 6'b100_111: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b0111_1111; default: {Y7_n, Y6_n, Y5_n, Y4_n, Y3_n, Y2_n, Y1_n, Y0_n} = 8'b1111_1111; endcase end endmodule

g

h

f

c

d

module t_recursive_avg; reg [7:0] d, threshold; reg clk, clr_n; wire [7:0] filtered_d; wire alarm; initial begin clk=0; forever #5 clk=~clk; end initial $monitor("%t alarm:%b", $time,alarm); recursive_avg DUT(filtered_d, alarm, d, threshold, clk, clr_n); initial begin threshold=8'd200; d=8'd255 ; clr_n=0; #10 clr_n=1; #500 d=0; #500; threshold=8'd100; d=8'd200 ; clr_n=0; #10 clr_n=1; #500 d=0; #500; threshold=8'd100; d=8'd110 ; clr_n=0; #10 clr_n=1; #500 d=0; #500; threshold=8'd30; d=8'd3 ; clr_n=0; #10 clr_n=1; #500 d=0; #500; #1 $stop; end endmodule

Problem 6:

  • 0 EVAL e- 2 - 2 a= 0 b= 0 c= 0 d= 0 e= 0 s= 0 UP d=-2 @t= Time Type Statement Result Values Scheduled Events
  • 0 EVAL 4 4 a= 0 b= 0 c= 0 d= 0 e= 0 s= 0 UP a=4@t=
  • 0 UP a= 4 a= 4 b= 0 c= 0 d= 0 e= 0 s= 0 al@(a,b,d), al@(*) @t=
  • 0 EVAL 3 3 a= 4 b= 0 c= 0 d= 0 e= 0 s= 0 UP b=3 @t=
  • 0 EVAL a+c+d+e 4 a= 4 b= 0 c= 0 d= 0 e= 0 s= 0 UP s=4 @t=
  • 0 EVAL s%5 0 a= 4 b= 0 c= 0 d= 0 e= 0 s= 0 UP s=0 @t=
  • 0 UP s= 0 a= 4 b= 0 c= 0 d= 0 e= 0 s=
  • 2 EVAL (2*d)+2 2 a= 4 b= 0 c= 0 d= 0 e= 0 s= 0 UP b=0 @t=
  • 2 UP b= 2 a= 4 b= 2 c= 0 d= 0 e= 0 s=
  • 3 UP d= - 2 a= 4 b= 2 c= 0 d=-2 e= 0 s= 0 al@(*) @t=
  • 3 EVAL a+c+d+e 4 a= 4 b= 2 c= 0 d=-2 e= 0 s= 0 UP s=2 @t=
  • 4 EVAL a+1 5 a= 4 b= 2 c= 0 d=-2 e= 0 s= 0 UP e=5 @t=
  • 4 UP e= 5 a= 4 b= 2 c= 0 d=-2 e= 5 s= 0 al@(*) @t=
  • 4 EVAL a+c+d+e 7 a= 4 b= 2 c= 0 d=-2 e= 5 s= 0 UP s=7 @=
  • 6 UP s= 4 a= 4 b= 2 c= 0 d=-2 e= 5 s=
  • 7 UP b= 3 a= 4 b= 3 c= 0 d=-2 e= 5 s= 4 al@(a,b,d) @t=
  • 7 EVAL s%5 4 a= 4 b= 3 c= 0 d=-2 e= 5 s= 4 UP s=4 @t=
  • 7 UP s= 4 a= 4 b= 3 c= 0 d=-2 e= 5 s=
  • 9 UP s= 2 a= 4 b= 3 c= 0 d=-2 e= 5 s=
  • 9 EVAL 5 5 a= 4 b= 3 c= 0 d=-2 e= 5 s= 2 UP a=5 @t=
  • 9 UP a= 5 a= 5 b= 3 c= 0 d=-2 e= 5 s= 2 al@(*) @t=
  • 9 EVAL a+c+d+e 7 a= 5 b= 3 c= 0 d=-2 e= 5 s= 2 UP s=8 @t=
  • 9 EVAL (2*d)+2 - 2 a= 5 b= 3 c= 0 d=-2 e= 5 s= 2 UP b=-2 @t=
  • 9 UP b= - 2 a= 5 b=-2 c= 0 d=-2 e= 5 s=
  • 10 UP s= 7 a= 5 b=-2 c= 0 d=-2 e= 5 s=
  • 11 EVAL a+1 6 a= 5 b=-2 c= 0 d=-2 e= 5 s= 7 UP e=6 @t=
  • 11 UP e= 6 a= 5 b=-2 c= 0 d=-2 e= 6 s= 7 al@(*) @t=
  • 11 EVAL a+c+d+e 9 a= 5 b= -2 c= 0 d=-2 e= 6 s= 7 UP s=9 @t=
  • 15 UP s= 8 a= 5 b= -2 c= 0 d=-2 e= 6 s=
  • 17 UP s= 9 a= 5 b= -2 c= 0 d=-2 e= 6 s=