Está en la página 1de 2

`timescale 1ns / 1ps

module compuertas(
input AA, BB, CC,
output y_and, y_or, y_notA, y_nand, y_xor
);

assign y_notA= ~AA;


assign y_or = AA | BB | CC;
assign y_and = AA & BB & CC;
assign y_nand = ~(AA & BB & CC);
assign y_xor = AA ^ BB;

endmodule

// ESTÍMULOS PARA SIMULACIÓN .


/* sintaxis para la conexión entre el archivo de estímulos y el módulo diseñado
nombre_módulo etiqueta(
.puerto_diseño(variable_estímulos),
.puerto_diseño(variable_estímulos)
);
*/

`timescale 1ns / 1ps


module stim_compuertas();
reg wAA, wBB, wCC; // se declaran como tipo “reg” aquellas variables a las
// que se le dan valores dentro de un “always” o “initial”
wire wy_and, wy_or, wy_notA, wy_nand, wy_xor; // las demás variables se declaran como tipo “wire”

compuertas test(
.AA(wAA),
.BB(wBB),
.CC(wCC),
.y_and(wy_and),
.y_or(wy_or),
.y_notA(wy_notA),
.y_nand(wy_nand),
.y_xor(wy_xor)
);

initial begin // Ejercicio: ¿cómo varía la simulación si cambio este “initial” por “always”?
wAA = 0; wBB = 0; wCC = 0;// valores de las entradas para los cuales se desea simular el circuito
#100; // #retardo
wAA = 0; wBB = 0; wCC = 1; #100;
wAA = 0; wBB = 1; wCC = 0; #100;
wAA = 0; wBB = 1; wCC = 1; #100;
wAA = 1; wBB = 0; wCC = 0; #100;
wAA = 1; wBB = 0; wCC = 1; #100;
wAA = 1; wBB = 1; wCC = 0; #100;
wAA = 1; wBB = 1; wCC = 1; #100;
end

// sintaxis necesaria para simular con “icarus verilog” //


initial begin //
$dumpfile("RESULTS.vcd"); //
$dumpvars; //
#(8*100); // tiempo de simulación
$finish; //
end //

endmodule

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

También podría gustarte