Created
September 28, 2021 01:43
-
-
Save mcandre/13f4ce07ef7248f5641d015d0c9e9b09 to your computer and use it in GitHub Desktop.
half_adder SystemVerilog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module half_adder( | |
input clk, | |
a, | |
b, | |
output reg sum, | |
carry | |
); | |
always @(posedge clk) | |
begin | |
sum <= a ^ b; | |
carry <= a & b; | |
end | |
endmodule | |
module test_half_adder; | |
reg clk = 0; | |
always #1 clk = !clk; | |
wire a = 0, | |
b = 0; | |
reg sum = 0, | |
carry = 0; | |
half_adder ha(clk, a, b, sum, carry); | |
initial | |
$monitor( | |
"Time: %t, clk: %0d, a: %0d, b: %0d, sum: %0d, carry: %0d", | |
$time, | |
clk, | |
a, | |
b, | |
sum, | |
carry | |
); | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basing my source from an iverilog tutorial.
https://iverilog.fandom.com/wiki/Getting_Started