Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16598 Discussions

Hello, I am trying to convert BCD to Decimal on my DE10-Lite board. I want utilize all all six seven-segment displays but I'm don't know how to go about it. At the moment I can't seem to get two of seven-segments displays to work correctly.

KRose13
Beginner
1,847 Views

module DE10_LITE_Default (SW,HEX1,HEX0);

input [3:0]SW;

output [6:0]HEX1,HEX0;

wire z ;

wire [3:0]y , m; 

wire [2:0]b;

assign y = {1'b0,b};

//-------------------------

// comparator  compar1(SW[3],SW[2],SW[1],SW[0],z);

 circuitA      circuita(SW[2:0],b[2:0]);

 multi       multi1(z,SW[3:0],y,m);

 circuitB      hex1(z,HEX1);

 char_7seg  hex0(m , HEX0 );

//-------------------------

endmodule 

//--------------------------------------------------

//module eq2 ( 

// input wire[1:0] a,b, 

// output wire q ) ; 

// wire q3, q2,q1,q0; 

//assign q = q3|q2|q1|q0;

//assign q3 = ( ~a[1] &~ a[0] ) & (~b[1] &~b[0]);

//assign q2 = ( ~a[1] & a[0] ) & (~b[1] &b[0]);

//assign q1 = ( a[1] &~ a[0] ) & (b[1] &~b[0]);

//assign q0 = ( a[1] & a[0] ) & (b[1] &b[0]);

//endmodule 

//------------------------------------------------

//module eq3 ( 

// input wire[1:0] a,b, 

// output wire q ) ; 

// wire q1, q0; 

//eql  bit0(a[0], b[0], q0);

//eql  bit1( a[1], b[1], q1 );

//assign q = q0&q1; 

//endmodule 

//-------------------------------------------------

//-------------------------------------

//module eql ( 

// input wire a,b, 

// output wire q ) ; 

// wire p0, p1; 

//  assign q = p0 |p1; 

//  assign p0 = ~a & ~b; 

// assign p1 = a & b; 

//endmodule

//-----------------------------------

//------------------------------------------

//module comparator(a,b,c,d,q);

//input a,b,c,d;

//output q ;

//wire q5,q4,q3,q2,q1,q0;

//assign q = q5|q4|q3|q2|q1|q0;

//assign q5 = a&~b&c&~d;  //10

//assign q4 = a&~b&c&d;  //11

//assign q3 = a&b&~c&~d;  //12

//assign q2 = a&b&~c&d;  //13

//assign q1 = a&b&c&~d;  //14

//assign q0 = a&b&c&d;   //15

//endmodule

//-----------------------------------------

module circuitA(a,b);

input [2:0]a;

output [2:0]b;

assign b[2:0] = (a[2:0] == 3'b010) ?3'b000 : // 2 ? 0

             (a[2:0] == 3'b011) ?3'b001 : // 3 ? 1

             (a[2:0] == 3'b100) ?3'b010 : // 4 ? 2

             (a[2:0] == 3'b101) ?3'b011 : // 5 ? 3

             (a[2:0] == 3'b110) ?3'b100 : // 6 ? 4

             (a[2:0] == 3'b111) ?3'b101 :3'b111; // 7 ? 5 : 7

endmodule

//--------------------------------------

 

module circuitB(a,hex);

input [0:0]a;

output [6:0]hex;

assign hex[6:0] = (a[0] == 1'b1)? 7'b111_1001 : 7'b100_0000; // 1 - 0

endmodule

 

//-----------------------------------------

module multi(s,x,y,m);

input s;

input [3:0]x,y;

output [3:0]m;

assign m[3] = (~s&x[3] ) | (s&y[3]);

assign m[2] = (~s&x[2] ) | (s&y[2]);

assign m[1] = (~s&x[1] ) | (s&y[1]);

assign m[0] = (~s&x[0] ) | (s&y[0]);

endmodule

//------------------------------------------

module char_7segs(sw,hex);

input [3:0]sw;

output [6:0]hex;

// seg = {g,f,e,d,c,b,a};

// 0 is on and 1 is off

// ---a----

// |    |

// f     b

// |    |

// ---g---- 

// |    |

// e     c

// |    |

// ---d----

assign hex= (sw[3:0] == 4'b0000 )? 7'b100_0000: // 0

      (sw[3:0] == 4'b0001 )? 7'b111_1001: // 1

      (sw[3:0] == 4'b0010 )? 7'b010_0100: // 2

      (sw[3:0] == 4'b0011 )? 7'b011_0000: // 3

      (sw[3:0] == 4'b0100 )? 7'b001_1001: // 4

      (sw[3:0] == 4'b0101 )? 7'b001_0010: // 5

      (sw[3:0] == 4'b0110 )? 7'b000_0010: // 6

      (sw[3:0] == 4'b0111 )? 7'b000_0111: // 7

      (sw[3:0] == 4'b1000 )? 7'b000_0000: // 8

      (sw[3:0] == 4'b1001 )? 7'b001_1000:7'b111_1111; // 9 - blank

endmodule

//----------------------------------------------------------------

 

0 Kudos
3 Replies
SyafieqS
Moderator
1,833 Views

Hi Kassy,

 

Could you point out which line in the mass of code is the line that gave rise or suspect to the error.

 

Thanks,

Regards

 

0 Kudos
KRose13
Beginner
1,833 Views

Hello Syafieq_Intel,

 

I can compile the code but once I have loaded to the DE10-Lite board my display is out.

display results below.

All switches off : HEX1 = 0 , HEX0 = Blank

SW2 switched on: HEX1 and HEX0=0

SW1 and SW2 switched on: HEX1= 0 and HEX0= E

SW0, SW1 and SW2 switched on: HEX1= 0 and HEX0=H

 

The BCD to decimal display is not functioning correctly and I think the code is to big but I'm not sure how to condense it.

I will need to utilize all six of seven segment display and perhaps using the LED's to indicate the Binary inputs.

 

Thanks

 

Kassy

0 Kudos
KRose13
Beginner
1,833 Views

This is what I am trying to achieve.

 

first task;

Use switches SW7−4 and SW3−0 for the inputs A and B, respectively, and use SW8 for the carry-in. The value of A should be displayed on the 7-segment display HEX5, while B should be on HEX3. Display the BCD sum, S1S0, on HEX1 and HEX0.

 

Second task;

Design a combinational circuit that converts a 6-bit binary number into a 2-digit decimal number represented in the BCD form. Use switches SW5−0 to input the binary number and 7-segment displays HEX1 and HEX0 to display the decimal number.

 

Finding these tasks difficult as I am very new to this and I have a few more task like these.

So, I will need all the help I can get.

0 Kudos
Reply