OpenCores
URL https://opencores.org/ocsvn/vtach/vtach/trunk

Subversion Repositories vtach

[/] [vtach/] [trunk/] [digitadd.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wd5gnr
`timescale 1us/1us
2
// Do BCD addition
3
module digitadd( input [3:0] a, input [3:0] b, input cyin, output reg [3:0] z, output reg cyout);
4
   wire [4:0] temp;
5
// add everything together in binary
6
   assign temp={1'b0,a}+{1'b0,b}+{4'b0, cyin};
7
 
8
// Now look at the answer and decode
9
   always @(temp) begin
10
   case (temp)
11
     10: begin z=4'h0; cyout=1'b1; end
12
     11: begin z=4'h1; cyout=1'b1; end
13
     12: begin z=4'h2; cyout=1'b1; end
14
     13: begin z=4'h3; cyout=1'b1; end
15
     14: begin z=4'h4; cyout=1'b1; end
16
     15: begin z=4'h5; cyout=1'b1; end
17
     16: begin z=4'h6; cyout=1'b1; end
18
     17: begin z=4'h7; cyout=1'b1; end
19
     18: begin z=4'h8; cyout=1'b1; end
20
     19: begin z=4'h9; cyout=1'b1; end
21
// all other cases are easy
22
     default: begin z=temp[3:0];  cyout=1'b0; end
23
   endcase
24
   end
25
endmodule // digitadd

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.