aruna siddappa
Newbie level 5
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 module mult_3 ( input wire [3:0] x, input wire en, output reg [11:0] y); always @ (*) begin if(en) y=(x*3); else y=0; end endmodule module mult_9 ( input wire [3:0] x, input wire en, output reg [11:0] y); always @ (*) begin if(en) y=(x*9); else y=0; end endmodule module mult_11 ( input wire [3:0] x, input wire en, output reg [11:0] y); always @ (*) begin if(en) y=(x*11); else y=0; end endmodule module mult_83 ( input wire [3:0] x, input wire en, output reg [11:0] y); always @ (*) begin if(en) y=(x*83); else y=0; end endmodule module top ( input wire [3:0] in, input wire [1:0] data_id, output [11:0] result); wire en1,en2,en3,en4; assign en1=(~data_id[1] & ~data_id[0]); assign en2=(~data_id[1] & data_id[0]); assign en3=(data_id[1] & ~data_id[0]); assign en4=(data_id[1] & data_id[0]); mult_3 dut1 (.x(in),.en(en1),.y(result)); mult_9 dut2 (.x(in),.en(en2),.y(result)); mult_11 dut3 (.x(in),.en(en3),.y(result)); mult_83 dut4 (.x(in),.en(en4),.y(result)); endmodule
The result is initially 0, then in the place of 1 it's showing x
Last edited by a moderator: