ECE241H1 - 20199 - 661580945892ECE241 Midterm Cheat Sheet
ECE241H1 - 20199 - 661580945892ECE241 Midterm Cheat Sheet
XNOR = xy + x̅y̅
GATED SR LATCH
ripple carry adder level / pos / neg triggered
jk flip flop
4 bit parallel load shift register NEG EDGE TRIGGERED D FLIP FLOP
master slave D flip flop
mod sim
vlib: set the working directory, where all the compiled
Verilog goes, use vlib work
• you can see responses that cannot be observed in Use NOR gates to construct
hardware neg edge triggered gate
anais poirier
mux2to1 function select
module mux2to1(x, y, s, m); module FunctionSelect(input [3:0] X, Y,
input x; //select 0 input [2:0] Sel,
input y; //select 1 output reg [3:0]
input s; //select signal Fout);
output m; //output wire [3:0] w1, w2;
ModA U1(.X(X), .Y(Y), .ModAout(w1));
//assign m = s & y | ~s & x; ModB U2(.X(X), .Y(Y), .ModBout(w2));
// OR always @(*)
assign m = s ? y : x; case (Sel)
3'b000: Fout = w1;
endmodule 3'b001: Fout = ~X;
3'b010: Fout = {X[3:2],Y[1:0]};
3'b011: Fout = w2;
shift register 3'b100: Fout = ~(X & Y);
module ShiftReg( default: Fout = 3'b000;
input [3:0] D, endcase // case (Sel)
input Clock, endmodule // FunctionSelect
Resetn,
Loadn,
output SerialOut); .do
reg [3:0] Q; vlib work
vlog mux.v
always @(posedge Clock) vsim mux
if (!Resetn) log {/*}
add wave {/*}
Q <= 0; #signal names need to be in {} brackets
else if (!Loadn) force {SW[0]} 0
Q <= D; force {SW[1]} 0
else begin force {SW[9]} 0
Q[0] <= 1'b1; run 10ns
Q[1] <= Q[0];
Q[2] <= Q[1];
Q[3] <= Q[2];
end
assign SerialOut = Q[3];
endmodule
add 8
module add8(
input [7:0] A,
input [7:0] B,
output [7:0] Sum,
output Cout);
assign {Cout, Sum} = A+B;
endmodule
4 bit register
module reg4bit (D, Clock, Resetb,
Enable, Q);
input [3:0] D;
input Clock, Resetb, Enable;
output reg [3:0] Q;
3 bit add
module adder(A, B, S, cin,
cout);
input [2:0] A, B;
input cin;
output [2:0] Sum;
output cout;
full_adder F0(
.ci(cin),
.a(A[0]),
.b(B[0]),
.s(S[0]),
.co(f_cout[0])
);
full_adder F0(
.ci(f_cout[0]),
.a(A[1]),
.b(B[1]),
.s(S[1]),
.co(f_cout[0])
);
full_adder F0(
.ci(f_cout[1]),
.a(A[2]),
.b(B[2]),
.s(S[2]),
.co(f_cout[0])
);
endmodule