



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




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
f y
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
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