aboutsummaryrefslogtreecommitdiff
path: root/bcd_adder.v
diff options
context:
space:
mode:
Diffstat (limited to 'bcd_adder.v')
-rw-r--r--bcd_adder.v13
1 files changed, 13 insertions, 0 deletions
diff --git a/bcd_adder.v b/bcd_adder.v
new file mode 100644
index 0000000..16790bd
--- /dev/null
+++ b/bcd_adder.v
@@ -0,0 +1,13 @@
+module bcd_adder(
+ input wire [3:0] a,
+ input wire [3:0] b,
+ output reg [7:0] x
+);
+ always @(*) begin
+ assign x = a + b;
+
+ if (x > 9) begin
+ x = x + 6;
+ end
+ end
+endmodule