Files
WMU-ECE-3570-Lab/lab2CA.srcs/sources_1/new/BasicModules.v
2019-02-15 14:48:57 -05:00

48 lines
964 B
Verilog

`timescale 1ns / 1ps
module gen_clock();
reg clk;
initial begin
clk = 1'b0;
end
always begin
#5 clk = ~clk; // Period to be determined
end
endmodule
module mux(input wire [1:0] switch,
input wire [8:0] A,B,C,D,
output reg [8:0] out);
always @(A,B,C,D,switch) begin
case (switch)
2'b00 : out = A;
2'b01 : out = B;
2'b10 : out = C;
default: out = D;
endcase
end
endmodule
module register(input wire clk, reset,
input wire [1:0] En,
input wire [8:0] Din,
output reg [8:0] Dout);
always @(posedge clk) begin
if (reset == 1'b1) begin
Dout <= 9'b000000000;
end
else if (En == 2'b00) begin
Dout <= Din;
end
else begin
Dout <= "ZZZZZZZZZ";
end
end
endmodule