David83
Advanced Member level 1
Hello all,
I tried to write the design and stimulus blocks for a 2-bit mux using structural modeling. I wrote the modules as following:
I did functional verification, and the design block is working fine. The total system's schematic, as well as the schematic of MUX1, I obtained from Vivado are attached. I just wonder if any of the three modules could have be written more efficiently. Any hint about this?
Thanks
I tried to write the design and stimulus blocks for a 2-bit mux using structural modeling. I wrote the modules as following:
Code:
// 1-bit Mux
module mux(out,S,A,B);
input A,B,S;
output out;
not (S_n,S);
and (I1,A,S_n);
and (I2,B,S);
or (out,I1,I2);
endmodule
module mux2bit(Out,S,A,B);
input S;
input [1:0] A;
input [1:0] B;
output [1:0] Out;
mux MUX1(Out[1],S,A[1],B[1]);
mux MUX2(Out[0],S,A[0],B[0]);
endmodule
// Testbench for 2-bit MUX
`timescale 1ns/1ns
module mux_tb;
reg clk;
reg [1:0] A;
reg [1:0] B;
reg S;
wire [1:0] out;
initial
begin
clk=1;
S=0;
A=2'b11;
B=2'b00;
end
always #5 clk=~clk;
always #40 S=~S;
always @(posedge clk)
begin
A=A+1;
B=B+1;
end
mux2bit MUT(out,S,A,B);
endmodule
I did functional verification, and the design block is working fine. The total system's schematic, as well as the schematic of MUX1, I obtained from Vivado are attached. I just wonder if any of the three modules could have be written more efficiently. Any hint about this?
Thanks