diff options
author | Vasil Zlatanov <v@skozl.com> | 2016-12-12 21:51:10 +0000 |
---|---|---|
committer | Vasil Zlatanov <v@skozl.com> | 2016-12-12 21:51:10 +0000 |
commit | 4b6e0102d20d9ab060ce930e4b846c8be446bb06 (patch) | |
tree | e475eab3716738f2928f0b2063956e9b155f94ab /part_4/ex16/add3_ge5.v | |
download | e2-verilab-4b6e0102d20d9ab060ce930e4b846c8be446bb06.tar.gz e2-verilab-4b6e0102d20d9ab060ce930e4b846c8be446bb06.tar.bz2 e2-verilab-4b6e0102d20d9ab060ce930e4b846c8be446bb06.zip |
public push
Diffstat (limited to 'part_4/ex16/add3_ge5.v')
-rw-r--r-- | part_4/ex16/add3_ge5.v | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/part_4/ex16/add3_ge5.v b/part_4/ex16/add3_ge5.v new file mode 100644 index 0000000..0daf78a --- /dev/null +++ b/part_4/ex16/add3_ge5.v @@ -0,0 +1,31 @@ +//------------------------------
+// Module name: add3_ge5
+// Function: Add 3 to input if it is 5 or above
+// Creator: Peter Cheung
+// Version: 1.0
+// Date: 21 Jan 2014
+//------------------------------
+
+module add3_ge5(w,a);
+ input [3:0] w;
+ output [3:0] a;
+ reg [3:0] a;
+
+ always @ (w)
+ case (w)
+ 4'b0000: a <= 4'b0000;
+ 4'b0001: a <= 4'b0001;
+ 4'b0010: a <= 4'b0010;
+ 4'b0011: a <= 4'b0011;
+ 4'b0100: a <= 4'b0100;
+ 4'b0101: a <= 4'b1000;
+ 4'b0110: a <= 4'b1001;
+ 4'b0111: a <= 4'b1010;
+ 4'b1000: a <= 4'b1011;
+ 4'b1001: a <= 4'b1100;
+ 4'b1010: a <= 4'b1101;
+ 4'b1011: a <= 4'b1110;
+ 4'b1100: a <= 4'b1111;
+ default: a <= 4'b0000; // a cannot be 13 or larger, else overflow
+ endcase
+endmodule
\ No newline at end of file |